Chromium Code Reviews| 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..76eef5e3f426c307069403dc44488d0f62601250 100644 |
| --- a/chrome/browser/ui/views/frame/browser_view.cc |
| +++ b/chrome/browser/ui/views/frame/browser_view.cc |
| @@ -1938,6 +1938,31 @@ void BrowserView::Layout() { |
| IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER); |
| } |
| +void BrowserView::OnGestureEvent(ui::GestureEvent* event) { |
| +#if defined(OS_MACOSX) |
| + auto get_gesture_command = [](ui::GestureEvent* event, |
| + base::Optional<int>* command) { |
| + if (event->details().type() == ui::ET_GESTURE_SWIPE) { |
| + if (event->details().swipe_left()) |
| + *command = IDC_BACK; |
| + else if (event->details().swipe_right()) |
| + *command = IDC_FORWARD; |
| + } |
| + return command->has_value(); |
| + }; |
| + |
| + base::Optional<int> command; |
| + if (get_gesture_command(event, &command) && |
| + chrome::IsCommandEnabled(browser(), *command)) { |
| + chrome::ExecuteCommandWithDisposition( |
| + browser(), *command, ui::DispositionFromEventFlags(event->flags())); |
| + return; |
| + } |
| +#endif // OS_MACOSX |
| + |
| + ClientView::OnGestureEvent(event); |
| +} |
|
tapted
2017/02/20 23:14:21
I'm undecided about base::Optional and the lambda
|
| + |
| void BrowserView::ViewHierarchyChanged( |
| const ViewHierarchyChangedDetails& details) { |
| if (!initialized_ && details.is_add && details.child == this && GetWidget()) { |