OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/views/frame/desktop_user_action_handler_aura.h" | |
6 | |
7 #include "chrome/browser/ui/browser.h" | |
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
9 #include "content/public/browser/web_contents.h" | |
10 | |
11 DesktopUserActionHandlerAura::DesktopUserActionHandlerAura(Browser* browser) | |
12 : browser_(browser) { | |
13 } | |
14 | |
15 DesktopUserActionHandlerAura::~DesktopUserActionHandlerAura() {} | |
16 | |
17 bool DesktopUserActionHandlerAura::OnUserAction( | |
18 aura::client::UserActionClient::Command command) { | |
19 switch (command) { | |
20 case aura::client::UserActionClient::BACK: { | |
21 content::WebContents* contents = GetActiveWebContents(); | |
22 if (contents && contents->GetController().CanGoBack()) { | |
23 contents->GetController().GoBack(); | |
24 return true; | |
25 } | |
26 break; | |
27 } | |
28 case aura::client::UserActionClient::FORWARD: { | |
29 content::WebContents* contents = GetActiveWebContents(); | |
30 if (contents && contents->GetController().CanGoForward()) { | |
31 contents->GetController().GoForward(); | |
32 return true; | |
33 } | |
34 break; | |
35 } | |
36 default: | |
37 break; | |
38 } | |
39 return false; | |
40 } | |
41 | |
42 content::WebContents* | |
43 DesktopUserActionHandlerAura::GetActiveWebContents() const { | |
44 return browser_->tab_strip_model()->GetActiveWebContents(); | |
45 } | |
OLD | NEW |