1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_ASH_CHROME_SHELL_DELEGATE_H_ 6#define CHROME_BROWSER_UI_ASH_CHROME_SHELL_DELEGATE_H_ 7 8#include <string> 9 10#include "ash/launcher/launcher_types.h" 11#include "ash/shell_delegate.h" 12#include "base/basictypes.h" 13#include "base/compiler_specific.h" 14#include "base/memory/scoped_ptr.h" 15#include "content/public/browser/notification_observer.h" 16#include "content/public/browser/notification_registrar.h" 17 18class Browser; 19 20namespace ash { 21class WindowPositioner; 22} 23 24namespace content { 25class WebContents; 26} 27 28namespace keyboard { 29class KeyboardControllerProxy; 30} 31 32class ChromeLauncherController; 33 34class ChromeShellDelegate : public ash::ShellDelegate, 35 public content::NotificationObserver { 36 public: 37 ChromeShellDelegate(); 38 virtual ~ChromeShellDelegate(); 39 40 static ChromeShellDelegate* instance() { return instance_; } 41 42 ash::WindowPositioner* window_positioner() { 43 return window_positioner_.get(); 44 } 45 46 // ash::ShellDelegate overrides; 47 virtual bool IsFirstRunAfterBoot() const OVERRIDE; 48 virtual bool IsMultiProfilesEnabled() const OVERRIDE; 49 virtual bool IsRunningInForcedAppMode() const OVERRIDE; 50 virtual void PreInit() OVERRIDE; 51 virtual void Shutdown() OVERRIDE; 52 virtual void Exit() OVERRIDE; 53 virtual void NewTab() OVERRIDE; 54 virtual void NewWindow(bool is_incognito) OVERRIDE; 55 virtual void ToggleFullscreen() OVERRIDE; 56 virtual void ToggleMaximized() OVERRIDE; 57 virtual void OpenFileManager(bool as_dialog) OVERRIDE; 58 virtual void OpenCrosh() OVERRIDE; 59 virtual void RestoreTab() OVERRIDE; 60 virtual void ShowKeyboardOverlay() OVERRIDE; 61 virtual keyboard::KeyboardControllerProxy* 62 CreateKeyboardControllerProxy() OVERRIDE; 63 virtual void ShowTaskManager() OVERRIDE; 64 virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE; 65 virtual void ToggleHighContrast() OVERRIDE; 66 virtual bool IsSpokenFeedbackEnabled() const OVERRIDE; 67 virtual void ToggleSpokenFeedback( 68 ash::AccessibilityNotificationVisibility notify) OVERRIDE; 69 virtual bool IsHighContrastEnabled() const OVERRIDE; 70 virtual void SetMagnifierEnabled(bool enabled) OVERRIDE; 71 virtual void SetMagnifierType(ash::MagnifierType type) OVERRIDE; 72 virtual bool IsMagnifierEnabled() const OVERRIDE; 73 virtual ash::MagnifierType GetMagnifierType() const OVERRIDE; 74 virtual void SetLargeCursorEnabled(bool enabled) OVERRIDE; 75 virtual bool IsLargeCursorEnabled() const OVERRIDE; 76 virtual bool ShouldAlwaysShowAccessibilityMenu() const OVERRIDE; 77 virtual void SilenceSpokenFeedback() const OVERRIDE; 78 virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; 79 virtual ash::LauncherDelegate* CreateLauncherDelegate( 80 ash::LauncherModel* model) OVERRIDE; 81 virtual ash::SystemTrayDelegate* CreateSystemTrayDelegate() OVERRIDE; 82 virtual ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() OVERRIDE; 83 virtual ash::CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE; 84 virtual ash::SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; 85 virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; 86 virtual void OpenFeedbackPage() OVERRIDE; 87 virtual void RecordUserMetricsAction(ash::UserMetricsAction action) OVERRIDE; 88 virtual void HandleMediaNextTrack() OVERRIDE; 89 virtual void HandleMediaPlayPause() OVERRIDE; 90 virtual void HandleMediaPrevTrack() OVERRIDE; 91 virtual void SaveScreenMagnifierScale(double scale) OVERRIDE; 92 virtual double GetSavedScreenMagnifierScale() OVERRIDE; 93 virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root) OVERRIDE; 94 virtual ash::RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE; 95 virtual string16 GetProductName() const OVERRIDE; 96 97 // content::NotificationObserver override: 98 virtual void Observe(int type, 99 const content::NotificationSource& source, 100 const content::NotificationDetails& details) OVERRIDE; 101 102 private: 103 class TabRestoreHelper; 104 105 void PlatformInit(); 106 107 // Returns the browser for active ash window if any. Otherwise it searches 108 // for a browser or create one for default profile and returns it. 109 Browser* GetTargetBrowser(); 110 111 static ChromeShellDelegate* instance_; 112 113 content::NotificationRegistrar registrar_; 114 115 scoped_ptr<ash::WindowPositioner> window_positioner_; 116 117 base::WeakPtrFactory<ChromeShellDelegate> weak_factory_; 118 119 ChromeLauncherController* launcher_delegate_; 120 121 scoped_ptr<TabRestoreHelper> tab_restore_helper_; 122 123 DISALLOW_COPY_AND_ASSIGN(ChromeShellDelegate); 124}; 125 126#endif // CHROME_BROWSER_UI_ASH_CHROME_SHELL_DELEGATE_H_ 127