diff options
25 files changed, 94 insertions, 364 deletions
diff --git a/ash/shell.cc b/ash/shell.cc index 2b6a8c9..4f0b8cb 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -85,7 +85,6 @@ #include "base/command_line.h" #include "base/debug/trace_event.h" #include "ui/aura/client/aura_constants.h" -#include "ui/aura/client/user_action_client.h" #include "ui/aura/env.h" #include "ui/aura/layout_manager.h" #include "ui/aura/window.h" @@ -724,7 +723,6 @@ Shell::~Shell() { event_client_.reset(); nested_dispatcher_controller_.reset(); toplevel_window_event_handler_.reset(); - user_action_client_.reset(); visibility_controller_.reset(); // |shelf_item_delegate_manager_| observes |shelf_model_|. It must be // destroyed before |shelf_model_| is destroyed. @@ -919,7 +917,6 @@ void Shell::Init() { // TODO(oshima): Move as many controllers before creating // RootWindowController as possible. visibility_controller_.reset(new AshVisibilityController); - user_action_client_.reset(delegate_->CreateUserActionClient()); magnification_controller_.reset( MagnificationController::CreateInstance()); @@ -1071,8 +1068,6 @@ void Shell::InitRootWindow(aura::Window* root_window) { aura::client::SetDispatcherClient(root_window, nested_dispatcher_controller_.get()); } - if (user_action_client_) - aura::client::SetUserActionClient(root_window, user_action_client_.get()); } bool Shell::CanWindowReceiveEvents(aura::Window* window) { diff --git a/ash/shell.h b/ash/shell.h index bc318f0..6bb3be0 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -40,7 +40,6 @@ class Window; namespace client { class ActivationClient; class FocusClient; -class UserActionClient; } } namespace chromeos { @@ -666,7 +665,6 @@ class ASH_EXPORT Shell scoped_ptr<PartialMagnificationController> partial_magnification_controller_; scoped_ptr<AutoclickController> autoclick_controller_; scoped_ptr<aura::client::FocusClient> focus_client_; - scoped_ptr<aura::client::UserActionClient> user_action_client_; aura::client::ActivationClient* activation_client_; scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_; scoped_ptr<internal::ScreenPositionController> screen_position_controller_; diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index 3abcdab..a715efa 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -155,10 +155,6 @@ ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() { return new MediaDelegateImpl; } -aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() { - return NULL; -} - ui::MenuModel* ShellDelegateImpl::CreateContextMenu( aura::Window* root, ash::ShelfItemDelegate* item_delegate, diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index 6edcbf0..2a095dd 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h @@ -53,7 +53,6 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE; - virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual ui::MenuModel* CreateContextMenu( aura::Window* root_window, ash::ShelfItemDelegate* item_delegate, diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index 7bb4ebe..7f27d21 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -19,9 +19,6 @@ class AppListViewDelegate; namespace aura { class RootWindow; class Window; -namespace client { -class UserActionClient; -} } namespace content { @@ -123,9 +120,6 @@ class ASH_EXPORT ShellDelegate { // Creates a media delegate. Shell takes ownership of the delegate. 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|. // When a ContextMenu is used for an item created by ShelfWindowWatcher, // passes its ShelfItemDelegate and ShelfItem. diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index 70e2117..72927cc 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -136,10 +136,6 @@ MediaDelegate* TestShellDelegate::CreateMediaDelegate() { return new MediaDelegateImpl; } -aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { - return NULL; -} - ui::MenuModel* TestShellDelegate::CreateContextMenu( aura::Window* root, ash::ShelfItemDelegate* item_delegate, diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index fa23b48..6090eca 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -49,7 +49,6 @@ class TestShellDelegate : public ShellDelegate { virtual AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual MediaDelegate* CreateMediaDelegate() OVERRIDE; - virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual ui::MenuModel* CreateContextMenu( aura::Window* root, ash::ShelfItemDelegate* item_delegate, diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc index 5fe0574..bffe745 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc @@ -21,7 +21,6 @@ #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/launcher_context_menu.h" -#include "chrome/browser/ui/ash/user_action_handler.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/common/chrome_switches.h" #include "grit/chromium_strings.h" @@ -125,10 +124,6 @@ ash::ShelfDelegate* ChromeShellDelegate::CreateShelfDelegate( return shelf_delegate_; } -aura::client::UserActionClient* ChromeShellDelegate::CreateUserActionClient() { - return new UserActionHandler; -} - ui::MenuModel* ChromeShellDelegate::CreateContextMenu( aura::Window* root, ash::ShelfItemDelegate* item_delegate, diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h index c009dd7..1e8bd56 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.h +++ b/chrome/browser/ui/ash/chrome_shell_delegate.h @@ -66,7 +66,6 @@ class ChromeShellDelegate : public ash::ShellDelegate, virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE; - virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual ui::MenuModel* CreateContextMenu( aura::Window* root, ash::ShelfItemDelegate* item_delegate, diff --git a/chrome/browser/ui/ash/user_action_handler.cc b/chrome/browser/ui/ash/user_action_handler.cc deleted file mode 100644 index c7e61cf..0000000 --- a/chrome/browser/ui/ash/user_action_handler.cc +++ /dev/null @@ -1,54 +0,0 @@ -// 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; -} diff --git a/chrome/browser/ui/ash/user_action_handler.h b/chrome/browser/ui/ash/user_action_handler.h deleted file mode 100644 index ac3f7f0..0000000 --- a/chrome/browser/ui/ash/user_action_handler.h +++ /dev/null @@ -1,25 +0,0 @@ -// 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_ 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 0000000..ce37fcc --- /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(); + } +} diff --git a/chrome/browser/ui/views/frame/browser_command_handler_x11.h b/chrome/browser/ui/views/frame/browser_command_handler_x11.h new file mode 100644 index 0000000..785c16d --- /dev/null +++ b/chrome/browser/ui/views/frame/browser_command_handler_x11.h @@ -0,0 +1,26 @@ +// 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_ diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc index 91f58f0..a3143f0 100644 --- a/chrome/browser/ui/views/frame/browser_frame.cc +++ b/chrome/browser/ui/views/frame/browser_frame.cc @@ -29,6 +29,7 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/base/hit_test.h" #include "ui/base/theme_provider.h" +#include "ui/events/event_handler.h" #include "ui/gfx/font_list.h" #include "ui/gfx/screen.h" #include "ui/views/controls/menu/menu_runner.h" @@ -46,6 +47,10 @@ #include "ash/session_state_delegate.h" #endif +#if defined(USE_X11) +#include "chrome/browser/ui/views/frame/browser_command_handler_x11.h" +#endif + //////////////////////////////////////////////////////////////////////////////// // BrowserFrame, public: @@ -60,9 +65,16 @@ BrowserFrame::BrowserFrame(BrowserView* browser_view) set_is_secondary_widget(false); // Don't focus anything on creation, selecting a tab will set the focus. set_focus_on_creation(false); + +#if defined(USE_X11) + browser_command_handler_.reset( + new BrowserCommandHandlerX11(browser_view_->browser())); +#endif } BrowserFrame::~BrowserFrame() { + if (browser_command_handler_ && GetNativeView()) + GetNativeView()->RemovePreTargetHandler(browser_command_handler_.get()); } // static @@ -139,6 +151,9 @@ void BrowserFrame::InitBrowserFrame() { DCHECK(non_client_view()); 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) { diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h index fa379b2..87bdea0 100644 --- a/chrome/browser/ui/views/frame/browser_frame.h +++ b/chrome/browser/ui/views/frame/browser_frame.h @@ -27,6 +27,7 @@ class Rect; } namespace ui { +class EventHandler; class MenuModel; class ThemeProvider; } @@ -138,6 +139,8 @@ class BrowserFrame // Whether the custom Chrome frame preference is set. BooleanPrefMember use_custom_frame_pref_; + scoped_ptr<ui::EventHandler> browser_command_handler_; + DISALLOW_COPY_AND_ASSIGN(BrowserFrame); }; diff --git a/chrome/browser/ui/views/frame/desktop_browser_frame_aura.cc b/chrome/browser/ui/views/frame/desktop_browser_frame_aura.cc index e632526..2e87976 100644 --- a/chrome/browser/ui/views/frame/desktop_browser_frame_aura.cc +++ b/chrome/browser/ui/views/frame/desktop_browser_frame_aura.cc @@ -8,7 +8,6 @@ #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_view.h" -#include "chrome/browser/ui/views/frame/desktop_user_action_handler_aura.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/aura/client/aura_constants.h" @@ -68,11 +67,6 @@ void DesktopBrowserFrameAura::InitNativeWidget( browser_desktop_window_tree_host_->AsDesktopWindowTreeHost(); 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); aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), visibility_controller_.get()); diff --git a/chrome/browser/ui/views/frame/desktop_browser_frame_aura.h b/chrome/browser/ui/views/frame/desktop_browser_frame_aura.h index edaf381..ec782b9 100644 --- a/chrome/browser/ui/views/frame/desktop_browser_frame_aura.h +++ b/chrome/browser/ui/views/frame/desktop_browser_frame_aura.h @@ -15,12 +15,6 @@ class BrowserDesktopWindowTreeHost; class BrowserFrame; class BrowserView; -namespace aura { -namespace client { -class UserActionClient; -} -} - namespace views { namespace corewm { class VisibilityController; @@ -63,7 +57,6 @@ class DesktopBrowserFrameAura : public views::DesktopNativeWidgetAura, // Owned by the RootWindow. BrowserDesktopWindowTreeHost* browser_desktop_window_tree_host_; - scoped_ptr<aura::client::UserActionClient> user_action_client_; scoped_ptr<views::corewm::VisibilityController> visibility_controller_; DISALLOW_COPY_AND_ASSIGN(DesktopBrowserFrameAura); diff --git a/chrome/browser/ui/views/frame/desktop_user_action_handler_aura.cc b/chrome/browser/ui/views/frame/desktop_user_action_handler_aura.cc deleted file mode 100644 index c2f6e98..0000000 --- a/chrome/browser/ui/views/frame/desktop_user_action_handler_aura.cc +++ /dev/null @@ -1,45 +0,0 @@ -// 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(); -} diff --git a/chrome/browser/ui/views/frame/desktop_user_action_handler_aura.h b/chrome/browser/ui/views/frame/desktop_user_action_handler_aura.h deleted file mode 100644 index a3a61ee..0000000 --- a/chrome/browser/ui/views/frame/desktop_user_action_handler_aura.h +++ /dev/null @@ -1,37 +0,0 @@ -// 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_ diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 775ec97..767c2fb 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -359,8 +359,6 @@ 'browser/ui/ash/system_tray_delegate_chromeos.h', 'browser/ui/ash/system_tray_delegate_win.cc', '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.h', 'browser/ui/ash/volume_controller_chromeos.cc', @@ -1872,6 +1870,8 @@ '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.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.h', 'browser/ui/views/frame/browser_frame_ash.cc', @@ -1903,8 +1903,6 @@ '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.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_win.cc', 'browser/ui/views/frame/browser_desktop_window_tree_host_win.h', @@ -2849,8 +2847,6 @@ '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.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.h', 'browser/ui/views/frame/global_menu_bar_x11.cc', diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index 3453031..5a16608 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -68,8 +68,6 @@ 'client/tooltip_client.h', 'client/transient_window_client.cc', 'client/transient_window_client.h', - 'client/user_action_client.cc', - 'client/user_action_client.h', 'client/visibility_client.cc', 'client/visibility_client.h', 'client/window_move_client.cc', diff --git a/ui/aura/client/user_action_client.cc b/ui/aura/client/user_action_client.cc deleted file mode 100644 index b8bb487..0000000 --- a/ui/aura/client/user_action_client.cc +++ /dev/null @@ -1,30 +0,0 @@ -// 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 diff --git a/ui/aura/client/user_action_client.h b/ui/aura/client/user_action_client.h deleted file mode 100644 index 738a8d5..0000000 --- a/ui/aura/client/user_action_client.h +++ /dev/null @@ -1,37 +0,0 @@ -// 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_ diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc index 6286742..8915790 100644 --- a/ui/aura/window_tree_host_x11.cc +++ b/ui/aura/window_tree_host_x11.cc @@ -29,7 +29,6 @@ #include "base/sys_info.h" #include "ui/aura/client/cursor_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/window_event_dispatcher.h" #include "ui/base/cursor/cursor.h" @@ -54,10 +53,6 @@ namespace aura { namespace { -// Standard Linux mouse buttons for going back and forward. -const int kBackMouseButton = 8; -const int kForwardMouseButton = 9; - const char* kAtomsToCache[] = { "WM_DELETE_WINDOW", "_NET_WM_PING", @@ -400,20 +395,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { SendEventToProcessor(&keyup_event); break; } - 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 ButtonPress: case ButtonRelease: { switch (ui::EventTypeFromNative(xev)) { case ui::ET_MOUSEWHEEL: { @@ -861,27 +843,6 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); if (num_coalesced > 0) 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); TranslateAndDispatchMouseEvent(&mouseev); diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc index 979cfe9..8c7c3df 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc @@ -18,7 +18,6 @@ #include "third_party/skia/include/core/SkPath.h" #include "ui/aura/client/cursor_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_event_dispatcher.h" #include "ui/aura/window_property.h" @@ -65,10 +64,6 @@ DEFINE_WINDOW_PROPERTY_KEY( namespace { -// Standard Linux mouse buttons for going back and forward. -const int kBackMouseButton = 8; -const int kForwardMouseButton = 9; - // Constants that are part of EWMH. const int k_NET_WM_STATE_ADD = 1; const int k_NET_WM_STATE_REMOVE = 0; @@ -1301,20 +1296,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { SendEventToProcessor(&keyup_event); break; } - 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 ButtonPress: case ButtonRelease: { ui::EventType event_type = ui::EventTypeFromNative(xev); switch (event_type) { @@ -1407,33 +1389,6 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); if (num_coalesced > 0) 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); DispatchMouseEvent(&mouseev); |