Commit ac34b1b9 authored by sadrul@chromium.org's avatar sadrul@chromium.org

aura: Remove client::UserActionClient.

UserActionClient is used to navigate back/forward when the back/forward on a
supported mouse-device is clicked on X11. This can instead be achieved by
installing an event-handler on the browser window.

This does change the behaviour a little on ChromeOS: clicking these navigation
buttons when the cursor is not on top of the browser window will not navigate
after this change. I have confirmed with UX that this is a desirable change.

BUG=319636
R=sky@chromium.org

Review URL: https://codereview.chromium.org/183853037

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255385 0039d316-1c4b-4281-b951-d872f2087c98
parent ebc7df9a
...@@ -85,7 +85,6 @@ ...@@ -85,7 +85,6 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/user_action_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/layout_manager.h" #include "ui/aura/layout_manager.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
...@@ -724,7 +723,6 @@ Shell::~Shell() { ...@@ -724,7 +723,6 @@ Shell::~Shell() {
event_client_.reset(); event_client_.reset();
nested_dispatcher_controller_.reset(); nested_dispatcher_controller_.reset();
toplevel_window_event_handler_.reset(); toplevel_window_event_handler_.reset();
user_action_client_.reset();
visibility_controller_.reset(); visibility_controller_.reset();
// |shelf_item_delegate_manager_| observes |shelf_model_|. It must be // |shelf_item_delegate_manager_| observes |shelf_model_|. It must be
// destroyed before |shelf_model_| is destroyed. // destroyed before |shelf_model_| is destroyed.
...@@ -919,7 +917,6 @@ void Shell::Init() { ...@@ -919,7 +917,6 @@ void Shell::Init() {
// TODO(oshima): Move as many controllers before creating // TODO(oshima): Move as many controllers before creating
// RootWindowController as possible. // RootWindowController as possible.
visibility_controller_.reset(new AshVisibilityController); visibility_controller_.reset(new AshVisibilityController);
user_action_client_.reset(delegate_->CreateUserActionClient());
magnification_controller_.reset( magnification_controller_.reset(
MagnificationController::CreateInstance()); MagnificationController::CreateInstance());
...@@ -1071,8 +1068,6 @@ void Shell::InitRootWindow(aura::Window* root_window) { ...@@ -1071,8 +1068,6 @@ void Shell::InitRootWindow(aura::Window* root_window) {
aura::client::SetDispatcherClient(root_window, aura::client::SetDispatcherClient(root_window,
nested_dispatcher_controller_.get()); nested_dispatcher_controller_.get());
} }
if (user_action_client_)
aura::client::SetUserActionClient(root_window, user_action_client_.get());
} }
bool Shell::CanWindowReceiveEvents(aura::Window* window) { bool Shell::CanWindowReceiveEvents(aura::Window* window) {
......
...@@ -40,7 +40,6 @@ class Window; ...@@ -40,7 +40,6 @@ class Window;
namespace client { namespace client {
class ActivationClient; class ActivationClient;
class FocusClient; class FocusClient;
class UserActionClient;
} }
} }
namespace chromeos { namespace chromeos {
...@@ -666,7 +665,6 @@ class ASH_EXPORT Shell ...@@ -666,7 +665,6 @@ class ASH_EXPORT Shell
scoped_ptr<PartialMagnificationController> partial_magnification_controller_; scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
scoped_ptr<AutoclickController> autoclick_controller_; scoped_ptr<AutoclickController> autoclick_controller_;
scoped_ptr<aura::client::FocusClient> focus_client_; scoped_ptr<aura::client::FocusClient> focus_client_;
scoped_ptr<aura::client::UserActionClient> user_action_client_;
aura::client::ActivationClient* activation_client_; aura::client::ActivationClient* activation_client_;
scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_; scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
scoped_ptr<internal::ScreenPositionController> screen_position_controller_; scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
......
...@@ -155,10 +155,6 @@ ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() { ...@@ -155,10 +155,6 @@ ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() {
return new MediaDelegateImpl; return new MediaDelegateImpl;
} }
aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() {
return NULL;
}
ui::MenuModel* ShellDelegateImpl::CreateContextMenu( ui::MenuModel* ShellDelegateImpl::CreateContextMenu(
aura::Window* root, aura::Window* root,
ash::ShelfItemDelegate* item_delegate, ash::ShelfItemDelegate* item_delegate,
......
...@@ -53,7 +53,6 @@ class ShellDelegateImpl : public ash::ShellDelegate { ...@@ -53,7 +53,6 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE;
virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE;
virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE;
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;
virtual ui::MenuModel* CreateContextMenu( virtual ui::MenuModel* CreateContextMenu(
aura::Window* root_window, aura::Window* root_window,
ash::ShelfItemDelegate* item_delegate, ash::ShelfItemDelegate* item_delegate,
......
...@@ -19,9 +19,6 @@ class AppListViewDelegate; ...@@ -19,9 +19,6 @@ class AppListViewDelegate;
namespace aura { namespace aura {
class RootWindow; class RootWindow;
class Window; class Window;
namespace client {
class UserActionClient;
}
} }
namespace content { namespace content {
...@@ -123,9 +120,6 @@ class ASH_EXPORT ShellDelegate { ...@@ -123,9 +120,6 @@ class ASH_EXPORT ShellDelegate {
// Creates a media delegate. Shell takes ownership of the delegate. // Creates a media delegate. Shell takes ownership of the delegate.
virtual MediaDelegate* CreateMediaDelegate() = 0; virtual MediaDelegate* CreateMediaDelegate() = 0;
// Creates a user action client. Shell takes ownership of the object.
virtual aura::client::UserActionClient* CreateUserActionClient() = 0;
// Creates a menu model of the context for the |root_window|. // Creates a menu model of the context for the |root_window|.
// When a ContextMenu is used for an item created by ShelfWindowWatcher, // When a ContextMenu is used for an item created by ShelfWindowWatcher,
// passes its ShelfItemDelegate and ShelfItem. // passes its ShelfItemDelegate and ShelfItem.
......
...@@ -136,10 +136,6 @@ MediaDelegate* TestShellDelegate::CreateMediaDelegate() { ...@@ -136,10 +136,6 @@ MediaDelegate* TestShellDelegate::CreateMediaDelegate() {
return new MediaDelegateImpl; return new MediaDelegateImpl;
} }
aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() {
return NULL;
}
ui::MenuModel* TestShellDelegate::CreateContextMenu( ui::MenuModel* TestShellDelegate::CreateContextMenu(
aura::Window* root, aura::Window* root,
ash::ShelfItemDelegate* item_delegate, ash::ShelfItemDelegate* item_delegate,
......
...@@ -49,7 +49,6 @@ class TestShellDelegate : public ShellDelegate { ...@@ -49,7 +49,6 @@ class TestShellDelegate : public ShellDelegate {
virtual AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE;
virtual NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE;
virtual MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual MediaDelegate* CreateMediaDelegate() OVERRIDE;
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;
virtual ui::MenuModel* CreateContextMenu( virtual ui::MenuModel* CreateContextMenu(
aura::Window* root, aura::Window* root,
ash::ShelfItemDelegate* item_delegate, ash::ShelfItemDelegate* item_delegate,
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h" #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
#include "chrome/browser/ui/ash/user_action_handler.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "grit/chromium_strings.h" #include "grit/chromium_strings.h"
...@@ -125,10 +124,6 @@ ash::ShelfDelegate* ChromeShellDelegate::CreateShelfDelegate( ...@@ -125,10 +124,6 @@ ash::ShelfDelegate* ChromeShellDelegate::CreateShelfDelegate(
return shelf_delegate_; return shelf_delegate_;
} }
aura::client::UserActionClient* ChromeShellDelegate::CreateUserActionClient() {
return new UserActionHandler;
}
ui::MenuModel* ChromeShellDelegate::CreateContextMenu( ui::MenuModel* ChromeShellDelegate::CreateContextMenu(
aura::Window* root, aura::Window* root,
ash::ShelfItemDelegate* item_delegate, ash::ShelfItemDelegate* item_delegate,
......
...@@ -66,7 +66,6 @@ class ChromeShellDelegate : public ash::ShellDelegate, ...@@ -66,7 +66,6 @@ class ChromeShellDelegate : public ash::ShellDelegate,
virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE;
virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE;
virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE;
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;
virtual ui::MenuModel* CreateContextMenu( virtual ui::MenuModel* CreateContextMenu(
aura::Window* root, aura::Window* root,
ash::ShelfItemDelegate* item_delegate, ash::ShelfItemDelegate* item_delegate,
......
// Copyright (c) 2012 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/ash/user_action_handler.h"
#include "ash/wm/window_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/web_contents.h"
// Returns the currently-active WebContents belonging to the active browser, or
// NULL if there's no currently-active browser.
content::WebContents* GetActiveWebContents() {
Browser* browser = chrome::FindLastActiveWithHostDesktopType(
chrome::HOST_DESKTOP_TYPE_ASH);
if (!browser)
return NULL;
if (!ash::wm::IsActiveWindow(browser->window()->GetNativeWindow()))
return NULL;
return browser->tab_strip_model()->GetActiveWebContents();
}
UserActionHandler::UserActionHandler() {}
UserActionHandler::~UserActionHandler() {}
bool UserActionHandler::OnUserAction(
aura::client::UserActionClient::Command command) {
switch (command) {
case aura::client::UserActionClient::BACK: {
content::WebContents* contents = GetActiveWebContents();
if (contents && contents->GetController().CanGoBack()) {
contents->GetController().GoBack();
return true;
}
break;
}
case aura::client::UserActionClient::FORWARD: {
content::WebContents* contents = GetActiveWebContents();
if (contents && contents->GetController().CanGoForward()) {
contents->GetController().GoForward();
return true;
}
break;
}
default:
break;
}
return false;
}
// Copyright (c) 2012 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_UI_ASH_USER_ACTION_HANDLER_H_
#define CHROME_BROWSER_UI_ASH_USER_ACTION_HANDLER_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/aura/client/user_action_client.h"
class UserActionHandler : public aura::client::UserActionClient {
public:
UserActionHandler();
virtual ~UserActionHandler();
// aura::client::UserActionClient overrides:
virtual bool OnUserAction(
aura::client::UserActionClient::Command command) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(UserActionHandler);
};
#endif // CHROME_BROWSER_UI_ASH_USER_ACTION_HANDLER_H_
// 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();
}
}
// 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.
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_COMMAND_HANDLER_X11_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_COMMAND_HANDLER_X11_H_
#include "ui/events/event_handler.h"
class Browser;
class BrowserCommandHandlerX11 : public ui::EventHandler {
public:
explicit BrowserCommandHandlerX11(Browser* browser);
virtual ~BrowserCommandHandlerX11();
private:
// ui::EventHandler:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
Browser* browser_;
DISALLOW_COPY_AND_ASSIGN(BrowserCommandHandlerX11);
};
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_COMMAND_HANDLER_X11_H_
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/base/hit_test.h" #include "ui/base/hit_test.h"
#include "ui/base/theme_provider.h" #include "ui/base/theme_provider.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/font_list.h" #include "ui/gfx/font_list.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "ui/views/controls/menu/menu_runner.h" #include "ui/views/controls/menu/menu_runner.h"
...@@ -46,6 +47,10 @@ ...@@ -46,6 +47,10 @@
#include "ash/session_state_delegate.h" #include "ash/session_state_delegate.h"
#endif #endif
#if defined(USE_X11)
#include "chrome/browser/ui/views/frame/browser_command_handler_x11.h"
#endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// BrowserFrame, public: // BrowserFrame, public:
...@@ -60,9 +65,16 @@ BrowserFrame::BrowserFrame(BrowserView* browser_view) ...@@ -60,9 +65,16 @@ BrowserFrame::BrowserFrame(BrowserView* browser_view)
set_is_secondary_widget(false); set_is_secondary_widget(false);
// Don't focus anything on creation, selecting a tab will set the focus. // Don't focus anything on creation, selecting a tab will set the focus.
set_focus_on_creation(false); set_focus_on_creation(false);
#if defined(USE_X11)
browser_command_handler_.reset(
new BrowserCommandHandlerX11(browser_view_->browser()));
#endif
} }
BrowserFrame::~BrowserFrame() { BrowserFrame::~BrowserFrame() {
if (browser_command_handler_ && GetNativeView())
GetNativeView()->RemovePreTargetHandler(browser_command_handler_.get());
} }
// static // static
...@@ -139,6 +151,9 @@ void BrowserFrame::InitBrowserFrame() { ...@@ -139,6 +151,9 @@ void BrowserFrame::InitBrowserFrame() {
DCHECK(non_client_view()); DCHECK(non_client_view());
non_client_view()->set_context_menu_controller(this); non_client_view()->set_context_menu_controller(this);
} }
if (browser_command_handler_)
GetNativeWindow()->AddPreTargetHandler(browser_command_handler_.get());
} }
void BrowserFrame::SetThemeProvider(scoped_ptr<ui::ThemeProvider> provider) { void BrowserFrame::SetThemeProvider(scoped_ptr<ui::ThemeProvider> provider) {
......
...@@ -27,6 +27,7 @@ class Rect; ...@@ -27,6 +27,7 @@ class Rect;
} }
namespace ui { namespace ui {
class EventHandler;
class MenuModel; class MenuModel;
class ThemeProvider; class ThemeProvider;
} }
...@@ -138,6 +139,8 @@ class BrowserFrame ...@@ -138,6 +139,8 @@ class BrowserFrame
// Whether the custom Chrome frame preference is set. // Whether the custom Chrome frame preference is set.
BooleanPrefMember use_custom_frame_pref_; BooleanPrefMember use_custom_frame_pref_;
scoped_ptr<ui::EventHandler> browser_command_handler_;
DISALLOW_COPY_AND_ASSIGN(BrowserFrame); DISALLOW_COPY_AND_ASSIGN(BrowserFrame);
}; };
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host.h" #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host.h"
#include "chrome/browser/ui/views/frame/browser_shutdown.h" #include "chrome/browser/ui/views/frame/browser_shutdown.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/desktop_user_action_handler_aura.h"
#include "grit/chromium_strings.h" #include "grit/chromium_strings.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
...@@ -68,11 +67,6 @@ void DesktopBrowserFrameAura::InitNativeWidget( ...@@ -68,11 +67,6 @@ void DesktopBrowserFrameAura::InitNativeWidget(
browser_desktop_window_tree_host_->AsDesktopWindowTreeHost(); browser_desktop_window_tree_host_->AsDesktopWindowTreeHost();
DesktopNativeWidgetAura::InitNativeWidget(modified_params); DesktopNativeWidgetAura::InitNativeWidget(modified_params);
user_action_client_.reset(
new DesktopUserActionHandlerAura(browser_view_->browser()));
aura::client::SetUserActionClient(GetNativeView()->GetRootWindow(),
user_action_client_.get());
visibility_controller_.reset(new views::corewm::VisibilityController); visibility_controller_.reset(new views::corewm::VisibilityController);
aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(),
visibility_controller_.get()); visibility_controller_.get());
......
...@@ -15,12 +15,6 @@ class BrowserDesktopWindowTreeHost; ...@@ -15,12 +15,6 @@ class BrowserDesktopWindowTreeHost;
class BrowserFrame; class BrowserFrame;
class BrowserView; class BrowserView;
namespace aura {
namespace client {
class UserActionClient;
}
}
namespace views { namespace views {
namespace corewm { namespace corewm {
class VisibilityController; class VisibilityController;
...@@ -63,7 +57,6 @@ class DesktopBrowserFrameAura : public views::DesktopNativeWidgetAura, ...@@ -63,7 +57,6 @@ class DesktopBrowserFrameAura : public views::DesktopNativeWidgetAura,
// Owned by the RootWindow. // Owned by the RootWindow.
BrowserDesktopWindowTreeHost* browser_desktop_window_tree_host_; BrowserDesktopWindowTreeHost* browser_desktop_window_tree_host_;
scoped_ptr<aura::client::UserActionClient> user_action_client_;
scoped_ptr<views::corewm::VisibilityController> visibility_controller_; scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
DISALLOW_COPY_AND_ASSIGN(DesktopBrowserFrameAura); DISALLOW_COPY_AND_ASSIGN(DesktopBrowserFrameAura);
......
// Copyright (c) 2013 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/desktop_user_action_handler_aura.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/web_contents.h"
DesktopUserActionHandlerAura::DesktopUserActionHandlerAura(Browser* browser)
: browser_(browser) {
}
DesktopUserActionHandlerAura::~DesktopUserActionHandlerAura() {}
bool DesktopUserActionHandlerAura::OnUserAction(
aura::client::UserActionClient::Command command) {
switch (command) {
case aura::client::UserActionClient::BACK: {
content::WebContents* contents = GetActiveWebContents();
if (contents && contents->GetController().CanGoBack()) {
contents->GetController().GoBack();
return true;
}
break;
}
case aura::client::UserActionClient::FORWARD: {
content::WebContents* contents = GetActiveWebContents();
if (contents && contents->GetController().CanGoForward()) {
contents->GetController().GoForward();
return true;
}
break;
}
default:
break;
}
return false;
}
content::WebContents*
DesktopUserActionHandlerAura::GetActiveWebContents() const {
return browser_->tab_strip_model()->GetActiveWebContents();
}
// Copyright (c) 2013 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_UI_VIEWS_FRAME_DESKTOP_USER_ACTION_HANDLER_AURA_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_DESKTOP_USER_ACTION_HANDLER_AURA_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/aura/client/user_action_client.h"
class Browser;
namespace content {
class WebContents;
}
// Handles back/forward commands on a per-browser basis.
class DesktopUserActionHandlerAura : public aura::client::UserActionClient {
public:
explicit DesktopUserActionHandlerAura(Browser* browser);
virtual ~DesktopUserActionHandlerAura();
// Overridden from aura::client::UserActionClient:
virtual bool OnUserAction(
aura::client::UserActionClient::Command command) OVERRIDE;
private:
// Returns the active web contents of |browser_|.
content::WebContents* GetActiveWebContents() const;
Browser* browser_;
DISALLOW_COPY_AND_ASSIGN(DesktopUserActionHandlerAura);
};
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_DESKTOP_USER_ACTION_HANDLER_AURA_H_
...@@ -359,8 +359,6 @@ ...@@ -359,8 +359,6 @@
'browser/ui/ash/system_tray_delegate_chromeos.h', 'browser/ui/ash/system_tray_delegate_chromeos.h',
'browser/ui/ash/system_tray_delegate_win.cc', 'browser/ui/ash/system_tray_delegate_win.cc',
'browser/ui/ash/system_tray_delegate_win.h', 'browser/ui/ash/system_tray_delegate_win.h',
'browser/ui/ash/user_action_handler.cc',
'browser/ui/ash/user_action_handler.h',
'browser/ui/ash/user_wallpaper_delegate_win.cc', 'browser/ui/ash/user_wallpaper_delegate_win.cc',
'browser/ui/ash/user_wallpaper_delegate_win.h', 'browser/ui/ash/user_wallpaper_delegate_win.h',
'browser/ui/ash/volume_controller_chromeos.cc', 'browser/ui/ash/volume_controller_chromeos.cc',
...@@ -1872,6 +1870,8 @@ ...@@ -1872,6 +1870,8 @@
'browser/ui/views/first_run_dialog.h', 'browser/ui/views/first_run_dialog.h',
'browser/ui/views/frame/app_panel_browser_frame_view.cc', 'browser/ui/views/frame/app_panel_browser_frame_view.cc',
'browser/ui/views/frame/app_panel_browser_frame_view.h', 'browser/ui/views/frame/app_panel_browser_frame_view.h',
'browser/ui/views/frame/browser_command_handler_x11.cc',
'browser/ui/views/frame/browser_command_handler_x11.h',
'browser/ui/views/frame/browser_frame.cc', 'browser/ui/views/frame/browser_frame.cc',
'browser/ui/views/frame/browser_frame.h', 'browser/ui/views/frame/browser_frame.h',
'browser/ui/views/frame/browser_frame_ash.cc', 'browser/ui/views/frame/browser_frame_ash.cc',
...@@ -1903,8 +1903,6 @@ ...@@ -1903,8 +1903,6 @@
'browser/ui/views/frame/contents_web_view.h', 'browser/ui/views/frame/contents_web_view.h',
'browser/ui/views/frame/desktop_browser_frame_aura.cc', 'browser/ui/views/frame/desktop_browser_frame_aura.cc',
'browser/ui/views/frame/desktop_browser_frame_aura.h', 'browser/ui/views/frame/desktop_browser_frame_aura.h',
'browser/ui/views/frame/desktop_user_action_handler_aura.cc',
'browser/ui/views/frame/desktop_user_action_handler_aura.h',
'browser/ui/views/frame/browser_desktop_window_tree_host.h', 'browser/ui/views/frame/browser_desktop_window_tree_host.h',
'browser/ui/views/frame/browser_desktop_window_tree_host_win.cc', 'browser/ui/views/frame/browser_desktop_window_tree_host_win.cc',
'browser/ui/views/frame/browser_desktop_window_tree_host_win.h', 'browser/ui/views/frame/browser_desktop_window_tree_host_win.h',
...@@ -2849,8 +2847,6 @@ ...@@ -2849,8 +2847,6 @@
'browser/ui/views/frame/browser_desktop_window_tree_host_x11.h', 'browser/ui/views/frame/browser_desktop_window_tree_host_x11.h',
'browser/ui/views/frame/desktop_browser_frame_aura.cc', 'browser/ui/views/frame/desktop_browser_frame_aura.cc',
'browser/ui/views/frame/desktop_browser_frame_aura.h', 'browser/ui/views/frame/desktop_browser_frame_aura.h',
'browser/ui/views/frame/desktop_user_action_handler_aura.cc',
'browser/ui/views/frame/desktop_user_action_handler_aura.h',
'browser/ui/views/frame/global_menu_bar_registrar_x11.cc', 'browser/ui/views/frame/global_menu_bar_registrar_x11.cc',
'browser/ui/views/frame/global_menu_bar_registrar_x11.h', 'browser/ui/views/frame/global_menu_bar_registrar_x11.h',
'browser/ui/views/frame/global_menu_bar_x11.cc', 'browser/ui/views/frame/global_menu_bar_x11.cc',
......
...@@ -68,8 +68,6 @@ ...@@ -68,8 +68,6 @@
'client/tooltip_client.h', 'client/tooltip_client.h',
'client/transient_window_client.cc', 'client/transient_window_client.cc',
'client/transient_window_client.h', 'client/transient_window_client.h',
'client/user_action_client.cc',
'client/user_action_client.h',
'client/visibility_client.cc', 'client/visibility_client.cc',
'client/visibility_client.h', 'client/visibility_client.h',
'client/window_move_client.cc', 'client/window_move_client.cc',
......
// Copyright (c) 2012 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 "ui/aura/client/user_action_client.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_property.h"
namespace aura {
namespace client {
DEFINE_WINDOW_PROPERTY_KEY(UserActionClient*,
kRootWindowUserActionClientKey,
NULL);
void SetUserActionClient(Window* root_window, UserActionClient* client) {
DCHECK_EQ(root_window->GetRootWindow(), root_window);
root_window->SetProperty(kRootWindowUserActionClientKey, client);
}
UserActionClient* GetUserActionClient(Window* root_window) {
if (root_window)
DCHECK_EQ(root_window->GetRootWindow(), root_window);
return root_window ?
root_window->GetProperty(kRootWindowUserActionClientKey) : NULL;
}
} // namespace client
} // namespace aura
// Copyright (c) 2012 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 UI_AURA_CLIENT_USER_ACTION_CLIENT_H_
#define UI_AURA_CLIENT_USER_ACTION_CLIENT_H_
#include "ui/aura/aura_export.h"
namespace aura {
class Window;
namespace client {
// An interface for handling a user action that isn't handled by the standard
// event path.
class AURA_EXPORT UserActionClient {
public:
enum Command {
BACK = 0,
FORWARD,
};
// Returns true if the command was handled and false otherwise.
virtual bool OnUserAction(Command command) = 0;
virtual ~UserActionClient() {}
};
// Sets/gets the client for handling user action on the specified root window.
AURA_EXPORT void SetUserActionClient(Window* root_window,
UserActionClient* client);
AURA_EXPORT UserActionClient* GetUserActionClient(Window* root_window);
} // namespace client
} // namespace aura
#endif // UI_AURA_CLIENT_USER_ACTION_CLIENT_H_
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "base/sys_info.h" #include "base/sys_info.h"
#include "ui/aura/client/cursor_client.h" #include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/screen_position_client.h"
#include "ui/aura/client/user_action_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/base/cursor/cursor.h" #include "ui/base/cursor/cursor.h"
...@@ -54,10 +53,6 @@ namespace aura { ...@@ -54,10 +53,6 @@ namespace aura {
namespace { namespace {
// Standard Linux mouse buttons for going back and forward.
const int kBackMouseButton = 8;
const int kForwardMouseButton = 9;
const char* kAtomsToCache[] = { const char* kAtomsToCache[] = {
"WM_DELETE_WINDOW", "WM_DELETE_WINDOW",
"_NET_WM_PING", "_NET_WM_PING",
...@@ -400,20 +395,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { ...@@ -400,20 +395,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
SendEventToProcessor(&keyup_event); SendEventToProcessor(&keyup_event);
break; break;
} }
case ButtonPress: { case ButtonPress:
if (static_cast<int>(xev->xbutton.button) == kBackMouseButton ||
static_cast<int>(xev->xbutton.button) == kForwardMouseButton) {
client::UserActionClient* gesture_client =
client::GetUserActionClient(window());
if (gesture_client) {
gesture_client->OnUserAction(
static_cast<int>(xev->xbutton.button) == kBackMouseButton ?
client::UserActionClient::BACK :
client::UserActionClient::FORWARD);
}
break;
}
} // fallthrough
case ButtonRelease: { case ButtonRelease: {
switch (ui::EventTypeFromNative(xev)) { switch (ui::EventTypeFromNative(xev)) {
case ui::ET_MOUSEWHEEL: { case ui::ET_MOUSEWHEEL: {
...@@ -861,27 +843,6 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { ...@@ -861,27 +843,6 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event);
if (num_coalesced > 0) if (num_coalesced > 0)
xev = &last_event; xev = &last_event;
} else if (type == ui::ET_MOUSE_PRESSED ||
type == ui::ET_MOUSE_RELEASED) {
XIDeviceEvent* xievent =
static_cast<XIDeviceEvent*>(xev->xcookie.data);
int button = xievent->detail;
if (button == kBackMouseButton || button == kForwardMouseButton) {
if (type == ui::ET_MOUSE_RELEASED)
break;
client::UserActionClient* gesture_client =
client::GetUserActionClient(window());
if (gesture_client) {
bool reverse_direction =
ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled();
gesture_client->OnUserAction(
(button == kBackMouseButton && !reverse_direction) ||
(button == kForwardMouseButton && reverse_direction) ?
client::UserActionClient::BACK :
client::UserActionClient::FORWARD);
}
break;
}
} }
ui::MouseEvent mouseev(xev); ui::MouseEvent mouseev(xev);
TranslateAndDispatchMouseEvent(&mouseev); TranslateAndDispatchMouseEvent(&mouseev);
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "third_party/skia/include/core/SkPath.h" #include "third_party/skia/include/core/SkPath.h"
#include "ui/aura/client/cursor_client.h" #include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/focus_client.h" #include "ui/aura/client/focus_client.h"
#include "ui/aura/client/user_action_client.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_property.h" #include "ui/aura/window_property.h"
...@@ -65,10 +64,6 @@ DEFINE_WINDOW_PROPERTY_KEY( ...@@ -65,10 +64,6 @@ DEFINE_WINDOW_PROPERTY_KEY(
namespace { namespace {
// Standard Linux mouse buttons for going back and forward.
const int kBackMouseButton = 8;
const int kForwardMouseButton = 9;
// Constants that are part of EWMH. // Constants that are part of EWMH.
const int k_NET_WM_STATE_ADD = 1; const int k_NET_WM_STATE_ADD = 1;
const int k_NET_WM_STATE_REMOVE = 0; const int k_NET_WM_STATE_REMOVE = 0;
...@@ -1301,20 +1296,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { ...@@ -1301,20 +1296,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
SendEventToProcessor(&keyup_event); SendEventToProcessor(&keyup_event);
break; break;
} }
case ButtonPress: { case ButtonPress:
if (static_cast<int>(xev->xbutton.button) == kBackMouseButton ||
static_cast<int>(xev->xbutton.button) == kForwardMouseButton) {
aura::client::UserActionClient* gesture_client =
aura::client::GetUserActionClient(dispatcher_->window());
if (gesture_client) {
gesture_client->OnUserAction(
static_cast<int>(xev->xbutton.button) == kBackMouseButton ?
aura::client::UserActionClient::BACK :
aura::client::UserActionClient::FORWARD);
}
break;
}
} // fallthrough
case ButtonRelease: { case ButtonRelease: {
ui::EventType event_type = ui::EventTypeFromNative(xev); ui::EventType event_type = ui::EventTypeFromNative(xev);
switch (event_type) { switch (event_type) {
...@@ -1407,33 +1389,6 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { ...@@ -1407,33 +1389,6 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event);
if (num_coalesced > 0) if (num_coalesced > 0)
xev = &last_event; xev = &last_event;
} else if (type == ui::ET_MOUSE_PRESSED) {
XIDeviceEvent* xievent =
static_cast<XIDeviceEvent*>(xev->xcookie.data);
int button = xievent->detail;
if (button == kBackMouseButton || button == kForwardMouseButton) {
aura::client::UserActionClient* gesture_client =
aura::client::GetUserActionClient(window());
if (gesture_client) {
bool reverse_direction =
ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled();
gesture_client->OnUserAction(
(button == kBackMouseButton && !reverse_direction) ||
(button == kForwardMouseButton && reverse_direction) ?
aura::client::UserActionClient::BACK :
aura::client::UserActionClient::FORWARD);
}
break;
}
} else if (type == ui::ET_MOUSE_RELEASED) {
XIDeviceEvent* xievent =
static_cast<XIDeviceEvent*>(xev->xcookie.data);
int button = xievent->detail;
if (button == kBackMouseButton || button == kForwardMouseButton) {
// We've already passed the back/forward mouse down to the user
// action client; we want to swallow the corresponding release.
break;
}
} }
ui::MouseEvent mouseev(xev); ui::MouseEvent mouseev(xev);
DispatchMouseEvent(&mouseev); DispatchMouseEvent(&mouseev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment