Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 1589003: Added item to Show/Hide video controls in the context menu for <video>. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/render_view_context_menu.cc
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 7cf0c86ec16d8e87acb7ce2528f2fcca036021f0..da20bec345bff2a3942cc9075a23b4031e234b25 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -395,6 +395,9 @@ void RenderViewContextMenu::AppendMediaItems() {
AppendCheckboxMenuItem(IDS_CONTENT_CONTEXT_LOOP,
l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_LOOP));
+
+ AppendCheckboxMenuItem(IDS_CONTENT_CONTEXT_CONTROLS,
+ l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_CONTROLS));
}
void RenderViewContextMenu::AppendPageItems() {
@@ -681,6 +684,13 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const {
(params_.media_flags &
WebContextMenuData::MediaInError) == 0;
+ // Media controls can be toggled only for video player. If we toggle
+ // controls for audio then the player disappears, and there is no way to
+ // return it back.
+ case IDS_CONTENT_CONTEXT_CONTROLS:
+ return (params_.media_flags &
+ WebContextMenuData::MediaHasVideo) != 0;
+
case IDS_CONTENT_CONTEXT_SAVESCREENSHOTAS:
// TODO(ajwong): Enable save screenshot after we actually implement
// this.
@@ -811,6 +821,11 @@ bool RenderViewContextMenu::ItemIsChecked(int id) const {
WebContextMenuData::MediaLoop) != 0;
}
+ if (id == IDS_CONTENT_CONTEXT_CONTROLS) {
+ return (params_.media_flags &
+ WebContextMenuData::MediaControls) != 0;
+ }
+
if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
ExtensionMenuItem* item = GetExtensionMenuItem(id);
@@ -981,6 +996,15 @@ void RenderViewContextMenu::ExecuteItemCommand(int id) {
!ItemIsChecked(IDS_CONTENT_CONTEXT_LOOP)));
break;
+ case IDS_CONTENT_CONTEXT_CONTROLS:
+ UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Controls"),
+ profile_);
+ MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
+ WebMediaPlayerAction(
+ WebMediaPlayerAction::Controls,
+ !ItemIsChecked(IDS_CONTENT_CONTEXT_CONTROLS)));
+ break;
+
case IDS_CONTENT_CONTEXT_BACK:
source_tab_contents_->controller().GoBack();
break;
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698