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

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

Issue 2690573002: MacViews: Handle three-finger swipe gestures for navigation. (Closed)
Patch Set: Fix compilation on Windows. Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | ui/views/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/browser_view.cc
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index f4dbf87a9b3440d7ce19808cf32bf6b2c92f3fe7..81c6b98da8e53b9ef97b548a10bb8d694ddb6035 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -271,6 +271,20 @@ void PaintAttachedBookmarkBar(gfx::Canvas* canvas,
}
}
+bool GetGestureCommand(ui::GestureEvent* event, int* command) {
+ DCHECK(command);
+ *command = 0;
+#if defined(OS_MACOSX)
+ if (event->details().type() == ui::ET_GESTURE_SWIPE) {
+ if (event->details().swipe_left())
+ *command = IDC_BACK;
sky 2017/02/22 17:34:10 I would early return here and on 282, then 285 bec
themblsha 2017/02/27 11:49:16 Ok, I thought my code would make it easier to be r
+ else if (event->details().swipe_right())
+ *command = IDC_FORWARD;
+ }
+#endif // OS_MACOSX
+ return *command != 0;
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -1938,6 +1952,18 @@ void BrowserView::Layout() {
IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER);
}
+void BrowserView::OnGestureEvent(ui::GestureEvent* event) {
+ int command;
+ if (GetGestureCommand(event, &command) &&
+ chrome::IsCommandEnabled(browser(), command)) {
+ chrome::ExecuteCommandWithDisposition(
+ browser(), command, ui::DispositionFromEventFlags(event->flags()));
+ return;
+ }
+
+ ClientView::OnGestureEvent(event);
+}
+
void BrowserView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
if (!initialized_ && details.is_add && details.child == this && GetWidget()) {
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | ui/views/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698