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

Side by Side 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, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <functional> 5 #include <functional>
6 6
7 #include "chrome/browser/tab_contents/render_view_context_menu.h" 7 #include "chrome/browser/tab_contents/render_view_context_menu.h"
8 8
9 #include "app/clipboard/clipboard.h" 9 #include "app/clipboard/clipboard.h"
10 #include "app/clipboard/scoped_clipboard_writer.h" 10 #include "app/clipboard/scoped_clipboard_writer.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 388 }
389 389
390 if (media_flags & WebContextMenuData::MediaMuted) { 390 if (media_flags & WebContextMenuData::MediaMuted) {
391 AppendMenuItem(IDS_CONTENT_CONTEXT_UNMUTE); 391 AppendMenuItem(IDS_CONTENT_CONTEXT_UNMUTE);
392 } else { 392 } else {
393 AppendMenuItem(IDS_CONTENT_CONTEXT_MUTE); 393 AppendMenuItem(IDS_CONTENT_CONTEXT_MUTE);
394 } 394 }
395 395
396 AppendCheckboxMenuItem(IDS_CONTENT_CONTEXT_LOOP, 396 AppendCheckboxMenuItem(IDS_CONTENT_CONTEXT_LOOP,
397 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_LOOP)); 397 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_LOOP));
398
399 AppendCheckboxMenuItem(IDS_CONTENT_CONTEXT_CONTROLS,
400 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_CONTROLS));
398 } 401 }
399 402
400 void RenderViewContextMenu::AppendPageItems() { 403 void RenderViewContextMenu::AppendPageItems() {
401 AppendMenuItem(IDS_CONTENT_CONTEXT_BACK); 404 AppendMenuItem(IDS_CONTENT_CONTEXT_BACK);
402 AppendMenuItem(IDS_CONTENT_CONTEXT_FORWARD); 405 AppendMenuItem(IDS_CONTENT_CONTEXT_FORWARD);
403 AppendMenuItem(IDS_CONTENT_CONTEXT_RELOAD); 406 AppendMenuItem(IDS_CONTENT_CONTEXT_RELOAD);
404 AppendSeparator(); 407 AppendSeparator();
405 AppendMenuItem(IDS_CONTENT_CONTEXT_SAVEPAGEAS); 408 AppendMenuItem(IDS_CONTENT_CONTEXT_SAVEPAGEAS);
406 AppendMenuItem(IDS_CONTENT_CONTEXT_PRINT); 409 AppendMenuItem(IDS_CONTENT_CONTEXT_PRINT);
407 if (TranslationService::IsTranslationEnabled() || 410 if (TranslationService::IsTranslationEnabled() ||
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 WebContextMenuData::MediaInError) == 0; 677 WebContextMenuData::MediaInError) == 0;
675 678
676 // Mute and unmute should also be disabled if the player has no audio. 679 // Mute and unmute should also be disabled if the player has no audio.
677 case IDS_CONTENT_CONTEXT_MUTE: 680 case IDS_CONTENT_CONTEXT_MUTE:
678 case IDS_CONTENT_CONTEXT_UNMUTE: 681 case IDS_CONTENT_CONTEXT_UNMUTE:
679 return (params_.media_flags & 682 return (params_.media_flags &
680 WebContextMenuData::MediaHasAudio) != 0 && 683 WebContextMenuData::MediaHasAudio) != 0 &&
681 (params_.media_flags & 684 (params_.media_flags &
682 WebContextMenuData::MediaInError) == 0; 685 WebContextMenuData::MediaInError) == 0;
683 686
687 // Media controls can be toggled only for video player. If we toggle
688 // controls for audio then the player disappears, and there is no way to
689 // return it back.
690 case IDS_CONTENT_CONTEXT_CONTROLS:
691 return (params_.media_flags &
692 WebContextMenuData::MediaHasVideo) != 0;
693
684 case IDS_CONTENT_CONTEXT_SAVESCREENSHOTAS: 694 case IDS_CONTENT_CONTEXT_SAVESCREENSHOTAS:
685 // TODO(ajwong): Enable save screenshot after we actually implement 695 // TODO(ajwong): Enable save screenshot after we actually implement
686 // this. 696 // this.
687 return false; 697 return false;
688 698
689 case IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION: 699 case IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION:
690 case IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION: 700 case IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION:
691 case IDS_CONTENT_CONTEXT_COPYIMAGELOCATION: 701 case IDS_CONTENT_CONTEXT_COPYIMAGELOCATION:
692 return params_.src_url.is_valid(); 702 return params_.src_url.is_valid();
693 703
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } 814 }
805 } 815 }
806 816
807 bool RenderViewContextMenu::ItemIsChecked(int id) const { 817 bool RenderViewContextMenu::ItemIsChecked(int id) const {
808 // See if the video is set to looping. 818 // See if the video is set to looping.
809 if (id == IDS_CONTENT_CONTEXT_LOOP) { 819 if (id == IDS_CONTENT_CONTEXT_LOOP) {
810 return (params_.media_flags & 820 return (params_.media_flags &
811 WebContextMenuData::MediaLoop) != 0; 821 WebContextMenuData::MediaLoop) != 0;
812 } 822 }
813 823
824 if (id == IDS_CONTENT_CONTEXT_CONTROLS) {
825 return (params_.media_flags &
826 WebContextMenuData::MediaControls) != 0;
827 }
828
814 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 829 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
815 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 830 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
816 ExtensionMenuItem* item = GetExtensionMenuItem(id); 831 ExtensionMenuItem* item = GetExtensionMenuItem(id);
817 if (item) 832 if (item)
818 return item->checked(); 833 return item->checked();
819 else 834 else
820 return false; 835 return false;
821 } 836 }
822 837
823 #if defined(OS_MACOSX) 838 #if defined(OS_MACOSX)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 989
975 case IDS_CONTENT_CONTEXT_LOOP: 990 case IDS_CONTENT_CONTEXT_LOOP:
976 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Loop"), 991 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Loop"),
977 profile_); 992 profile_);
978 MediaPlayerActionAt(gfx::Point(params_.x, params_.y), 993 MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
979 WebMediaPlayerAction( 994 WebMediaPlayerAction(
980 WebMediaPlayerAction::Loop, 995 WebMediaPlayerAction::Loop,
981 !ItemIsChecked(IDS_CONTENT_CONTEXT_LOOP))); 996 !ItemIsChecked(IDS_CONTENT_CONTEXT_LOOP)));
982 break; 997 break;
983 998
999 case IDS_CONTENT_CONTEXT_CONTROLS:
1000 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Controls"),
1001 profile_);
1002 MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
1003 WebMediaPlayerAction(
1004 WebMediaPlayerAction::Controls,
1005 !ItemIsChecked(IDS_CONTENT_CONTEXT_CONTROLS)));
1006 break;
1007
984 case IDS_CONTENT_CONTEXT_BACK: 1008 case IDS_CONTENT_CONTEXT_BACK:
985 source_tab_contents_->controller().GoBack(); 1009 source_tab_contents_->controller().GoBack();
986 break; 1010 break;
987 1011
988 case IDS_CONTENT_CONTEXT_FORWARD: 1012 case IDS_CONTENT_CONTEXT_FORWARD:
989 source_tab_contents_->controller().GoForward(); 1013 source_tab_contents_->controller().GoForward();
990 break; 1014 break;
991 1015
992 case IDS_CONTENT_CONTEXT_SAVEPAGEAS: 1016 case IDS_CONTENT_CONTEXT_SAVEPAGEAS:
993 source_tab_contents_->OnSavePage(); 1017 source_tab_contents_->OnSavePage();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1283 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1260 g_browser_process->clipboard()); 1284 g_browser_process->clipboard());
1261 } 1285 }
1262 1286
1263 void RenderViewContextMenu::MediaPlayerActionAt( 1287 void RenderViewContextMenu::MediaPlayerActionAt(
1264 const gfx::Point& location, 1288 const gfx::Point& location,
1265 const WebMediaPlayerAction& action) { 1289 const WebMediaPlayerAction& action) {
1266 source_tab_contents_->render_view_host()->MediaPlayerActionAt( 1290 source_tab_contents_->render_view_host()->MediaPlayerActionAt(
1267 location, action); 1291 location, action);
1268 } 1292 }
OLDNEW
« 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