Merge pull request #3718 from atom/chrome47-linux

Port Chrome47 on Linux
This commit is contained in:
Cheng Zhao 2015-12-08 10:14:27 +08:00
Родитель e78a02806e 9a0cecf943
Коммит e8b5a6dedf
5 изменённых файлов: 48 добавлений и 36 удалений

Просмотреть файл

@ -22,7 +22,9 @@ gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
// Makes .* file extension matches all file types. // Makes .* file extension matches all file types.
if (*file_extension == ".*") if (*file_extension == ".*")
return true; return true;
return base::EndsWith(file_info->filename, *file_extension, false); return base::EndsWith(
file_info->filename,
*file_extension, base::CompareCase::INSENSITIVE_ASCII);
} }
// Deletes |data| when gtk_file_filter_add_custom() is done with it. // Deletes |data| when gtk_file_filter_add_custom() is done with it.

Просмотреть файл

@ -17,7 +17,6 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#elif defined(USE_X11) #elif defined(USE_X11)
#include "chrome/browser/ui/libgtk2ui/owned_widget_gtk2.h"
#include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h"
#endif #endif
@ -33,15 +32,16 @@ const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233);
#if defined(USE_X11) #if defined(USE_X11)
void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight, void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight,
SkColor* hover, SkColor* background) { SkColor* hover, SkColor* background) {
libgtk2ui::OwnedWidgetGtk fake_menu_bar; GtkWidget* menu_bar = gtk_menu_bar_new();
fake_menu_bar.Own(gtk_menu_bar_new());
GtkStyle* style = gtk_rc_get_style(fake_menu_bar.get()); GtkStyle* style = gtk_rc_get_style(menu_bar);
*enabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_NORMAL]); *enabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_NORMAL]);
*disabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_INSENSITIVE]); *disabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_INSENSITIVE]);
*highlight = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_SELECTED]); *highlight = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_SELECTED]);
*hover = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_PRELIGHT]); *hover = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_PRELIGHT]);
*background = libgtk2ui::GdkColorToSkColor(style->bg[GTK_STATE_NORMAL]); *background = libgtk2ui::GdkColorToSkColor(style->bg[GTK_STATE_NORMAL]);
gtk_widget_destroy(menu_bar);
} }
#endif #endif

Просмотреть файл

