diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-25 01:49:17 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-25 01:49:17 +0000 |
commit | 47686c42b6a34d82c12f8f378be8d52d06875404 (patch) | |
tree | 68f3cb78f8afb9fae59e221b0ea38e6b16391f3d /ash | |
parent | 6e415ff81a1e29024ccfdd5548e7cd6ba4de450e (diff) | |
download | chromium_src-47686c42b6a34d82c12f8f378be8d52d06875404.zip chromium_src-47686c42b6a34d82c12f8f378be8d52d06875404.tar.gz chromium_src-47686c42b6a34d82c12f8f378be8d52d06875404.tar.bz2 |
Introduces NewWindowDelegate to create or show windows/tabs that are not part of ash.
BUG=none
TBR=phajdan.jr@chromium.org
Review URL: https://codereview.chromium.org/30533012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230901 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/accelerators/accelerator_controller.cc | 21 | ||||
-rw-r--r-- | ash/new_window_delegate.h | 44 | ||||
-rw-r--r-- | ash/shell.cc | 2 | ||||
-rw-r--r-- | ash/shell.h | 8 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.cc | 59 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.h | 9 | ||||
-rw-r--r-- | ash/shell_delegate.h | 28 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.cc | 43 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.h | 9 |
9 files changed, 121 insertions, 102 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index d7ab549..4cc30ed 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -25,6 +25,7 @@ #include "ash/magnifier/magnification_controller.h" #include "ash/magnifier/partial_magnification_controller.h" #include "ash/multi_profile_uma.h" +#include "ash/new_window_delegate.h" #include "ash/root_window_controller.h" #include "ash/rotator/screen_rotation.h" #include "ash/screenshot_delegate.h" @@ -173,12 +174,12 @@ bool HandleLock() { } bool HandleFileManager() { - Shell::GetInstance()->delegate()->OpenFileManager(); + Shell::GetInstance()->new_window_delegate()->OpenFileManager(); return true; } bool HandleCrosh() { - Shell::GetInstance()->delegate()->OpenCrosh(); + Shell::GetInstance()->new_window_delegate()->OpenCrosh(); return true; } @@ -616,25 +617,27 @@ bool AcceleratorController::PerformAction(int action, return true; #endif case OPEN_FEEDBACK_PAGE: - ash::Shell::GetInstance()->delegate()->OpenFeedbackPage(); + ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); return true; case EXIT: // UMA metrics are recorded in the handler. exit_warning_handler_.HandleAccelerator(); return true; case NEW_INCOGNITO_WINDOW: - Shell::GetInstance()->delegate()->NewWindow(true /* is_incognito */); + Shell::GetInstance()->new_window_delegate()->NewWindow( + true /* is_incognito */); return true; case NEW_TAB: if (key_code == ui::VKEY_T) shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEWTAB_T); - Shell::GetInstance()->delegate()->NewTab(); + Shell::GetInstance()->new_window_delegate()->NewTab(); return true; case NEW_WINDOW: - Shell::GetInstance()->delegate()->NewWindow(false /* is_incognito */); + Shell::GetInstance()->new_window_delegate()->NewWindow( + false /* is_incognito */); return true; case RESTORE_TAB: - Shell::GetInstance()->delegate()->RestoreTab(); + Shell::GetInstance()->new_window_delegate()->RestoreTab(); return true; case TAKE_SCREENSHOT: if (screenshot_delegate_.get() && @@ -731,7 +734,7 @@ bool AcceleratorController::PerformAction(int action, case FOCUS_PREVIOUS_PANE: return HandleRotatePaneFocus(Shell::BACKWARD); case SHOW_KEYBOARD_OVERLAY: - ash::Shell::GetInstance()->delegate()->ShowKeyboardOverlay(); + ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); return true; case SHOW_OAK: if (CommandLine::ForCurrentProcess()->HasSwitch( @@ -763,7 +766,7 @@ bool AcceleratorController::PerformAction(int action, break; } case SHOW_TASK_MANAGER: - Shell::GetInstance()->delegate()->ShowTaskManager(); + Shell::GetInstance()->new_window_delegate()->ShowTaskManager(); return true; case NEXT_IME: // This check is necessary e.g. not to process the Shift+Alt+ diff --git a/ash/new_window_delegate.h b/ash/new_window_delegate.h new file mode 100644 index 0000000..b4a592b --- /dev/null +++ b/ash/new_window_delegate.h @@ -0,0 +1,44 @@ +// Copyright 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 ASH_NEW_WINDOW_DELEGATE_H_ +#define ASH_NEW_WINDOW_DELEGATE_H_ + +namespace ash { + +// A delegate class to create or open windows that are not a part of +// ash. +class NewWindowDelegate { + public: + NewWindowDelegate() {} + virtual ~NewWindowDelegate() {} + + // Invoked when the user uses Ctrl+T to open a new tab. + virtual void NewTab() = 0; + + // Invoked when the user uses Ctrl-N or Ctrl-Shift-N to open a new window. + virtual void NewWindow(bool incognito) = 0; + + // Invoked when an accelerator is used to open the file manager. + virtual void OpenFileManager() = 0; + + // Invoked when the user opens Crosh. + virtual void OpenCrosh() = 0; + + // Invoked when the user uses Shift+Ctrl+T to restore the closed tab. + virtual void RestoreTab() = 0; + + // Shows the keyboard shortcut overlay. + virtual void ShowKeyboardOverlay() = 0; + + // Shows the task manager window. + virtual void ShowTaskManager() = 0; + + // Opens the feedback page for "Report Issue". + virtual void OpenFeedbackPage() = 0; +}; + +} // namespace ash + +#endif // ASH_NEW_WINDOW_DELEGATE_H_ diff --git a/ash/shell.cc b/ash/shell.cc index 50810a3..332e8c7 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -36,6 +36,7 @@ #include "ash/launcher/launcher_model_util.h" #include "ash/magnifier/magnification_controller.h" #include "ash/magnifier/partial_magnification_controller.h" +#include "ash/new_window_delegate.h" #include "ash/root_window_controller.h" #include "ash/screen_ash.h" #include "ash/session_state_delegate.h" @@ -833,6 +834,7 @@ void Shell::Init() { session_state_delegate_.reset(delegate_->CreateSessionStateDelegate()); accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); + new_window_delegate_.reset(delegate_->CreateNewWindowDelegate()); if (!command_line->HasSwitch(views::corewm::switches::kNoDropShadows)) { resize_shadow_controller_.reset(new internal::ResizeShadowController()); diff --git a/ash/shell.h b/ash/shell.h index 74903cb..eb20038 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -89,14 +89,15 @@ class LauncherDelegate; class LauncherItemDelegate; class LauncherItemDelegateManager; class LauncherModel; +class LockStateController; class MagnificationController; class MruWindowTracker; class NestedDispatcherController; +class NewWindowDelegate; class PartialMagnificationController; class PowerButtonController; class RootWindowHostFactory; class ScreenAsh; -class LockStateController; class SessionStateDelegate; class ShellDelegate; class ShellObserver; @@ -371,6 +372,10 @@ class ASH_EXPORT Shell return accessibility_delegate_.get(); } + NewWindowDelegate* new_window_delegate() { + return new_window_delegate_.get(); + } + HighContrastController* high_contrast_controller() { return high_contrast_controller_.get(); } @@ -579,6 +584,7 @@ class ASH_EXPORT Shell scoped_ptr<CapsLockDelegate> caps_lock_delegate_; scoped_ptr<SessionStateDelegate> session_state_delegate_; scoped_ptr<AccessibilityDelegate> accessibility_delegate_; + scoped_ptr<NewWindowDelegate> new_window_delegate_; scoped_ptr<LauncherDelegate> launcher_delegate_; scoped_ptr<LauncherItemDelegateManager> launcher_item_delegate_manager_; diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index 5f3eee6..6280f2b 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -10,6 +10,7 @@ #include "ash/default_user_wallpaper_delegate.h" #include "ash/host/root_window_host_factory.h" #include "ash/keyboard_controller_proxy_stub.h" +#include "ash/new_window_delegate.h" #include "ash/session_state_delegate.h" #include "ash/session_state_delegate_stub.h" #include "ash/shell/context_menu.h" @@ -25,6 +26,32 @@ namespace ash { namespace shell { +namespace { + +class NewWindowDelegateImpl : public NewWindowDelegate { + public: + NewWindowDelegateImpl() {} + virtual ~NewWindowDelegateImpl() {} + + virtual void NewTab() OVERRIDE {} + virtual void NewWindow(bool incognito) OVERRIDE { + ash::shell::ToplevelWindow::CreateParams create_params; + create_params.can_resize = true; + create_params.can_maximize = true; + ash::shell::ToplevelWindow::CreateToplevelWindow(create_params); + } + virtual void OpenFileManager() OVERRIDE {} + virtual void OpenCrosh() OVERRIDE {} + virtual void RestoreTab() OVERRIDE {} + virtual void ShowKeyboardOverlay() OVERRIDE {} + virtual void ShowTaskManager() OVERRIDE {} + virtual void OpenFeedbackPage() OVERRIDE {} + + private: + DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl); +}; + +} // namespace ShellDelegateImpl::ShellDelegateImpl() : watcher_(NULL), @@ -62,16 +89,6 @@ void ShellDelegateImpl::Exit() { base::MessageLoopForUI::current()->Quit(); } -void ShellDelegateImpl::NewTab() { -} - -void ShellDelegateImpl::NewWindow(bool incognito) { - ash::shell::ToplevelWindow::CreateParams create_params; - create_params.can_resize = true; - create_params.can_maximize = true; - ash::shell::ToplevelWindow::CreateToplevelWindow(create_params); -} - void ShellDelegateImpl::ToggleFullscreen() { // TODO(oshima): Remove this when crbug.com/309837 is implemented. wm::WindowState* window_state = wm::GetActiveWindowState(); @@ -79,26 +96,11 @@ void ShellDelegateImpl::ToggleFullscreen() { window_state->ToggleMaximized(); } -void ShellDelegateImpl::OpenFileManager() { -} - -void ShellDelegateImpl::OpenCrosh() { -} - -void ShellDelegateImpl::RestoreTab() { -} - -void ShellDelegateImpl::ShowKeyboardOverlay() { -} - keyboard::KeyboardControllerProxy* ShellDelegateImpl::CreateKeyboardControllerProxy() { return new KeyboardControllerProxyStub(); } -void ShellDelegateImpl::ShowTaskManager() { -} - content::BrowserContext* ShellDelegateImpl::GetCurrentBrowserContext() { return Shell::GetInstance()->browser_context(); } @@ -133,11 +135,12 @@ ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() { return new internal::DefaultAccessibilityDelegate; } -aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() { - return NULL; +ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() { + return new NewWindowDelegateImpl; } -void ShellDelegateImpl::OpenFeedbackPage() { +aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() { + return NULL; } void ShellDelegateImpl::RecordUserMetricsAction(UserMetricsAction action) { diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index 545e2e3..75c14e4 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h @@ -33,16 +33,9 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual void PreInit() OVERRIDE; virtual void Shutdown() OVERRIDE; virtual void Exit() OVERRIDE; - virtual void NewTab() OVERRIDE; - virtual void NewWindow(bool incognito) OVERRIDE; virtual void ToggleFullscreen() OVERRIDE; - virtual void OpenFileManager() OVERRIDE; - virtual void OpenCrosh() OVERRIDE; - virtual void RestoreTab() OVERRIDE; - virtual void ShowKeyboardOverlay() OVERRIDE; virtual keyboard::KeyboardControllerProxy* CreateKeyboardControllerProxy() OVERRIDE; - virtual void ShowTaskManager() OVERRIDE; virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE; virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; virtual ash::LauncherDelegate* CreateLauncherDelegate( @@ -52,8 +45,8 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual ash::CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE; virtual ash::SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; + virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; - virtual void OpenFeedbackPage() OVERRIDE; virtual void RecordUserMetricsAction(UserMetricsAction action) OVERRIDE; virtual void HandleMediaNextTrack() OVERRIDE; virtual void HandleMediaPlayPause() OVERRIDE; diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index 65b445d..42d936a 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -42,6 +42,7 @@ class CapsLockDelegate; class LauncherDelegate; class LauncherModel; struct LauncherItem; +class NewWindowDelegate; class RootWindowHostFactory; class AccessibilityDelegate; class SessionStateDelegate; @@ -128,34 +129,13 @@ class ASH_EXPORT ShellDelegate { // Invoked when the user uses Ctrl-Shift-Q to close chrome. virtual void Exit() = 0; - // Invoked when the user uses Ctrl+T to open a new tab. - virtual void NewTab() = 0; - - // Invoked when the user uses Ctrl-N or Ctrl-Shift-N to open a new window. - virtual void NewWindow(bool incognito) = 0; - // Invoked when the user uses Shift+F4 to toggle the window fullscreen state. virtual void ToggleFullscreen() = 0; - // Invoked when an accelerator is used to open the file manager. - virtual void OpenFileManager() = 0; - - // Invoked when the user opens Crosh. - virtual void OpenCrosh() = 0; - - // Invoked when the user uses Shift+Ctrl+T to restore the closed tab. - virtual void RestoreTab() = 0; - - // Shows the keyboard shortcut overlay. - virtual void ShowKeyboardOverlay() = 0; - // Create a shell-specific keyboard::KeyboardControllerProxy virtual keyboard::KeyboardControllerProxy* CreateKeyboardControllerProxy() = 0; - // Shows the task manager window. - virtual void ShowTaskManager() = 0; - // Get the current browser context. This will get us the current profile. virtual content::BrowserContext* GetCurrentBrowserContext() = 0; @@ -183,12 +163,12 @@ class ASH_EXPORT ShellDelegate { // Creates a accessibility delegate. Shell takes ownership of the delegate. virtual AccessibilityDelegate* CreateAccessibilityDelegate() = 0; + // Creates an application delegate. Shell takes ownership of the delegate. + virtual NewWindowDelegate* CreateNewWindowDelegate() = 0; + // Creates a user action client. Shell takes ownership of the object. virtual aura::client::UserActionClient* CreateUserActionClient() = 0; - // Opens the feedback page for "Report Issue". - virtual void OpenFeedbackPage() = 0; - // Records that the user performed an action. virtual void RecordUserMetricsAction(UserMetricsAction action) = 0; diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index d7c11bd..f2b3722 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -10,6 +10,7 @@ #include "ash/default_accessibility_delegate.h" #include "ash/host/root_window_host_factory.h" #include "ash/keyboard_controller_proxy_stub.h" +#include "ash/new_window_delegate.h" #include "ash/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" @@ -26,6 +27,20 @@ namespace ash { namespace test { +namespace { + +class NewWindowDelegateImpl : public NewWindowDelegate { + virtual void NewTab() OVERRIDE {} + virtual void NewWindow(bool incognito) OVERRIDE {} + virtual void OpenFileManager() OVERRIDE {} + virtual void OpenCrosh() OVERRIDE {} + virtual void RestoreTab() OVERRIDE {} + virtual void ShowKeyboardOverlay() OVERRIDE {} + virtual void ShowTaskManager() OVERRIDE {} + virtual void OpenFeedbackPage() OVERRIDE {} +}; + +} // namespace TestShellDelegate::TestShellDelegate() : num_exit_requests_(0), @@ -58,35 +73,14 @@ void TestShellDelegate::Exit() { num_exit_requests_++; } -void TestShellDelegate::NewTab() { -} - -void TestShellDelegate::NewWindow(bool incognito) { -} - void TestShellDelegate::ToggleFullscreen() { } -void TestShellDelegate::OpenFileManager() { -} - -void TestShellDelegate::OpenCrosh() { -} - -void TestShellDelegate::RestoreTab() { -} - -void TestShellDelegate::ShowKeyboardOverlay() { -} - keyboard::KeyboardControllerProxy* TestShellDelegate::CreateKeyboardControllerProxy() { return new KeyboardControllerProxyStub(); } -void TestShellDelegate::ShowTaskManager() { -} - content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() { current_browser_context_.reset(new content::TestBrowserContext()); return current_browser_context_.get(); @@ -123,11 +117,12 @@ AccessibilityDelegate* TestShellDelegate::CreateAccessibilityDelegate() { return new internal::DefaultAccessibilityDelegate(); } -aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { - return NULL; +NewWindowDelegate* TestShellDelegate::CreateNewWindowDelegate() { + return new NewWindowDelegateImpl; } -void TestShellDelegate::OpenFeedbackPage() { +aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { + return NULL; } void TestShellDelegate::RecordUserMetricsAction(UserMetricsAction action) { diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index 8c4269d..5e854ee 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -36,16 +36,9 @@ class TestShellDelegate : public ShellDelegate { virtual void PreInit() OVERRIDE; virtual void Shutdown() OVERRIDE; virtual void Exit() OVERRIDE; - virtual void NewTab() OVERRIDE; - virtual void NewWindow(bool incognito) OVERRIDE; virtual void ToggleFullscreen() OVERRIDE; - virtual void OpenFileManager() OVERRIDE; - virtual void OpenCrosh() OVERRIDE; - virtual void RestoreTab() OVERRIDE; - virtual void ShowKeyboardOverlay() OVERRIDE; virtual keyboard::KeyboardControllerProxy* CreateKeyboardControllerProxy() OVERRIDE; - virtual void ShowTaskManager() OVERRIDE; virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE; virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; virtual LauncherDelegate* CreateLauncherDelegate( @@ -55,8 +48,8 @@ class TestShellDelegate : public ShellDelegate { virtual CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE; virtual SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; virtual AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; + virtual NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; - virtual void OpenFeedbackPage() OVERRIDE; virtual void RecordUserMetricsAction(UserMetricsAction action) OVERRIDE; virtual void HandleMediaNextTrack() OVERRIDE; virtual void HandleMediaPlayPause() OVERRIDE; |