Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3164)

Unified Diff: chrome/browser/ui/views/frame/browser_command_handler_x11.cc

Issue 183853037: aura: Remove client::UserActionClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unrevert Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/browser_command_handler_x11.cc
diff --git a/chrome/browser/ui/views/frame/browser_command_handler_x11.cc b/chrome/browser/ui/views/frame/browser_command_handler_x11.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ce37fcc47799ad2138f4e943214cead8fd23c3ea
--- /dev/null
+++ b/chrome/browser/ui/views/frame/browser_command_handler_x11.cc
@@ -0,0 +1,46 @@
+// Copyright 2014 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/ui/views/frame/browser_command_handler_x11.h"
+
+#include <X11/Xlib.h>
+
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/events/event.h"
+#include "ui/events/event_utils.h"
+
+BrowserCommandHandlerX11::BrowserCommandHandlerX11(Browser* browser)
+ : browser_(browser) {}
+
+BrowserCommandHandlerX11::~BrowserCommandHandlerX11() {}
+
+void BrowserCommandHandlerX11::OnMouseEvent(ui::MouseEvent* event) {
+ if (event->type() != ui::ET_MOUSE_PRESSED)
+ return;
+ XEvent* xevent = event->native_event();
+ if (!xevent)
+ return;
+ int button = xevent->type == GenericEvent ? ui::EventButtonFromNative(xevent)
+ : xevent->xbutton.button;
+
+ // Standard Linux mouse buttons for going back and forward.
+ const int kBackMouseButton = 8;
+ const int kForwardMouseButton = 9;
+ if (button == kBackMouseButton || button == kForwardMouseButton) {
+ content::WebContents* contents =
+ browser_->tab_strip_model()->GetActiveWebContents();
+ if (!contents)
+ return;
+ content::NavigationController& controller = contents->GetController();
+ if (button == kBackMouseButton && controller.CanGoBack())
+ controller.GoBack();
+ else if (button == kForwardMouseButton && controller.CanGoForward())
+ controller.GoForward();
+ // Always consume the event, whether a navigation was successful or not.
+ event->SetHandled();
+ }
+}
« no previous file with comments | « chrome/browser/ui/views/frame/browser_command_handler_x11.h ('k') | chrome/browser/ui/views/frame/browser_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698