summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_main_posix.cc4
-rw-r--r--chrome/browser/chromeos/browser_main_chromeos.cc53
-rw-r--r--chrome/browser/chromeos/browser_main_chromeos.h20
-rw-r--r--chrome/chrome_browser.gypi2
4 files changed, 77 insertions, 2 deletions
diff --git a/chrome/browser/browser_main_posix.cc b/chrome/browser/browser_main_posix.cc
index e6675f6..c2fc98c 100644
--- a/chrome/browser/browser_main_posix.cc
+++ b/chrome/browser/browser_main_posix.cc
@@ -219,8 +219,8 @@ void BrowserMainPartsPosix::PostMainMessageLoopStart() {
}
}
-// Mac further subclasses BrowserMainPartsPosix
-#if !defined(OS_MACOSX)
+// Mac and Chromeos further subclass BrowserMainPartsPosix.
+#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
// static
BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
const MainFunctionParams& parameters) {
diff --git a/chrome/browser/chromeos/browser_main_chromeos.cc b/chrome/browser/chromeos/browser_main_chromeos.cc
new file mode 100644
index 0000000..df4653a
--- /dev/null
+++ b/chrome/browser/chromeos/browser_main_chromeos.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/browser_main_chromeos.h"
+
+#include "base/message_loop.h"
+#include "base/singleton.h"
+
+#include <gtk/gtk.h>
+
+class MessageLoopObserver : public MessageLoopForUI::Observer {
+ virtual void WillProcessEvent(GdkEvent* event) {
+ // On chromeos we want to map Alt-left click to right click.
+ // This code only changes presses and releases. We could decide to also
+ // modify drags and crossings. It doesn't seem to be a problem right now
+ // with our support for context menus (the only real need we have).
+ // There are some inconsistent states both with what we have and what
+ // we would get if we added drags. You could get a right drag without a
+ // right down for example, unless we started synthesizing events, which
+ // seems like more trouble than it's worth.
+ if ((event->type == GDK_BUTTON_PRESS ||
+ event->type == GDK_2BUTTON_PRESS ||
+ event->type == GDK_3BUTTON_PRESS ||
+ event->type == GDK_BUTTON_RELEASE) &&
+ event->button.button == 1 &&
+ event->button.state & GDK_MOD1_MASK) {
+ // Change the button to the third (right) one.
+ event->button.button = 3;
+ // Remove the Alt key and first button state.
+ event->button.state &= ~(GDK_MOD1_MASK | GDK_BUTTON1_MASK);
+ // Add the third (right) button state.
+ event->button.state |= GDK_BUTTON3_MASK;
+ }
+ }
+
+ virtual void DidProcessEvent(GdkEvent* event) {
+ }
+};
+
+void BrowserMainPartsChromeos::PostMainMessageLoopStart() {
+ static Singleton<MessageLoopObserver> observer;
+
+ BrowserMainPartsPosix::PostMainMessageLoopStart();
+ MessageLoopForUI* message_loop = MessageLoopForUI::current();
+ message_loop->AddObserver(observer.get());
+}
+
+// static
+BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
+ const MainFunctionParams& parameters) {
+ return new BrowserMainPartsChromeos(parameters);
+}
diff --git a/chrome/browser/chromeos/browser_main_chromeos.h b/chrome/browser/chromeos/browser_main_chromeos.h
new file mode 100644
index 0000000..de8deb4
--- /dev/null
+++ b/chrome/browser/chromeos/browser_main_chromeos.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_BROWSER_MAIN_CHROMEOS_H_
+#define CHROME_BROWSER_CHROMEOS_BROWSER_MAIN_CHROMEOS_H_
+
+#include "chrome/browser/browser_main_posix.h"
+
+class BrowserMainPartsChromeos : public BrowserMainPartsPosix {
+ public:
+ explicit BrowserMainPartsChromeos(const MainFunctionParams& parameters)
+ : BrowserMainPartsPosix(parameters) {}
+
+ protected:
+ virtual void PostMainMessageLoopStart();
+ DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsChromeos);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_BROWSER_MAIN_CHROMEOS_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 9cd7534..a803bae 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -387,6 +387,8 @@
'browser/chromeos/audio_handler.h',
'browser/chromeos/boot_times_loader.cc',
'browser/chromeos/boot_times_loader.h',
+ 'browser/chromeos/browser_main_chromeos.cc',
+ 'browser/chromeos/browser_main_chromeos.h',
'browser/chromeos/cros_settings.cc',
'browser/chromeos/cros_settings.h',
'browser/chromeos/cros_settings_names.cc',