@ -13,6 +13,7 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "chrome/browser/speech/tts_platform.h" #include "chrome/browser/speech/tts_platform.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h"
#include "library_loaders/libspeechd.h" #include "library_loaders/libspeechd.h"
@ -32,18 +33,17 @@ struct SPDChromeVoice {
class TtsPlatformImplLinux : public TtsPlatformImpl { class TtsPlatformImplLinux : public TtsPlatformImpl {
public: public:
virtual bool PlatformImplAvailable() override; bool PlatformImplAvailable() override;
virtual bool Speak( bool Speak(int utterance_id,
int utterance_id, const std::string& utterance,
const std::string& utterance, const std::string& lang,
const std::string& lang, const VoiceData& voice,
const VoiceData& voice, const UtteranceContinuousParameters& params) override;
const UtteranceContinuousParameters& params) override; bool StopSpeaking() override;
virtual bool StopSpeaking() override; void Pause() override;
virtual void Pause() override; void Resume() override;
virtual void Resume() override; bool IsSpeaking() override;
virtual bool IsSpeaking() override; void GetVoices(std::vector<VoiceData>* out_voices) override;
virtual void GetVoices(std::vector<VoiceData>* out_voices) override;
void OnSpeechEvent(SPDNotificationType type); void OnSpeechEvent(SPDNotificationType type);
@ -52,7 +52,7 @@ class TtsPlatformImplLinux : public TtsPlatformImpl {
private: private:
TtsPlatformImplLinux(); TtsPlatformImplLinux();
virtual ~TtsPlatformImplLinux(); ~TtsPlatformImplLinux() override;
// Initiate the connection with the speech dispatcher. // Initiate the connection with the speech dispatcher.
void Initialize(); void Initialize();
@ -83,7 +83,7 @@ class TtsPlatformImplLinux : public TtsPlatformImpl {
// uniquely identify a voice across all available modules. // uniquely identify a voice across all available modules.
scoped_ptr<std::map<std::string, SPDChromeVoice> > all_native_voices_; scoped_ptr<std::map<std::string, SPDChromeVoice> > all_native_voices_;
friend struct DefaultSingletonTraits<TtsPlatformImplLinux>; friend struct base::DefaultSingletonTraits<TtsPlatformImplLinux>;
DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplLinux); DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplLinux);
}; };
@ -94,6 +94,11 @@ SPDNotificationType TtsPlatformImplLinux::current_notification_ =
TtsPlatformImplLinux::TtsPlatformImplLinux() TtsPlatformImplLinux::TtsPlatformImplLinux()
: utterance_id_(0) { : utterance_id_(0) {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kEnableSpeechDispatcher))
return;
BrowserThread::PostTask(BrowserThread::FILE, BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE, FROM_HERE,
base::Bind(&TtsPlatformImplLinux::Initialize, base::Bind(&TtsPlatformImplLinux::Initialize,
@ -111,7 +116,7 @@ void TtsPlatformImplLinux::Initialize() {
// http://crbug.com/317360 // http://crbug.com/317360
ANNOTATE_SCOPED_MEMORY_LEAK; ANNOTATE_SCOPED_MEMORY_LEAK;
conn_ = libspeechd_loader_.spd_open( conn_ = libspeechd_loader_.spd_open(
"chrome", "extension_api", NULL, SPD_MODE_SINGLE); "chrome", "extension_api", NULL, SPD_MODE_THREADED);
} }
if (!conn_) if (!conn_)
return; return;
@ -146,7 +151,7 @@ void TtsPlatformImplLinux::Reset() {
if (conn_) if (conn_)
libspeechd_loader_.spd_close(conn_); libspeechd_loader_.spd_close(conn_);
conn_ = libspeechd_loader_.spd_open( conn_ = libspeechd_loader_.spd_open(
"chrome", "extension_api", NULL, SPD_MODE_SINGLE); "chrome", "extension_api", NULL, SPD_MODE_THREADED);
} }
bool TtsPlatformImplLinux::PlatformImplAvailable() { bool TtsPlatformImplLinux::PlatformImplAvailable() {
@ -187,6 +192,10 @@ bool TtsPlatformImplLinux::Speak(
libspeechd_loader_.spd_set_voice_rate(conn_, 100 * log10(rate) / log10(3)); libspeechd_loader_.spd_set_voice_rate(conn_, 100 * log10(rate) / log10(3));
libspeechd_loader_.spd_set_voice_pitch(conn_, 100 * log10(pitch) / log10(3)); libspeechd_loader_.spd_set_voice_pitch(conn_, 100 * log10(pitch) / log10(3));
// Support languages other than the default
if (!lang.empty())
libspeechd_loader_.spd_set_language(conn_, lang.c_str());
utterance_ = utterance; utterance_ = utterance;
utterance_id_ = utterance_id; utterance_id_ = utterance_id;
@ -337,8 +346,9 @@ void TtsPlatformImplLinux::IndexMarkCallback(size_t msg_id,
// static // static
TtsPlatformImplLinux* TtsPlatformImplLinux::GetInstance() { TtsPlatformImplLinux* TtsPlatformImplLinux::GetInstance() {
return Singleton<TtsPlatformImplLinux, return base::Singleton<
LeakySingletonTraits<TtsPlatformImplLinux> >::get(); TtsPlatformImplLinux,
base::LeakySingletonTraits<TtsPlatformImplLinux>>::get();
} }
// static // static

Просмотреть файл

@ -21,7 +21,7 @@ const char kAppMenuRegistrarPath[] = "/com/canonical/AppMenu/Registrar";
// static // static
GlobalMenuBarRegistrarX11* GlobalMenuBarRegistrarX11::GetInstance() { GlobalMenuBarRegistrarX11* GlobalMenuBarRegistrarX11::GetInstance() {
return Singleton<GlobalMenuBarRegistrarX11>::get(); return base::Singleton<GlobalMenuBarRegistrarX11>::get();
} }
void GlobalMenuBarRegistrarX11::OnWindowMapped(unsigned long xid) { void GlobalMenuBarRegistrarX11::OnWindowMapped(unsigned long xid) {
@ -39,7 +39,7 @@ void GlobalMenuBarRegistrarX11::OnWindowUnmapped(unsigned long xid) {
} }
GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11()
: registrar_proxy_(NULL) { : registrar_proxy_(nullptr) {
// libdbusmenu uses the gio version of dbus; I tried using the code in dbus/, // libdbusmenu uses the gio version of dbus; I tried using the code in dbus/,
// but it looks like that's isn't sharing the bus name with the gio version, // but it looks like that's isn't sharing the bus name with the gio version,
// even when |connection_type| is set to SHARED. // even when |connection_type| is set to SHARED.
@ -49,11 +49,11 @@ GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11()
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START), G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START),
NULL, nullptr,
kAppMenuRegistrarName, kAppMenuRegistrarName,
kAppMenuRegistrarPath, kAppMenuRegistrarPath,
kAppMenuRegistrarName, kAppMenuRegistrarName,
NULL, // TODO: Probalby want a real cancelable. nullptr, // TODO: Probalby want a real cancelable.
static_cast<GAsyncReadyCallback>(OnProxyCreatedThunk), static_cast<GAsyncReadyCallback>(OnProxyCreatedThunk),
this); this);
} }
@ -84,9 +84,9 @@ void GlobalMenuBarRegistrarX11::RegisterXID(unsigned long xid) {
"RegisterWindow", "RegisterWindow",
g_variant_new("(uo)", xid, path.c_str()), g_variant_new("(uo)", xid, path.c_str()),
G_DBUS_CALL_FLAGS_NONE, -1, G_DBUS_CALL_FLAGS_NONE, -1,
NULL, nullptr,
NULL, nullptr,
NULL); nullptr);
} }
void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) { void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) {
@ -105,14 +105,14 @@ void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) {
"UnregisterWindow", "UnregisterWindow",
g_variant_new("(u)", xid), g_variant_new("(u)", xid),
G_DBUS_CALL_FLAGS_NONE, -1, G_DBUS_CALL_FLAGS_NONE, -1,
NULL, nullptr,
NULL, nullptr,
NULL); nullptr);
} }
void GlobalMenuBarRegistrarX11::OnProxyCreated(GObject* source, void GlobalMenuBarRegistrarX11::OnProxyCreated(GObject* source,
GAsyncResult* result) { GAsyncResult* result) {
GError* error = NULL; GError* error = nullptr;
GDBusProxy* proxy = g_dbus_proxy_new_for_bus_finish(result, &error); GDBusProxy* proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
if (error) { if (error) {
g_error_free(error); g_error_free(error);
@ -128,7 +128,7 @@ void GlobalMenuBarRegistrarX11::OnProxyCreated(GObject* source,
g_signal_connect(registrar_proxy_, "notify::g-name-owner", g_signal_connect(registrar_proxy_, "notify::g-name-owner",
G_CALLBACK(OnNameOwnerChangedThunk), this); G_CALLBACK(OnNameOwnerChangedThunk), this);
OnNameOwnerChanged(NULL, NULL); OnNameOwnerChanged(nullptr, nullptr);
} }
void GlobalMenuBarRegistrarX11::OnNameOwnerChanged(GObject* /* ignored */, void GlobalMenuBarRegistrarX11::OnNameOwnerChanged(GObject* /* ignored */,

Просмотреть файл

@ -28,7 +28,7 @@ class GlobalMenuBarRegistrarX11 {
void OnWindowUnmapped(unsigned long xid); void OnWindowUnmapped(unsigned long xid);
private: private:
friend struct DefaultSingletonTraits<GlobalMenuBarRegistrarX11>; friend struct base::DefaultSingletonTraits<GlobalMenuBarRegistrarX11>;
GlobalMenuBarRegistrarX11(); GlobalMenuBarRegistrarX11();
~GlobalMenuBarRegistrarX11(); ~GlobalMenuBarRegistrarX11();