| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/media_delegate.h" |
| 8 #include "ash/wm/mru_window_tracker.h" | 9 #include "ash/wm/mru_window_tracker.h" |
| 9 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 14 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 15 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 15 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" | 16 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" |
| 16 #include "chrome/browser/chromeos/display/display_preferences.h" | 17 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 17 #include "chrome/browser/chromeos/extensions/media_player_api.h" | 18 #include "chrome/browser/chromeos/extensions/media_player_api.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return chromeos::MagnificationManager::Get()-> | 139 return chromeos::MagnificationManager::Get()-> |
| 139 GetSavedScreenMagnifierScale(); | 140 GetSavedScreenMagnifierScale(); |
| 140 } | 141 } |
| 141 return std::numeric_limits<double>::min(); | 142 return std::numeric_limits<double>::min(); |
| 142 } | 143 } |
| 143 | 144 |
| 144 private: | 145 private: |
| 145 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); | 146 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); |
| 146 }; | 147 }; |
| 147 | 148 |
| 149 class MediaDelegateImpl : public ash::MediaDelegate { |
| 150 public: |
| 151 MediaDelegateImpl() {} |
| 152 virtual ~MediaDelegateImpl() {} |
| 153 |
| 154 virtual void HandleMediaNextTrack() OVERRIDE { |
| 155 extensions::MediaPlayerAPI::Get( |
| 156 ProfileManager::GetDefaultProfileOrOffTheRecord())-> |
| 157 media_player_event_router()->NotifyNextTrack(); |
| 158 } |
| 159 |
| 160 virtual void HandleMediaPlayPause() OVERRIDE { |
| 161 extensions::MediaPlayerAPI::Get( |
| 162 ProfileManager::GetDefaultProfileOrOffTheRecord())-> |
| 163 media_player_event_router()->NotifyTogglePlayState(); |
| 164 } |
| 165 |
| 166 virtual void HandleMediaPrevTrack() OVERRIDE { |
| 167 extensions::MediaPlayerAPI::Get( |
| 168 ProfileManager::GetDefaultProfileOrOffTheRecord())-> |
| 169 media_player_event_router()->NotifyPrevTrack(); |
| 170 } |
| 171 |
| 172 private: |
| 173 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl); |
| 174 }; |
| 175 |
| 148 } // anonymous namespace | 176 } // anonymous namespace |
| 149 | 177 |
| 150 bool ChromeShellDelegate::IsFirstRunAfterBoot() const { | 178 bool ChromeShellDelegate::IsFirstRunAfterBoot() const { |
| 151 return CommandLine::ForCurrentProcess()->HasSwitch( | 179 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 152 chromeos::switches::kFirstExecAfterBoot); | 180 chromeos::switches::kFirstExecAfterBoot); |
| 153 } | 181 } |
| 154 | 182 |
| 155 void ChromeShellDelegate::PreInit() { | 183 void ChromeShellDelegate::PreInit() { |
| 156 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); | 184 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); |
| 157 } | 185 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 173 } | 201 } |
| 174 | 202 |
| 175 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { | 203 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { |
| 176 return new AccessibilityDelegateImpl; | 204 return new AccessibilityDelegateImpl; |
| 177 } | 205 } |
| 178 | 206 |
| 179 ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() { | 207 ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() { |
| 180 return new ChromeNewWindowDelegateChromeos; | 208 return new ChromeNewWindowDelegateChromeos; |
| 181 } | 209 } |
| 182 | 210 |
| 211 ash::MediaDelegate* ChromeShellDelegate::CreateMediaDelegate() { |
| 212 return new MediaDelegateImpl; |
| 213 } |
| 214 |
| 183 ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { | 215 ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { |
| 184 return chromeos::CreateSystemTrayDelegate(); | 216 return chromeos::CreateSystemTrayDelegate(); |
| 185 } | 217 } |
| 186 | 218 |
| 187 ash::UserWallpaperDelegate* ChromeShellDelegate::CreateUserWallpaperDelegate() { | 219 ash::UserWallpaperDelegate* ChromeShellDelegate::CreateUserWallpaperDelegate() { |
| 188 return chromeos::CreateUserWallpaperDelegate(); | 220 return chromeos::CreateUserWallpaperDelegate(); |
| 189 } | 221 } |
| 190 | 222 |
| 191 void ChromeShellDelegate::HandleMediaNextTrack() { | |
| 192 extensions::MediaPlayerAPI::Get( | |
| 193 ProfileManager::GetDefaultProfileOrOffTheRecord())-> | |
| 194 media_player_event_router()->NotifyNextTrack(); | |
| 195 } | |
| 196 | |
| 197 void ChromeShellDelegate::HandleMediaPlayPause() { | |
| 198 extensions::MediaPlayerAPI::Get( | |
| 199 ProfileManager::GetDefaultProfileOrOffTheRecord())-> | |
| 200 media_player_event_router()->NotifyTogglePlayState(); | |
| 201 } | |
| 202 | |
| 203 void ChromeShellDelegate::HandleMediaPrevTrack() { | |
| 204 extensions::MediaPlayerAPI::Get( | |
| 205 ProfileManager::GetDefaultProfileOrOffTheRecord())-> | |
| 206 media_player_event_router()->NotifyPrevTrack(); | |
| 207 } | |
| 208 | |
| 209 void ChromeShellDelegate::Observe(int type, | 223 void ChromeShellDelegate::Observe(int type, |
| 210 const content::NotificationSource& source, | 224 const content::NotificationSource& source, |
| 211 const content::NotificationDetails& details) { | 225 const content::NotificationDetails& details) { |
| 212 switch (type) { | 226 switch (type) { |
| 213 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: | 227 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: |
| 214 ash::Shell::GetInstance()->CreateLauncher(); | 228 ash::Shell::GetInstance()->CreateLauncher(); |
| 215 break; | 229 break; |
| 216 case chrome::NOTIFICATION_SESSION_STARTED: | 230 case chrome::NOTIFICATION_SESSION_STARTED: |
| 217 RestoreFocus(); | 231 RestoreFocus(); |
| 218 ash::Shell::GetInstance()->ShowLauncher(); | 232 ash::Shell::GetInstance()->ShowLauncher(); |
| 219 break; | 233 break; |
| 220 default: | 234 default: |
| 221 NOTREACHED() << "Unexpected notification " << type; | 235 NOTREACHED() << "Unexpected notification " << type; |
| 222 } | 236 } |
| 223 } | 237 } |
| 224 | 238 |
| 225 void ChromeShellDelegate::PlatformInit() { | 239 void ChromeShellDelegate::PlatformInit() { |
| 226 registrar_.Add(this, | 240 registrar_.Add(this, |
| 227 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 241 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 228 content::NotificationService::AllSources()); | 242 content::NotificationService::AllSources()); |
| 229 registrar_.Add(this, | 243 registrar_.Add(this, |
| 230 chrome::NOTIFICATION_SESSION_STARTED, | 244 chrome::NOTIFICATION_SESSION_STARTED, |
| 231 content::NotificationService::AllSources()); | 245 content::NotificationService::AllSources()); |
| 232 } | 246 } |
| OLD | NEW |