diff options
-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 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider_chromeos.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_new_window_delegate.cc | 138 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_new_window_delegate.h | 44 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc | 78 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h | 24 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_shell_delegate.cc | 125 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_shell_delegate.h | 23 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc | 67 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_shell_delegate_views.cc | 34 | ||||
-rw-r--r-- | chrome/chrome_browser_ui.gypi | 4 |
19 files changed, 439 insertions, 325 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; diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc index a3b39990..efac3d6 100644 --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc @@ -4,8 +4,8 @@ #include "chrome/browser/automation/testing_automation_provider.h" +#include "ash/new_window_delegate.h" #include "ash/shell.h" -#include "ash/shell_delegate.h" #include "ash/system/tray/system_tray_delegate.h" #include "base/command_line.h" #include "base/i18n/time_formatting.h" @@ -600,7 +600,7 @@ void TestingAutomationProvider::OpenCrosh(DictionaryValue* args, IPC::Message* reply_message) { new NavigationNotificationObserver( NULL, this, reply_message, 1, false, true); - ash::Shell::GetInstance()->delegate()->OpenCrosh(); + ash::Shell::GetInstance()->new_window_delegate()->OpenCrosh(); } void TestingAutomationProvider::AddChromeosObservers() { diff --git a/chrome/browser/ui/ash/chrome_new_window_delegate.cc b/chrome/browser/ui/ash/chrome_new_window_delegate.cc new file mode 100644 index 0000000..d0e5609 --- /dev/null +++ b/chrome/browser/ui/ash/chrome_new_window_delegate.cc @@ -0,0 +1,138 @@ +// 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. + +#include "chrome/browser/ui/ash/chrome_new_window_delegate.h" + +#include "ash/wm/window_util.h" +#include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/sessions/tab_restore_service.h" +#include "chrome/browser/sessions/tab_restore_service_factory.h" +#include "chrome/browser/sessions/tab_restore_service_observer.h" +#include "chrome/browser/ui/ash/chrome_shell_delegate.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_commands.h" +#include "chrome/browser/ui/browser_finder.h" +#include "chrome/browser/ui/browser_window.h" + +namespace { + +void RestoreTabUsingProfile(Profile* profile) { + TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); + service->RestoreMostRecentEntry(NULL, chrome::HOST_DESKTOP_TYPE_ASH); +} + +} // namespace + +ChromeNewWindowDelegate::ChromeNewWindowDelegate() {} +ChromeNewWindowDelegate::~ChromeNewWindowDelegate() {} + +// TabRestoreHelper is used to restore a tab. In particular when the user +// attempts to a restore a tab if the TabRestoreService hasn't finished loading +// this waits for it. Once the TabRestoreService finishes loading the tab is +// restored. +class ChromeNewWindowDelegate::TabRestoreHelper + : public TabRestoreServiceObserver { + public: + TabRestoreHelper(ChromeNewWindowDelegate* delegate, + Profile* profile, + TabRestoreService* service) + : delegate_(delegate), + profile_(profile), + tab_restore_service_(service) { + tab_restore_service_->AddObserver(this); + } + + virtual ~TabRestoreHelper() { + tab_restore_service_->RemoveObserver(this); + } + + TabRestoreService* tab_restore_service() { return tab_restore_service_; } + + virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE { + } + + virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE { + // This destroys us. + delegate_->tab_restore_helper_.reset(); + } + + virtual void TabRestoreServiceLoaded(TabRestoreService* service) OVERRIDE { + RestoreTabUsingProfile(profile_); + // This destroys us. + delegate_->tab_restore_helper_.reset(); + } + + private: + ChromeNewWindowDelegate* delegate_; + Profile* profile_; + TabRestoreService* tab_restore_service_; + + DISALLOW_COPY_AND_ASSIGN(TabRestoreHelper); +}; + +void ChromeNewWindowDelegate::NewTab() { + Browser* browser = GetTargetBrowser(); + + // If the browser was not active, we call BrowserWindow::Show to make it + // visible. Otherwise, we let Browser::NewTab handle the active window change. + const bool was_active = browser->window()->IsActive(); + chrome::NewTab(browser); + if (!was_active) + browser->window()->Show(); +} + +void ChromeNewWindowDelegate::NewWindow(bool is_incognito) { + Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); + chrome::NewEmptyWindow( + is_incognito ? profile->GetOffTheRecordProfile() : profile, + chrome::HOST_DESKTOP_TYPE_ASH); +} + +void ChromeNewWindowDelegate::RestoreTab() { + if (tab_restore_helper_.get()) { + DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded()); + return; + } + + Browser* browser = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); + Profile* profile = browser ? browser->profile() : NULL; + if (!profile) + profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); + if (profile->IsOffTheRecord()) + return; + TabRestoreService* service = + TabRestoreServiceFactory::GetForProfile(profile); + if (!service) + return; + + if (service->IsLoaded()) { + RestoreTabUsingProfile(profile); + } else { + tab_restore_helper_.reset(new TabRestoreHelper(this, profile, service)); + service->LoadTabsFromLastSession(); + } +} + +void ChromeNewWindowDelegate::ShowTaskManager() { + chrome::OpenTaskManager(NULL); +} + +void ChromeNewWindowDelegate::OpenFeedbackPage() { + chrome::OpenFeedbackDialog(GetTargetBrowserIfAvailable()); +} + +// static +Browser* ChromeNewWindowDelegate::GetTargetBrowser() { + Browser* browser = GetTargetBrowserIfAvailable(); + if (browser) + return browser; + return chrome::FindOrCreateTabbedBrowser( + ProfileManager::GetDefaultProfileOrOffTheRecord(), + chrome::HOST_DESKTOP_TYPE_ASH); +} + +// static +Browser* ChromeNewWindowDelegate::GetTargetBrowserIfAvailable() { + return chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); +} diff --git a/chrome/browser/ui/ash/chrome_new_window_delegate.h b/chrome/browser/ui/ash/chrome_new_window_delegate.h new file mode 100644 index 0000000..47c654c --- /dev/null +++ b/chrome/browser/ui/ash/chrome_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 CHROME_BROWSER_UI_ASH_CHROME_NEW_WINDOW_DELEGATE_H_ +#define CHROME_BROWSER_UI_ASH_CHROME_NEW_WINDOW_DELEGATE_H_ + +#include "ash/new_window_delegate.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" + +class Browser; + +class ChromeNewWindowDelegate : public ash::NewWindowDelegate { + public: + ChromeNewWindowDelegate(); + virtual ~ChromeNewWindowDelegate(); + + // Overridden from ash::NewWindowDelegate: + virtual void NewTab() OVERRIDE; + virtual void NewWindow(bool incognito) OVERRIDE; + virtual void RestoreTab() OVERRIDE; + virtual void ShowTaskManager() OVERRIDE; + virtual void OpenFeedbackPage() OVERRIDE; + + // Returns the browser for active ash window if any. Otherwise it searches + // for a browser or create one for default profile and returns it. + static Browser* GetTargetBrowser(); + + protected: + // This returns the active ash window if any. Unlike the method above, it + // does not create a window if one isn't available, instead it returns NULL + // in that case. + static Browser* GetTargetBrowserIfAvailable(); + + private: + class TabRestoreHelper; + + scoped_ptr<TabRestoreHelper> tab_restore_helper_; + + DISALLOW_COPY_AND_ASSIGN(ChromeNewWindowDelegate); +}; + +#endif // CHROME_BROWSER_UI_ASH_CHROME_NEW_WINDOW_DELEGATE_H_ diff --git a/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc new file mode 100644 index 0000000..d03dd28 --- /dev/null +++ b/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc @@ -0,0 +1,78 @@ +// 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. + +#include "chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h" + +#include "apps/shell_window_registry.h" +#include "apps/ui/native_app_window.h" +#include "ash/keyboard_overlay/keyboard_overlay_view.h" +#include "chrome/browser/chromeos/file_manager/app_id.h" +#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" +#include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/profiles/profile_manager.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/extensions/application_launch.h" +#include "chrome/browser/ui/webui/chrome_web_contents_handler.h" +#include "chrome/common/url_constants.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" + +ChromeNewWindowDelegateChromeos::ChromeNewWindowDelegateChromeos() {} +ChromeNewWindowDelegateChromeos::~ChromeNewWindowDelegateChromeos() {} + +void ChromeNewWindowDelegateChromeos::OpenFileManager() { + using file_manager::kFileManagerAppId; + Profile* const profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); + const apps::ShellWindowRegistry* const registry = + apps::ShellWindowRegistry::Get(profile); + const apps::ShellWindowRegistry::ShellWindowList list = + registry->GetShellWindowsForApp(kFileManagerAppId); + if (list.empty()) { + // Open the new window. + const ExtensionService* const service = profile->GetExtensionService(); + if (service == NULL || + !service->IsExtensionEnabledForLauncher(kFileManagerAppId)) + return; + const extensions::Extension* const extension = + service->GetInstalledExtension(kFileManagerAppId); + // event_flags = 0 means this invokes the same behavior as the launcher + // item is clicked without any keyboard modifiers. + OpenApplication(AppLaunchParams( + profile, + extension, + 0 /* event_flags */, + chrome::HOST_DESKTOP_TYPE_ASH)); + } else { + // Activate the existing window. + list.front()->GetBaseWindow()->Activate(); + } +} + +void ChromeNewWindowDelegateChromeos::OpenCrosh() { + GURL crosh_url = extensions::TerminalExtensionHelper::GetCroshExtensionURL( + ProfileManager::GetDefaultProfileOrOffTheRecord()); + if (!crosh_url.is_valid()) + return; + Browser* browser = GetTargetBrowser(); + content::WebContents* page = browser->OpenURL( + content::OpenURLParams(crosh_url, + content::Referrer(), + NEW_FOREGROUND_TAB, + content::PAGE_TRANSITION_GENERATED, + false)); + browser->window()->Show(); + browser->window()->Activate(); + page->GetView()->Focus(); +} + +void ChromeNewWindowDelegateChromeos::ShowKeyboardOverlay() { + // TODO(mazda): Move the show logic to ash (http://crbug.com/124222). + Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); + std::string url(chrome::kChromeUIKeyboardOverlayURL); + ash::KeyboardOverlayView::ShowDialog(profile, + new ChromeWebContentsHandler, + GURL(url)); +} diff --git a/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h b/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h new file mode 100644 index 0000000..3688e6d --- /dev/null +++ b/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h @@ -0,0 +1,24 @@ +// 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 CHROME_BROWSER_UI_ASH_CHROME_NEW_WINDOW_DELEGATE_CHROMEOS_H_ +#define CHROME_BROWSER_UI_ASH_CHROME_NEW_WINDOW_DELEGATE_CHROMEOS_H_ + +#include "chrome/browser/ui/ash/chrome_new_window_delegate.h" + +class ChromeNewWindowDelegateChromeos : public ChromeNewWindowDelegate { + public: + ChromeNewWindowDelegateChromeos(); + virtual ~ChromeNewWindowDelegateChromeos(); + + // Overridden from ash::NewWindowDelegate: + virtual void OpenFileManager() OVERRIDE; + virtual void OpenCrosh() OVERRIDE; + virtual void ShowKeyboardOverlay() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ChromeNewWindowDelegateChromeos); +}; + +#endif // CHROME_BROWSER_UI_ASH_CHROME_NEW_WINDOW_DELEGATE_CHROMEOS_H_ diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc index c94e533..420839c 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc @@ -6,37 +6,26 @@ #include "apps/shell_window.h" #include "apps/shell_window_registry.h" -#include "apps/ui/native_app_window.h" #include "ash/host/root_window_host_factory.h" #include "ash/magnifier/magnifier_constants.h" -#include "ash/session_state_delegate.h" -#include "ash/system/tray/system_tray_delegate.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" #include "base/command_line.h" -#include "base/prefs/pref_service.h" #include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/sessions/tab_restore_service.h" -#include "chrome/browser/sessions/tab_restore_service_factory.h" -#include "chrome/browser/sessions/tab_restore_service_observer.h" #include "chrome/browser/ui/app_list/app_list_view_delegate.h" #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.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/launcher_context_menu.h" #include "chrome/browser/ui/ash/user_action_handler.h" -#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/host_desktop.h" #include "chrome/common/chrome_switches.h" #include "content/public/browser/user_metrics.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" -#include "ui/aura/window.h" #include "ui/base/l10n/l10n_util.h" #if defined(OS_CHROMEOS) @@ -47,57 +36,6 @@ // static ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; -namespace { - -void RestoreTabUsingProfile(Profile* profile) { - TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); - service->RestoreMostRecentEntry(NULL, chrome::HOST_DESKTOP_TYPE_ASH); -} - -} // namespace - -// TabRestoreHelper is used to restore a tab. In particular when the user -// attempts to a restore a tab if the TabRestoreService hasn't finished loading -// this waits for it. Once the TabRestoreService finishes loading the tab is -// restored. -class ChromeShellDelegate::TabRestoreHelper : public TabRestoreServiceObserver { - public: - TabRestoreHelper(ChromeShellDelegate* delegate, - Profile* profile, - TabRestoreService* service) - : delegate_(delegate), - profile_(profile), - tab_restore_service_(service) { - tab_restore_service_->AddObserver(this); - } - - virtual ~TabRestoreHelper() { - tab_restore_service_->RemoveObserver(this); - } - - TabRestoreService* tab_restore_service() { return tab_restore_service_; } - - virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE { - } - virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE { - // This destroys us. - delegate_->tab_restore_helper_.reset(); - } - - virtual void TabRestoreServiceLoaded(TabRestoreService* service) OVERRIDE { - RestoreTabUsingProfile(profile_); - // This destroys us. - delegate_->tab_restore_helper_.reset(); - } - - private: - ChromeShellDelegate* delegate_; - Profile* profile_; - TabRestoreService* tab_restore_service_; - - DISALLOW_COPY_AND_ASSIGN(TabRestoreHelper); -}; - ChromeShellDelegate::ChromeShellDelegate() : launcher_delegate_(NULL) { instance_ = this; @@ -134,23 +72,6 @@ void ChromeShellDelegate::Exit() { chrome::AttemptUserExit(); } -void ChromeShellDelegate::NewTab() { - Browser* browser = GetTargetBrowser(); - // If the browser was not active, we call BrowserWindow::Show to make it - // visible. Otherwise, we let Browser::NewTab handle the active window change. - const bool was_active = browser->window()->IsActive(); - chrome::NewTab(browser); - if (!was_active) - browser->window()->Show(); -} - -void ChromeShellDelegate::NewWindow(bool is_incognito) { - Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); - chrome::NewEmptyWindow( - is_incognito ? profile->GetOffTheRecordProfile() : profile, - chrome::HOST_DESKTOP_TYPE_ASH); -} - void ChromeShellDelegate::ToggleFullscreen() { // Only toggle if the user has a window open. aura::Window* window = ash::wm::GetActiveWindow(); @@ -200,35 +121,6 @@ void ChromeShellDelegate::ToggleFullscreen() { } } -void ChromeShellDelegate::RestoreTab() { - if (tab_restore_helper_.get()) { - DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded()); - return; - } - - Browser* browser = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); - Profile* profile = browser ? browser->profile() : NULL; - if (!profile) - profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); - if (profile->IsOffTheRecord()) - return; - TabRestoreService* service = - TabRestoreServiceFactory::GetForProfile(profile); - if (!service) - return; - - if (service->IsLoaded()) { - RestoreTabUsingProfile(profile); - } else { - tab_restore_helper_.reset(new TabRestoreHelper(this, profile, service)); - service->LoadTabsFromLastSession(); - } -} - -void ChromeShellDelegate::ShowTaskManager() { - chrome::OpenTaskManager(NULL); -} - content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() { return ProfileManager::GetDefaultProfile(); } @@ -261,10 +153,6 @@ aura::client::UserActionClient* ChromeShellDelegate::CreateUserActionClient() { return new UserActionHandler; } -void ChromeShellDelegate::OpenFeedbackPage() { - chrome::OpenFeedbackDialog(GetTargetBrowserIfAvailable()); -} - void ChromeShellDelegate::RecordUserMetricsAction( ash::UserMetricsAction action) { switch (action) { @@ -435,19 +323,6 @@ string16 ChromeShellDelegate::GetProductName() const { return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); } -Browser* ChromeShellDelegate::GetTargetBrowser() { - Browser* browser = GetTargetBrowserIfAvailable(); - if (browser) - return browser; - return chrome::FindOrCreateTabbedBrowser( - ProfileManager::GetDefaultProfileOrOffTheRecord(), - chrome::HOST_DESKTOP_TYPE_ASH); -} - -Browser* ChromeShellDelegate::GetTargetBrowserIfAvailable() { - return chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); -} - keyboard::KeyboardControllerProxy* ChromeShellDelegate::CreateKeyboardControllerProxy() { return new AshKeyboardControllerProxy(); diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h index 82dd89a..ce48df5 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.h +++ b/chrome/browser/ui/ash/chrome_shell_delegate.h @@ -26,6 +26,7 @@ class KeyboardControllerProxy; } class ChromeLauncherController; +class ChromeNewWindowDelegate; class ChromeShellDelegate : public ash::ShellDelegate, public content::NotificationObserver { @@ -42,16 +43,9 @@ class ChromeShellDelegate : public ash::ShellDelegate, virtual void PreInit() OVERRIDE; virtual void Shutdown() OVERRIDE; virtual void Exit() OVERRIDE; - virtual void NewTab() OVERRIDE; - virtual void NewWindow(bool is_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( @@ -61,8 +55,8 @@ class ChromeShellDelegate : 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(ash::UserMetricsAction action) OVERRIDE; virtual void HandleMediaNextTrack() OVERRIDE; virtual void HandleMediaPlayPause() OVERRIDE; @@ -77,27 +71,14 @@ class ChromeShellDelegate : public ash::ShellDelegate, const content::NotificationDetails& details) OVERRIDE; private: - class TabRestoreHelper; - void PlatformInit(); - // Returns the browser for active ash window if any. Otherwise it searches - // for a browser or create one for default profile and returns it. - Browser* GetTargetBrowser(); - - // This returns the active ash window if any. Unlike the method above, it - // does not create a window if one isn't available, instead it returns NULL - // in that case. - Browser* GetTargetBrowserIfAvailable(); - static ChromeShellDelegate* instance_; content::NotificationRegistrar registrar_; ChromeLauncherController* launcher_delegate_; - scoped_ptr<TabRestoreHelper> tab_restore_helper_; - DISALLOW_COPY_AND_ASSIGN(ChromeShellDelegate); }; diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc index 2caaa09..e6d31a5 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc @@ -4,10 +4,7 @@ #include "chrome/browser/ui/ash/chrome_shell_delegate.h" -#include "apps/shell_window_registry.h" -#include "apps/ui/native_app_window.h" #include "ash/accessibility_delegate.h" -#include "ash/keyboard_overlay/keyboard_overlay_view.h" #include "ash/wm/mru_window_tracker.h" #include "ash/wm/window_util.h" #include "base/command_line.h" @@ -19,29 +16,23 @@ #include "chrome/browser/chromeos/display/display_preferences.h" #include "chrome/browser/chromeos/extensions/media_player_api.h" #include "chrome/browser/chromeos/extensions/media_player_event_router.h" -#include "chrome/browser/chromeos/file_manager/app_id.h" #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" -#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" -#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/speech/tts_controller.h" #include "chrome/browser/ui/ash/caps_lock_delegate_chromeos.h" +#include "chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h" #include "chrome/browser/ui/ash/session_state_delegate_chromeos.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/extensions/application_launch.h" -#include "chrome/browser/ui/webui/chrome_web_contents_handler.h" #include "chrome/common/pref_names.h" -#include "chrome/common/url_constants.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power_manager_client.h" #include "chromeos/ime/input_method_manager.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/user_metrics.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" +#include "ui/aura/window.h" namespace { @@ -171,51 +162,6 @@ void ChromeShellDelegate::Shutdown() { RequestShutdown(); } -void ChromeShellDelegate::OpenFileManager() { - using file_manager::kFileManagerAppId; - Profile* const profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); - const apps::ShellWindowRegistry* const registry = - apps::ShellWindowRegistry::Get(profile); - const apps::ShellWindowRegistry::ShellWindowList list = - registry->GetShellWindowsForApp(kFileManagerAppId); - if (list.empty()) { - // Open the new window. - const ExtensionService* const service = profile->GetExtensionService(); - if (service == NULL || - !service->IsExtensionEnabledForLauncher(kFileManagerAppId)) - return; - const extensions::Extension* const extension = - service->GetInstalledExtension(kFileManagerAppId); - // event_flags = 0 means this invokes the same behavior as the launcher - // item is clicked without any keyboard modifiers. - OpenApplication(AppLaunchParams( - profile, - extension, - 0 /* event_flags */, - chrome::HOST_DESKTOP_TYPE_ASH)); - } else { - // Activate the existing window. - list.front()->GetBaseWindow()->Activate(); - } -} - -void ChromeShellDelegate::OpenCrosh() { - GURL crosh_url = extensions::TerminalExtensionHelper::GetCroshExtensionURL( - ProfileManager::GetDefaultProfileOrOffTheRecord()); - if (!crosh_url.is_valid()) - return; - Browser* browser = GetTargetBrowser(); - content::WebContents* page = browser->OpenURL( - content::OpenURLParams(crosh_url, - content::Referrer(), - NEW_FOREGROUND_TAB, - content::PAGE_TRANSITION_GENERATED, - false)); - browser->window()->Show(); - browser->window()->Activate(); - page->GetView()->Focus(); -} - ash::CapsLockDelegate* ChromeShellDelegate::CreateCapsLockDelegate() { chromeos::input_method::XKeyboard* xkeyboard = chromeos::input_method::InputMethodManager::Get()->GetXKeyboard(); @@ -230,13 +176,8 @@ ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { return new AccessibilityDelegateImpl; } -void ChromeShellDelegate::ShowKeyboardOverlay() { - // TODO(mazda): Move the show logic to ash (http://crbug.com/124222). - Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); - std::string url(chrome::kChromeUIKeyboardOverlayURL); - ash::KeyboardOverlayView::ShowDialog(profile, - new ChromeWebContentsHandler, - GURL(url)); +ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() { + return new ChromeNewWindowDelegateChromeos; } ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc index 7ee8dcf..3ef7504 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc @@ -12,6 +12,7 @@ #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/ash/caps_lock_delegate_views.h" +#include "chrome/browser/ui/ash/chrome_new_window_delegate.h" #include "chrome/browser/ui/ash/session_state_delegate_views.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -28,6 +29,20 @@ namespace { +class NewWindowDelegateImpl : public ChromeNewWindowDelegate { + public: + NewWindowDelegateImpl() {} + virtual ~NewWindowDelegateImpl() {} + + // Overridden from ash::NewWindowDelegate: + virtual void OpenFileManager() OVERRIDE {} + virtual void OpenCrosh() OVERRIDE {} + virtual void ShowKeyboardOverlay() OVERRIDE {} + + private: + DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl); +}; + class EmptyAccessibilityDelegate : public ash::AccessibilityDelegate { public: EmptyAccessibilityDelegate() {} @@ -36,6 +51,10 @@ class EmptyAccessibilityDelegate : public ash::AccessibilityDelegate { virtual void ToggleHighContrast() OVERRIDE { } + virtual bool IsHighContrastEnabled() const OVERRIDE { + return false; + } + virtual bool IsSpokenFeedbackEnabled() const OVERRIDE { return false; } @@ -51,10 +70,6 @@ class EmptyAccessibilityDelegate : public ash::AccessibilityDelegate { return false; } - virtual bool IsHighContrastEnabled() const OVERRIDE { - return false; - } - virtual void SetMagnifierEnabled(bool enabled) OVERRIDE { } @@ -106,13 +121,8 @@ void ChromeShellDelegate::PreInit() { void ChromeShellDelegate::Shutdown() { } -void ChromeShellDelegate::OpenFileManager() { -} - -void ChromeShellDelegate::OpenCrosh() { -} - -void ChromeShellDelegate::ShowKeyboardOverlay() { +ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() { + return new NewWindowDelegateImpl; } ash::CapsLockDelegate* ChromeShellDelegate::CreateCapsLockDelegate() { @@ -181,7 +191,7 @@ void ChromeShellDelegate::Observe(int type, true, chrome::HOST_DESKTOP_TYPE_ASH); } else { - Browser* browser = GetTargetBrowser(); + Browser* browser = ChromeNewWindowDelegate::GetTargetBrowser(); chrome::AddBlankTabAt(browser, -1, true); browser->window()->Show(); } diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index a23b7e9..2771e2c 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -258,6 +258,10 @@ 'browser/ui/ash/caps_lock_delegate_views.h', 'browser/ui/ash/chrome_launcher_prefs.cc', 'browser/ui/ash/chrome_launcher_prefs.h', + 'browser/ui/ash/chrome_new_window_delegate.cc', + 'browser/ui/ash/chrome_new_window_delegate.h', + 'browser/ui/ash/chrome_new_window_delegate_chromeos.cc', + 'browser/ui/ash/chrome_new_window_delegate_chromeos.h', 'browser/ui/ash/chrome_shell_delegate.cc', 'browser/ui/ash/chrome_shell_delegate.h', 'browser/ui/ash/chrome_shell_delegate_chromeos.cc', |