Merge pull request #3718 from atom/chrome47-linux
Port Chrome47 on Linux
This commit is contained in:
commit
e8b5a6dedf
5 changed files with 48 additions and 36 deletions
|
@ -22,7 +22,9 @@ gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
|
|||
// Makes .* file extension matches all file types.
|
||||
if (*file_extension == ".*")
|
||||
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.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#if defined(OS_WIN)
|
||||
#include "ui/gfx/color_utils.h"
|
||||
#elif defined(USE_X11)
|
||||
#include "chrome/browser/ui/libgtk2ui/owned_widget_gtk2.h"
|
||||
#include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h"
|
||||
#endif
|
||||
|
||||
|
@ -33,15 +32,16 @@ const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233);
|
|||
#if defined(USE_X11)
|
||||
void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight,
|
||||
SkColor* hover, SkColor* background) {
|
||||
libgtk2ui::OwnedWidgetGtk fake_menu_bar;
|
||||
fake_menu_bar.Own(gtk_menu_bar_new());
|
||||
GtkWidget* menu_bar = 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]);
|
||||
*disabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_INSENSITIVE]);
|
||||
*highlight = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_SELECTED]);
|
||||
*hover = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_PRELIGHT]);
|
||||
*background = libgtk2ui::GdkColorToSkColor(style->bg[GTK_STATE_NORMAL]);
|
||||
|
||||
gtk_widget_destroy(menu_bar);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "base/synchronization/lock.h"
|
||||
#include "chrome/browser/speech/tts_platform.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
|
||||
#include "library_loaders/libspeechd.h"
|
||||
|
||||
|
@ -32,18 +33,17 @@ struct SPDChromeVoice {
|
|||
|
||||
class TtsPlatformImplLinux : public TtsPlatformImpl {
|
||||
public:
|
||||
virtual bool PlatformImplAvailable() override;
|
||||
virtual bool Speak(
|
||||
int utterance_id,
|
||||
const std::string& utterance,
|
||||
const std::string& lang,
|
||||
const VoiceData& voice,
|
||||
const UtteranceContinuousParameters& params) override;
|
||||
virtual bool StopSpeaking() override;
|
||||
virtual void Pause() override;
|
||||
virtual void Resume() override;
|
||||
virtual bool IsSpeaking() override;
|
||||
virtual void GetVoices(std::vector<VoiceData>* out_voices) override;
|
||||
bool PlatformImplAvailable() override;
|
||||
bool Speak(int utterance_id,
|
||||
const std::string& utterance,
|
||||
const std::string& lang,
|
||||
const VoiceData& voice,
|
||||
const UtteranceContinuousParameters& params) override;
|
||||
bool StopSpeaking() override;
|
||||
void Pause() override;
|
||||
void Resume() override;
|
||||
bool IsSpeaking() override;
|
||||
void GetVoices(std::vector<VoiceData>* out_voices) override;
|
||||
|
||||
void OnSpeechEvent(SPDNotificationType type);
|
||||
|
||||
|
@ -52,7 +52,7 @@ class TtsPlatformImplLinux : public TtsPlatformImpl {
|
|||
|
||||
private:
|
||||
TtsPlatformImplLinux();
|
||||
virtual ~TtsPlatformImplLinux();
|
||||
~TtsPlatformImplLinux() override;
|
||||
|
||||
// Initiate the connection with the speech dispatcher.
|
||||
void Initialize();
|
||||
|
@ -83,7 +83,7 @@ class TtsPlatformImplLinux : public TtsPlatformImpl {
|
|||
// uniquely identify a voice across all available modules.
|
||||
scoped_ptr<std::map<std::string, SPDChromeVoice> > all_native_voices_;
|
||||
|
||||
friend struct DefaultSingletonTraits<TtsPlatformImplLinux>;
|
||||
friend struct base::DefaultSingletonTraits<TtsPlatformImplLinux>;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplLinux);
|
||||
};
|
||||
|
@ -94,6 +94,11 @@ SPDNotificationType TtsPlatformImplLinux::current_notification_ =
|
|||
|
||||
TtsPlatformImplLinux::TtsPlatformImplLinux()
|
||||
: utterance_id_(0) {
|
||||
const base::CommandLine& command_line =
|
||||
*base::CommandLine::ForCurrentProcess();
|
||||
if (!command_line.HasSwitch(switches::kEnableSpeechDispatcher))
|
||||
return;
|
||||
|
||||
BrowserThread::PostTask(BrowserThread::FILE,
|
||||
FROM_HERE,
|
||||
base::Bind(&TtsPlatformImplLinux::Initialize,
|
||||
|
@ -111,7 +116,7 @@ void TtsPlatformImplLinux::Initialize() {
|
|||
// http://crbug.com/317360
|
||||
ANNOTATE_SCOPED_MEMORY_LEAK;
|
||||
conn_ = libspeechd_loader_.spd_open(
|
||||
"chrome", "extension_api", NULL, SPD_MODE_SINGLE);
|
||||
"chrome", "extension_api", NULL, SPD_MODE_THREADED);
|
||||
}
|
||||
if (!conn_)
|
||||
return;
|
||||
|
@ -146,7 +151,7 @@ void TtsPlatformImplLinux::Reset() {
|
|||
if (conn_)
|
||||
libspeechd_loader_.spd_close(conn_);
|
||||
conn_ = libspeechd_loader_.spd_open(
|
||||
"chrome", "extension_api", NULL, SPD_MODE_SINGLE);
|
||||
"chrome", "extension_api", NULL, SPD_MODE_THREADED);
|
||||
}
|
||||
|
||||
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_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_id_ = utterance_id;
|
||||
|
||||
|
@ -337,8 +346,9 @@ void TtsPlatformImplLinux::IndexMarkCallback(size_t msg_id,
|
|||
|
||||
// static
|
||||
TtsPlatformImplLinux* TtsPlatformImplLinux::GetInstance() {
|
||||
return Singleton<TtsPlatformImplLinux,
|
||||
LeakySingletonTraits<TtsPlatformImplLinux> >::get();
|
||||
return base::Singleton<
|
||||
TtsPlatformImplLinux,
|
||||
base::LeakySingletonTraits<TtsPlatformImplLinux>>::get();
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -21,7 +21,7 @@ const char kAppMenuRegistrarPath[] = "/com/canonical/AppMenu/Registrar";
|
|||
|
||||
// static
|
||||
GlobalMenuBarRegistrarX11* GlobalMenuBarRegistrarX11::GetInstance() {
|
||||
return Singleton<GlobalMenuBarRegistrarX11>::get();
|
||||
return base::Singleton<GlobalMenuBarRegistrarX11>::get();
|
||||
}
|
||||
|
||||
void GlobalMenuBarRegistrarX11::OnWindowMapped(unsigned long xid) {
|
||||
|
@ -39,7 +39,7 @@ void GlobalMenuBarRegistrarX11::OnWindowUnmapped(unsigned long xid) {
|
|||
}
|
||||
|
||||
GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11()
|
||||
: registrar_proxy_(NULL) {
|
||||
: registrar_proxy_(nullptr) {
|
||||
// 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,
|
||||
// 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_CONNECT_SIGNALS |
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START),
|
||||
NULL,
|
||||
nullptr,
|
||||
kAppMenuRegistrarName,
|
||||
kAppMenuRegistrarPath,
|
||||
kAppMenuRegistrarName,
|
||||
NULL, // TODO: Probalby want a real cancelable.
|
||||
nullptr, // TODO: Probalby want a real cancelable.
|
||||
static_cast<GAsyncReadyCallback>(OnProxyCreatedThunk),
|
||||
this);
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ void GlobalMenuBarRegistrarX11::RegisterXID(unsigned long xid) {
|
|||
"RegisterWindow",
|
||||
g_variant_new("(uo)", xid, path.c_str()),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) {
|
||||
|
@ -105,14 +105,14 @@ void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) {
|
|||
"UnregisterWindow",
|
||||
g_variant_new("(u)", xid),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void GlobalMenuBarRegistrarX11::OnProxyCreated(GObject* source,
|
||||
GAsyncResult* result) {
|
||||
GError* error = NULL;
|
||||
GError* error = nullptr;
|
||||
GDBusProxy* proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
|
||||
if (error) {
|
||||
g_error_free(error);
|
||||
|
@ -128,7 +128,7 @@ void GlobalMenuBarRegistrarX11::OnProxyCreated(GObject* source,
|
|||
g_signal_connect(registrar_proxy_, "notify::g-name-owner",
|
||||
G_CALLBACK(OnNameOwnerChangedThunk), this);
|
||||
|
||||
OnNameOwnerChanged(NULL, NULL);
|
||||
OnNameOwnerChanged(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void GlobalMenuBarRegistrarX11::OnNameOwnerChanged(GObject* /* ignored */,
|
||||
|
|
|
@ -28,7 +28,7 @@ class GlobalMenuBarRegistrarX11 {
|
|||
void OnWindowUnmapped(unsigned long xid);
|
||||
|
||||
private:
|
||||
friend struct DefaultSingletonTraits<GlobalMenuBarRegistrarX11>;
|
||||
friend struct base::DefaultSingletonTraits<GlobalMenuBarRegistrarX11>;
|
||||
|
||||
GlobalMenuBarRegistrarX11();
|
||||
~GlobalMenuBarRegistrarX11();
|
||||
|
|
Loading…
Reference in a new issue