1 // Copyright 2013 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 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" 6 7 #include "base/command_line.h" 8 #include "ash/magnifier/magnifier_constants.h" 9 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/prefs/session_startup_pref.h" 11 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/ui/ash/caps_lock_delegate_views.h" 13 #include "chrome/browser/ui/ash/session_state_delegate_views.h" 14 #include "chrome/browser/ui/ash/window_positioner.h" 15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_tabstrip.h" 18 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/host_desktop.h" 20 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" 21 #include "chrome/common/chrome_switches.h" 22 #include "content/public/browser/notification_service.h" 23 24 #if defined(OS_WIN) 25 #include "chrome/browser/ui/ash/user_wallpaper_delegate_win.h" 26 #endif 27 28 bool ChromeShellDelegate::IsFirstRunAfterBoot() const { 29 return false; 30 } 31 32 void ChromeShellDelegate::PreInit() { 33 } 34 35 void ChromeShellDelegate::Shutdown() { 36 } 37 38 void ChromeShellDelegate::OpenFileManager(bool as_dialog) { 39 } 40 41 void ChromeShellDelegate::OpenCrosh() { 42 } 43 44 void ChromeShellDelegate::ShowKeyboardOverlay() { 45 } 46 47 void ChromeShellDelegate::ToggleHighContrast() { 48 } 49 50 bool ChromeShellDelegate::IsSpokenFeedbackEnabled() const { 51 return false; 52 } 53 54 void ChromeShellDelegate::ToggleSpokenFeedback( 55 ash::AccessibilityNotificationVisibility notify) { 56 } 57 58 void ChromeShellDelegate::SetLargeCursorEnabled(bool enalbed) { 59 } 60 61 bool ChromeShellDelegate::IsLargeCursorEnabled() const { 62 return false; 63 } 64 65 bool ChromeShellDelegate::IsHighContrastEnabled() const { 66 return false; 67 } 68 69 void ChromeShellDelegate::SetMagnifierEnabled(bool enabled) { 70 } 71 72 void ChromeShellDelegate::SetMagnifierType(ash::MagnifierType type) { 73 } 74 75 bool ChromeShellDelegate::IsMagnifierEnabled() const { 76 return false; 77 } 78 79 ash::MagnifierType ChromeShellDelegate::GetMagnifierType() const { 80 return ash::kDefaultMagnifierType; 81 } 82 83 ash::CapsLockDelegate* ChromeShellDelegate::CreateCapsLockDelegate() { 84 return new CapsLockDelegate(); 85 } 86 87 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { 88 return new SessionStateDelegate; 89 } 90 91 void ChromeShellDelegate::SaveScreenMagnifierScale(double scale) { 92 } 93 94 double ChromeShellDelegate::GetSavedScreenMagnifierScale() { 95 return std::numeric_limits<double>::min(); 96 } 97 98 bool ChromeShellDelegate::ShouldAlwaysShowAccessibilityMenu() const { 99 return false; 100 } 101 102 void ChromeShellDelegate::SilenceSpokenFeedback() const { 103 } 104 105 ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { 106 return NULL; 107 } 108 109 ash::UserWallpaperDelegate* ChromeShellDelegate::CreateUserWallpaperDelegate() { 110 #if defined(OS_WIN) 111 return ::CreateUserWallpaperDelegate(); 112 #else 113 return NULL; 114 #endif 115 } 116 117 void ChromeShellDelegate::HandleMediaNextTrack() { 118 } 119 120 void ChromeShellDelegate::HandleMediaPlayPause() { 121 } 122 123 void ChromeShellDelegate::HandleMediaPrevTrack() { 124 } 125 126 void ChromeShellDelegate::Observe(int type, 127 const content::NotificationSource& source, 128 const content::NotificationDetails& details) { 129 switch (type) { 130 case chrome::NOTIFICATION_ASH_SESSION_STARTED: { 131 // If we are launched to service a windows 8 search request then let the 132 // IPC which carries the search string create the browser and initiate 133 // the navigation. 134 if (CommandLine::ForCurrentProcess()->HasSwitch( 135 switches::kWindows8Search)) 136 break; 137 // If Chrome ASH is launched when no browser is open in the desktop, 138 // we should execute the startup code. 139 // If there are browsers open in the desktop, we create a browser window 140 // and open a new tab page, if session restore is not on. 141 BrowserList* desktop_list = BrowserList::GetInstance( 142 chrome::HOST_DESKTOP_TYPE_NATIVE); 143 if (desktop_list->empty()) { 144 // We pass a dummy command line here, because the browser is launched in 145 // silent-mode by the metro viewer process, which causes the 146 // StartupBrowserCreatorImpl class to not create any browsers which is 147 // not the behavior we want. 148 CommandLine dummy(CommandLine::NO_PROGRAM); 149 StartupBrowserCreatorImpl startup_impl( 150 base::FilePath(), 151 dummy, 152 chrome::startup::IS_NOT_FIRST_RUN); 153 startup_impl.Launch(ProfileManager::GetDefaultProfileOrOffTheRecord(), 154 std::vector<GURL>(), 155 true, 156 chrome::HOST_DESKTOP_TYPE_ASH); 157 } else { 158 Browser* browser = GetTargetBrowser(); 159 chrome::AddBlankTabAt(browser, -1, true); 160 browser->window()->Show(); 161 } 162 break; 163 } 164 case chrome::NOTIFICATION_ASH_SESSION_ENDED: 165 break; 166 default: 167 NOTREACHED() << "Unexpected notification " << type; 168 } 169 } 170 171 void ChromeShellDelegate::PlatformInit() { 172 #if defined(OS_WIN) 173 registrar_.Add(this, 174 chrome::NOTIFICATION_ASH_SESSION_STARTED, 175 content::NotificationService::AllSources()); 176 registrar_.Add(this, 177 chrome::NOTIFICATION_ASH_SESSION_ENDED, 178 content::NotificationService::AllSources()); 179 #endif 180 } 181