diff options
-rw-r--r-- | ash/accelerators/accelerator_controller.cc | 7 | ||||
-rw-r--r-- | ash/accessibility_delegate.h | 1 | ||||
-rw-r--r-- | ash/media_delegate.h | 27 | ||||
-rw-r--r-- | ash/new_window_delegate.h | 1 | ||||
-rw-r--r-- | ash/shell.cc | 4 | ||||
-rw-r--r-- | ash/shell.h | 6 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.cc | 27 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.h | 4 | ||||
-rw-r--r-- | ash/shell_delegate.h | 13 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.cc | 21 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_shell_delegate.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc | 50 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_shell_delegate_views.cc | 26 |
14 files changed, 127 insertions, 68 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 5941081..efb9098 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -24,6 +24,7 @@ #include "ash/launcher/launcher_model.h" #include "ash/magnifier/magnification_controller.h" #include "ash/magnifier/partial_magnification_controller.h" +#include "ash/media_delegate.h" #include "ash/multi_profile_uma.h" #include "ash/new_window_delegate.h" #include "ash/root_window_controller.h" @@ -313,17 +314,17 @@ bool HandleMagnifyScreen(int delta_index) { } bool HandleMediaNextTrack() { - Shell::GetInstance()->delegate()->HandleMediaNextTrack(); + Shell::GetInstance()->media_delegate()->HandleMediaNextTrack(); return true; } bool HandleMediaPlayPause() { - Shell::GetInstance()->delegate()->HandleMediaPlayPause(); + Shell::GetInstance()->media_delegate()->HandleMediaPlayPause(); return true; } bool HandleMediaPrevTrack() { - Shell::GetInstance()->delegate()->HandleMediaPrevTrack(); + Shell::GetInstance()->media_delegate()->HandleMediaPrevTrack(); return true; } diff --git a/ash/accessibility_delegate.h b/ash/accessibility_delegate.h index a77e840..1f0f349 100644 --- a/ash/accessibility_delegate.h +++ b/ash/accessibility_delegate.h @@ -18,7 +18,6 @@ enum AccessibilityNotificationVisibility { // A deletate class to control accessibility features. class ASH_EXPORT AccessibilityDelegate { public: - AccessibilityDelegate() {} virtual ~AccessibilityDelegate() {} // Invoked to toggle spoken feedback for accessibility diff --git a/ash/media_delegate.h b/ash/media_delegate.h new file mode 100644 index 0000000..1dac059 --- /dev/null +++ b/ash/media_delegate.h @@ -0,0 +1,27 @@ +// 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_MEDIA_DELEGATE_H_ +#define ASH_MEDIA_DELEGATE_H_ + +namespace ash { + +// A delegate class to control media playback. +class MediaDelegate { + public: + virtual ~MediaDelegate() {} + + // Handles the Next Track Media shortcut key. + virtual void HandleMediaNextTrack() = 0; + + // Handles the Play/Pause Toggle Media shortcut key. + virtual void HandleMediaPlayPause() = 0; + + // Handles the Previous Track Media shortcut key. + virtual void HandleMediaPrevTrack() = 0; +}; + +} // namespace ash + +#endif // ASH_MEDIA_DELEGATE_H_ diff --git a/ash/new_window_delegate.h b/ash/new_window_delegate.h index b4a592b..57319af 100644 --- a/ash/new_window_delegate.h +++ b/ash/new_window_delegate.h @@ -11,7 +11,6 @@ namespace ash { // ash. class NewWindowDelegate { public: - NewWindowDelegate() {} virtual ~NewWindowDelegate() {} // Invoked when the user uses Ctrl+T to open a new tab. diff --git a/ash/shell.cc b/ash/shell.cc index 02a84db..0410c40 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/media_delegate.h" #include "ash/new_window_delegate.h" #include "ash/root_window_controller.h" #include "ash/screen_ash.h" @@ -665,6 +666,8 @@ Shell::~Shell() { keyboard_controller_.reset(); accessibility_delegate_.reset(); + new_window_delegate_.reset(); + media_delegate_.reset(); #if defined(OS_CHROMEOS) && defined(USE_X11) if (display_change_observer_) @@ -842,6 +845,7 @@ void Shell::Init() { session_state_delegate_.reset(delegate_->CreateSessionStateDelegate()); accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); new_window_delegate_.reset(delegate_->CreateNewWindowDelegate()); + media_delegate_.reset(delegate_->CreateMediaDelegate()); 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 62379ac..fa54faa 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -92,6 +92,7 @@ class LauncherItemDelegateManager; class LauncherModel; class LockStateController; class MagnificationController; +class MediaDelegate; class MruWindowTracker; class NestedDispatcherController; class NewWindowDelegate; @@ -377,6 +378,10 @@ class ASH_EXPORT Shell return new_window_delegate_.get(); } + MediaDelegate* media_delegate() { + return media_delegate_.get(); + } + HighContrastController* high_contrast_controller() { return high_contrast_controller_.get(); } @@ -586,6 +591,7 @@ class ASH_EXPORT Shell scoped_ptr<SessionStateDelegate> session_state_delegate_; scoped_ptr<AccessibilityDelegate> accessibility_delegate_; scoped_ptr<NewWindowDelegate> new_window_delegate_; + scoped_ptr<MediaDelegate> media_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 e414419..d890625 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/media_delegate.h" #include "ash/new_window_delegate.h" #include "ash/session_state_delegate.h" #include "ash/session_state_delegate_stub.h" @@ -51,6 +52,19 @@ class NewWindowDelegateImpl : public NewWindowDelegate { DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl); }; +class MediaDelegateImpl : public MediaDelegate { + public: + MediaDelegateImpl() {} + virtual ~MediaDelegateImpl() {} + + virtual void HandleMediaNextTrack() OVERRIDE {} + virtual void HandleMediaPlayPause() OVERRIDE {} + virtual void HandleMediaPrevTrack() OVERRIDE {} + + private: + DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl); +}; + } // namespace ShellDelegateImpl::ShellDelegateImpl() @@ -136,6 +150,10 @@ ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() { return new NewWindowDelegateImpl; } +ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() { + return new MediaDelegateImpl; +} + aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() { return NULL; } @@ -143,15 +161,6 @@ aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() { void ShellDelegateImpl::RecordUserMetricsAction(UserMetricsAction action) { } -void ShellDelegateImpl::HandleMediaNextTrack() { -} - -void ShellDelegateImpl::HandleMediaPlayPause() { -} - -void ShellDelegateImpl::HandleMediaPrevTrack() { -} - ui::MenuModel* ShellDelegateImpl::CreateContextMenu(aura::Window* root) { return new ContextMenu(root); } diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index 544eef9..db31609 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h @@ -46,11 +46,9 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual ash::SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; + virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual void RecordUserMetricsAction(UserMetricsAction action) OVERRIDE; - virtual void HandleMediaNextTrack() OVERRIDE; - virtual void HandleMediaPlayPause() OVERRIDE; - virtual void HandleMediaPrevTrack() OVERRIDE; virtual ui::MenuModel* CreateContextMenu( aura::Window* root_window) OVERRIDE; virtual RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE; diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index 3c8d344..76a129d 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -42,6 +42,7 @@ class CapsLockDelegate; class LauncherDelegate; class LauncherModel; struct LauncherItem; +class MediaDelegate; class NewWindowDelegate; class RootWindowHostFactory; class AccessibilityDelegate; @@ -168,21 +169,15 @@ class ASH_EXPORT ShellDelegate { // Creates an application delegate. Shell takes ownership of the delegate. virtual NewWindowDelegate* CreateNewWindowDelegate() = 0; + // Creates a media delegate. Shell takes ownership of the delegate. + virtual MediaDelegate* CreateMediaDelegate() = 0; + // Creates a user action client. Shell takes ownership of the object. virtual aura::client::UserActionClient* CreateUserActionClient() = 0; // Records that the user performed an action. virtual void RecordUserMetricsAction(UserMetricsAction action) = 0; - // Handles the Next Track Media shortcut key. - virtual void HandleMediaNextTrack() = 0; - - // Handles the Play/Pause Toggle Media shortcut key. - virtual void HandleMediaPlayPause() = 0; - - // Handles the Previous Track Media shortcut key. - virtual void HandleMediaPrevTrack() = 0; - // Creates a menu model of the context for the |root_window|. virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) = 0; diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index 5fde812..735ad60 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/media_delegate.h" #include "ash/new_window_delegate.h" #include "ash/session_state_delegate.h" #include "ash/shell.h" @@ -39,6 +40,13 @@ class NewWindowDelegateImpl : public NewWindowDelegate { virtual void OpenFeedbackPage() OVERRIDE {} }; +class MediaDelegateImpl : public MediaDelegate { + public: + virtual void HandleMediaNextTrack() OVERRIDE {} + virtual void HandleMediaPlayPause() OVERRIDE {} + virtual void HandleMediaPrevTrack() OVERRIDE {} +}; + } // namespace TestShellDelegate::TestShellDelegate() @@ -121,6 +129,10 @@ NewWindowDelegate* TestShellDelegate::CreateNewWindowDelegate() { return new NewWindowDelegateImpl; } +MediaDelegate* TestShellDelegate::CreateMediaDelegate() { + return new MediaDelegateImpl; +} + aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { return NULL; } @@ -128,15 +140,6 @@ aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { void TestShellDelegate::RecordUserMetricsAction(UserMetricsAction action) { } -void TestShellDelegate::HandleMediaNextTrack() { -} - -void TestShellDelegate::HandleMediaPlayPause() { -} - -void TestShellDelegate::HandleMediaPrevTrack() { -} - ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::Window* root) { return NULL; } diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index b241eb7..790163c 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -49,11 +49,9 @@ class TestShellDelegate : public ShellDelegate { virtual SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; virtual AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; + virtual MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual void RecordUserMetricsAction(UserMetricsAction action) OVERRIDE; - virtual void HandleMediaNextTrack() OVERRIDE; - virtual void HandleMediaPlayPause() OVERRIDE; - virtual void HandleMediaPrevTrack() OVERRIDE; virtual ui::MenuModel* CreateContextMenu(aura::Window* root) OVERRIDE; virtual RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE; virtual base::string16 GetProductName() const OVERRIDE; diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h index 6c048ea..43a087b 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.h +++ b/chrome/browser/ui/ash/chrome_shell_delegate.h @@ -55,11 +55,9 @@ class ChromeShellDelegate : public ash::ShellDelegate, virtual ash::SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; + virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual void RecordUserMetricsAction(ash::UserMetricsAction action) OVERRIDE; - virtual void HandleMediaNextTrack() OVERRIDE; - virtual void HandleMediaPlayPause() OVERRIDE; - virtual void HandleMediaPrevTrack() OVERRIDE; virtual ui::MenuModel* CreateContextMenu(aura::Window* root) OVERRIDE; virtual ash::RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE; virtual string16 GetProductName() const OVERRIDE; diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc index e6d31a5..d370383 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/ash/chrome_shell_delegate.h" #include "ash/accessibility_delegate.h" +#include "ash/media_delegate.h" #include "ash/wm/mru_window_tracker.h" #include "ash/wm/window_util.h" #include "base/command_line.h" @@ -145,6 +146,33 @@ class AccessibilityDelegateImpl : public ash::AccessibilityDelegate { DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); }; +class MediaDelegateImpl : public ash::MediaDelegate { + public: + MediaDelegateImpl() {} + virtual ~MediaDelegateImpl() {} + + virtual void HandleMediaNextTrack() OVERRIDE { + extensions::MediaPlayerAPI::Get( + ProfileManager::GetDefaultProfileOrOffTheRecord())-> + media_player_event_router()->NotifyNextTrack(); + } + + virtual void HandleMediaPlayPause() OVERRIDE { + extensions::MediaPlayerAPI::Get( + ProfileManager::GetDefaultProfileOrOffTheRecord())-> + media_player_event_router()->NotifyTogglePlayState(); + } + + virtual void HandleMediaPrevTrack() OVERRIDE { + extensions::MediaPlayerAPI::Get( + ProfileManager::GetDefaultProfileOrOffTheRecord())-> + media_player_event_router()->NotifyPrevTrack(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl); +}; + } // anonymous namespace bool ChromeShellDelegate::IsFirstRunAfterBoot() const { @@ -180,6 +208,10 @@ ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() { return new ChromeNewWindowDelegateChromeos; } +ash::MediaDelegate* ChromeShellDelegate::CreateMediaDelegate() { + return new MediaDelegateImpl; +} + ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { return chromeos::CreateSystemTrayDelegate(); } @@ -188,24 +220,6 @@ ash::UserWallpaperDelegate* ChromeShellDelegate::CreateUserWallpaperDelegate() { return chromeos::CreateUserWallpaperDelegate(); } -void ChromeShellDelegate::HandleMediaNextTrack() { - extensions::MediaPlayerAPI::Get( - ProfileManager::GetDefaultProfileOrOffTheRecord())-> - media_player_event_router()->NotifyNextTrack(); -} - -void ChromeShellDelegate::HandleMediaPlayPause() { - extensions::MediaPlayerAPI::Get( - ProfileManager::GetDefaultProfileOrOffTheRecord())-> - media_player_event_router()->NotifyTogglePlayState(); -} - -void ChromeShellDelegate::HandleMediaPrevTrack() { - extensions::MediaPlayerAPI::Get( - ProfileManager::GetDefaultProfileOrOffTheRecord())-> - media_player_event_router()->NotifyPrevTrack(); -} - void ChromeShellDelegate::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc index ccfe795..d22eedc 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc @@ -6,6 +6,7 @@ #include "ash/accessibility_delegate.h" #include "ash/magnifier/magnifier_constants.h" +#include "ash/media_delegate.h" #include "ash/system/tray/default_system_tray_delegate.h" #include "ash/wm/window_util.h" #include "base/command_line.h" @@ -47,6 +48,18 @@ class NewWindowDelegateImpl : public ChromeNewWindowDelegate { DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl); }; +class MediaDelegateImpl : public ash::MediaDelegate { + public: + MediaDelegateImpl() {} + virtual ~MediaDelegateImpl() {} + virtual void HandleMediaNextTrack() OVERRIDE {} + virtual void HandleMediaPlayPause() OVERRIDE {} + virtual void HandleMediaPrevTrack() OVERRIDE {} + + private: + DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl); +}; + class EmptyAccessibilityDelegate : public ash::AccessibilityDelegate { public: EmptyAccessibilityDelegate() {} @@ -129,6 +142,10 @@ ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() { return new NewWindowDelegateImpl; } +ash::MediaDelegate* ChromeShellDelegate::CreateMediaDelegate() { + return new MediaDelegateImpl; +} + ash::CapsLockDelegate* ChromeShellDelegate::CreateCapsLockDelegate() { return new CapsLockDelegate(); } @@ -157,15 +174,6 @@ ash::UserWallpaperDelegate* ChromeShellDelegate::CreateUserWallpaperDelegate() { #endif } -void ChromeShellDelegate::HandleMediaNextTrack() { -} - -void ChromeShellDelegate::HandleMediaPlayPause() { -} - -void ChromeShellDelegate::HandleMediaPrevTrack() { -} - void ChromeShellDelegate::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { |