summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsschmitz@chromium.org <sschmitz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-27 17:38:00 +0000
committersschmitz@chromium.org <sschmitz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-27 17:38:00 +0000
commite54e8193d26424fd4d31cbae3871158056403f82 (patch)
treeb015bec46abf46a9c2b2f7ce0294db7c804b897e
parent79ec9aa6e75cd375b2010a938d61f33d214ebc03 (diff)
downloadchromium_src-e54e8193d26424fd4d31cbae3871158056403f82.zip
chromium_src-e54e8193d26424fd4d31cbae3871158056403f82.tar.gz
chromium_src-e54e8193d26424fd4d31cbae3871158056403f82.tar.bz2
Ash: Support "Next Song", "Previous Song", "Play/Pause" Multi Media buttons
in our Media Player that is part of the File Manager right now. Added shortcut handlers and plumbing to the Audio and Video player of the Ash File Manager. see also: http://code.google.com/p/chromium/issues/detail?id=123739#c17 BUG=138745 TEST=Attach an (Wired USB) Apple keyboard or Windows Natural keyboard to a Chromebook. Either download three mp3 and an mp4 file to your chromebook or navigate to a Google Drive folder that has these. Bring up File Manager from the Launcher and click on an mp3. Press the Previous Track, Play/Pause, Next Track keys on the MAC keyboard and observe same behavior as clicking the corresponding Audio Control buttons on the screen. Click on an mp4 and press the Play/Pause key and observe same behavior as clicking Play/Pause button on the screen. Repeat for Windows Natural keyboard with the Play/Pause key. (Note it does not have any prev./next track keys.) PS: The Goldtouch USB keyboard works as well. The media keys require holding done the "Fn" key and F1, F2, or F3. Review URL: https://chromiumcodereview.appspot.com/10823439 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153502 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/accelerators/accelerator_controller.cc21
-rw-r--r--ash/accelerators/accelerator_table.cc7
-rw-r--r--ash/accelerators/accelerator_table.h3
-rw-r--r--ash/shell/shell_delegate_impl.cc9
-rw-r--r--ash/shell/shell_delegate_impl.h3
-rw-r--r--ash/shell_delegate.h9
-rw-r--r--ash/test/test_shell_delegate.cc9
-rw-r--r--ash/test/test_shell_delegate.h3
-rw-r--r--chrome/browser/chromeos/extensions/media_player_event_router.cc26
-rw-r--r--chrome/browser/chromeos/extensions/media_player_event_router.h10
-rw-r--r--chrome/browser/resources/file_manager/js/media/media_controls.js12
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.cc19
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.h3
-rw-r--r--chrome/common/extensions/api/media_player_private.json18
14 files changed, 150 insertions, 2 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 8948851..a33b0e4 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -241,6 +241,21 @@ bool HandleMagnifyScreen(int delta_index) {
return true;
}
+bool HandleMediaNextTrack() {
+ Shell::GetInstance()->delegate()->HandleMediaNextTrack();
+ return true;
+}
+
+bool HandleMediaPlayPause() {
+ Shell::GetInstance()->delegate()->HandleMediaPlayPause();
+ return true;
+}
+
+bool HandleMediaPrevTrack() {
+ Shell::GetInstance()->delegate()->HandleMediaPrevTrack();
+ return true;
+}
+
#if !defined(NDEBUG)
bool HandlePrintLayerHierarchy() {
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
@@ -663,6 +678,12 @@ bool AcceleratorController::PerformAction(int action,
return HandleMagnifyScreen(1);
case MAGNIFY_SCREEN_ZOOM_OUT:
return HandleMagnifyScreen(-1);
+ case MEDIA_NEXT_TRACK:
+ return HandleMediaNextTrack();
+ case MEDIA_PLAY_PAUSE:
+ return HandleMediaPlayPause();
+ case MEDIA_PREV_TRACK:
+ return HandleMediaPrevTrack();
#if !defined(NDEBUG)
case PRINT_LAYER_HIERARCHY:
return HandlePrintLayerHierarchy();
diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc
index 5a53ec5..b998083 100644
--- a/ash/accelerators/accelerator_table.cc
+++ b/ash/accelerators/accelerator_table.cc
@@ -125,7 +125,12 @@ const AcceleratorData kAcceleratorData[] = {
{ true, ui::VKEY_F2, ui::EF_CONTROL_DOWN, FOCUS_NEXT_PANE },
{ true, ui::VKEY_F1, ui::EF_CONTROL_DOWN, FOCUS_PREVIOUS_PANE },
- // TODO(yusukes): Handle VKEY_MEDIA_STOP, VKEY_MEDIA_PLAY_PAUSE, and
+ // Media Player shortcuts.
+ { true, ui::VKEY_MEDIA_NEXT_TRACK, ui::EF_NONE, MEDIA_NEXT_TRACK},
+ { true, ui::VKEY_MEDIA_PLAY_PAUSE, ui::EF_NONE, MEDIA_PLAY_PAUSE},
+ { true, ui::VKEY_MEDIA_PREV_TRACK, ui::EF_NONE, MEDIA_PREV_TRACK},
+
+ // TODO(yusukes): Handle VKEY_MEDIA_STOP, and
// VKEY_MEDIA_LAUNCH_MAIL.
};
diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h
index a599460..9687acb 100644
--- a/ash/accelerators/accelerator_table.h
+++ b/ash/accelerators/accelerator_table.h
@@ -32,6 +32,9 @@ enum AcceleratorAction {
KEYBOARD_BRIGHTNESS_UP,
MAGNIFY_SCREEN_ZOOM_IN,
MAGNIFY_SCREEN_ZOOM_OUT,
+ MEDIA_NEXT_TRACK,
+ MEDIA_PLAY_PAUSE,
+ MEDIA_PREV_TRACK,
NEW_INCOGNITO_WINDOW,
NEW_TAB,
NEW_WINDOW,
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 383218d..b7457e6 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -133,5 +133,14 @@ void ShellDelegateImpl::OpenFeedbackPage() {
void ShellDelegateImpl::RecordUserMetricsAction(UserMetricsAction action) {
}
+void ShellDelegateImpl::HandleMediaNextTrack() {
+}
+
+void ShellDelegateImpl::HandleMediaPlayPause() {
+}
+
+void ShellDelegateImpl::HandleMediaPrevTrack() {
+}
+
} // namespace shell
} // namespace ash
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index 55880f3..9078ed7 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -49,6 +49,9 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;
virtual void OpenFeedbackPage() OVERRIDE;
virtual void RecordUserMetricsAction(UserMetricsAction action) OVERRIDE;
+ virtual void HandleMediaNextTrack() OVERRIDE;
+ virtual void HandleMediaPlayPause() OVERRIDE;
+ virtual void HandleMediaPrevTrack() OVERRIDE;
private:
// Used to update Launcher. Owned by main.
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index 8029e1b..7b7d097 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -137,6 +137,15 @@ class ASH_EXPORT ShellDelegate {
// 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;
};
} // namespace ash
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 090d14a..3ecb75a 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -118,5 +118,14 @@ void TestShellDelegate::OpenFeedbackPage() {
void TestShellDelegate::RecordUserMetricsAction(UserMetricsAction action) {
}
+void TestShellDelegate::HandleMediaNextTrack() {
+}
+
+void TestShellDelegate::HandleMediaPlayPause() {
+}
+
+void TestShellDelegate::HandleMediaPrevTrack() {
+}
+
} // namespace test
} // namespace ash
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 88b8616..7b4d2ea 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -44,6 +44,9 @@ class TestShellDelegate : public ShellDelegate {
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;
virtual void OpenFeedbackPage() OVERRIDE;
virtual void RecordUserMetricsAction(UserMetricsAction action) OVERRIDE;
+ virtual void HandleMediaNextTrack() OVERRIDE;
+ virtual void HandleMediaPlayPause() OVERRIDE;
+ virtual void HandleMediaPrevTrack() OVERRIDE;
private:
bool locked_;
diff --git a/chrome/browser/chromeos/extensions/media_player_event_router.cc b/chrome/browser/chromeos/extensions/media_player_event_router.cc
index 9d3fbc6..c8aa4e8 100644
--- a/chrome/browser/chromeos/extensions/media_player_event_router.cc
+++ b/chrome/browser/chromeos/extensions/media_player_event_router.cc
@@ -21,10 +21,34 @@ void ExtensionMediaPlayerEventRouter::Init(Profile* profile) {
profile_ = profile;
}
+void ExtensionMediaPlayerEventRouter::NotifyNextTrack() {
+ if (profile_ && profile_->GetExtensionEventRouter()) {
+ scoped_ptr<ListValue> args(new ListValue());
+ profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
+ "mediaPlayerPrivate.onNextTrack", args.Pass(), NULL, GURL());
+ }
+}
+
void ExtensionMediaPlayerEventRouter::NotifyPlaylistChanged() {
if (profile_ && profile_->GetExtensionEventRouter()) {
scoped_ptr<ListValue> args(new ListValue());
profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
- "mediaPlayerPrivate.onPlaylistChanged", args.Pass(), NULL, GURL());
+ "mediaPlayerPrivate.onPlaylistChanged", args.Pass(), NULL, GURL());
+ }
+}
+
+void ExtensionMediaPlayerEventRouter::NotifyPrevTrack() {
+ if (profile_ && profile_->GetExtensionEventRouter()) {
+ scoped_ptr<ListValue> args(new ListValue());
+ profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
+ "mediaPlayerPrivate.onPrevTrack", args.Pass(), NULL, GURL());
+ }
+}
+
+void ExtensionMediaPlayerEventRouter::NotifyTogglePlayState() {
+ if (profile_ && profile_->GetExtensionEventRouter()) {
+ scoped_ptr<ListValue> args(new ListValue());
+ profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
+ "mediaPlayerPrivate.onTogglePlayState", args.Pass(), NULL, GURL());
}
}
diff --git a/chrome/browser/chromeos/extensions/media_player_event_router.h b/chrome/browser/chromeos/extensions/media_player_event_router.h
index aaaafb1..6fb76ef 100644
--- a/chrome/browser/chromeos/extensions/media_player_event_router.h
+++ b/chrome/browser/chromeos/extensions/media_player_event_router.h
@@ -17,8 +17,18 @@ class ExtensionMediaPlayerEventRouter {
void Init(Profile* profile);
+ // Send notification that next-track shortcut key was pressed.
+ void NotifyNextTrack();
+
+ // Send notification that playlist changed.
void NotifyPlaylistChanged();
+ // Send notification that previous-track shortcut key was pressed.
+ void NotifyPrevTrack();
+
+ // Send notification that play/pause shortcut key was pressed.
+ void NotifyTogglePlayState();
+
private:
Profile* profile_;
diff --git a/chrome/browser/resources/file_manager/js/media/media_controls.js b/chrome/browser/resources/file_manager/js/media/media_controls.js
index 75923b9..20ca98f 100644
--- a/chrome/browser/resources/file_manager/js/media/media_controls.js
+++ b/chrome/browser/resources/file_manager/js/media/media_controls.js
@@ -858,6 +858,10 @@ function VideoControls(containerElement, onMediaError,
'VideoResumePosition',
VideoControls.RESUME_POSITIONS_CAPACITY,
VideoControls.RESUME_POSITION_LIFETIME);
+
+ var video_controls = this;
+ chrome.mediaPlayerPrivate.onTogglePlayState.addListener(
+ function() { video_controls.togglePlayStateWithFeedback(); });
}
/**
@@ -1139,6 +1143,14 @@ function AudioControls(container, advanceTrack, onError) {
/* No volume controls */
this.createButton('previous', this.onAdvanceClick_.bind(this, false));
this.createButton('next', this.onAdvanceClick_.bind(this, true));
+
+ var audio_controls = this;
+ chrome.mediaPlayerPrivate.onNextTrack.addListener(
+ function() { audio_controls.onAdvanceClick_(true); });
+ chrome.mediaPlayerPrivate.onPrevTrack.addListener(
+ function() { audio_controls.onAdvanceClick_(false); });
+ chrome.mediaPlayerPrivate.onTogglePlayState.addListener(
+ function() { audio_controls.togglePlayState(); });
}
AudioControls.prototype = { __proto__: MediaControls.prototype };
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc
index 2857d27..dc15114 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc
@@ -40,6 +40,7 @@
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h"
#include "chrome/browser/chromeos/extensions/file_manager_util.h"
+#include "chrome/browser/chromeos/extensions/media_player_event_router.h"
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/webui_login_display_host.h"
@@ -366,6 +367,24 @@ void ChromeShellDelegate::RecordUserMetricsAction(
}
}
+void ChromeShellDelegate::HandleMediaNextTrack() {
+#if defined(OS_CHROMEOS)
+ ExtensionMediaPlayerEventRouter::GetInstance()->NotifyNextTrack();
+#endif
+}
+
+void ChromeShellDelegate::HandleMediaPlayPause() {
+#if defined(OS_CHROMEOS)
+ ExtensionMediaPlayerEventRouter::GetInstance()->NotifyTogglePlayState();
+#endif
+}
+
+void ChromeShellDelegate::HandleMediaPrevTrack() {
+#if defined(OS_CHROMEOS)
+ ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPrevTrack();
+#endif
+}
+
void ChromeShellDelegate::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h
index 32b5525..2090bb1 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.h
@@ -62,6 +62,9 @@ class ChromeShellDelegate : public ash::ShellDelegate,
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;
+ virtual void HandleMediaPrevTrack() OVERRIDE;
// content::NotificationObserver override:
virtual void Observe(int type,
diff --git a/chrome/common/extensions/api/media_player_private.json b/chrome/common/extensions/api/media_player_private.json
index fef30a0..5d77ab9 100644
--- a/chrome/common/extensions/api/media_player_private.json
+++ b/chrome/common/extensions/api/media_player_private.json
@@ -81,10 +81,28 @@
],
"events": [
{
+ "name": "onNextTrack",
+ "type": "function",
+ "description": "Notifies that the next track was requested.",
+ "parameters": []
+ },
+ {
"name": "onPlaylistChanged",
"type": "function",
"description": "Notifies that playlist content or state has been changed. Data could be retrieved via 'getPlaylist'.",
"parameters": []
+ },
+ {
+ "name": "onPrevTrack",
+ "type": "function",
+ "description": "Notifies that the previous tack was requested.",
+ "parameters": []
+ },
+ {
+ "name": "onTogglePlayState",
+ "type": "function",
+ "description": "Notifies that a play/pause toggle was requested.",
+ "parameters": []
}
]
}