| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 470 |
| 471 void RenderViewContextMenu::AppendVideoItems() { | 471 void RenderViewContextMenu::AppendVideoItems() { |
| 472 AppendMediaItems(); | 472 AppendMediaItems(); |
| 473 menu_model_.AddSeparator(); | 473 menu_model_.AddSeparator(); |
| 474 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, | 474 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, |
| 475 IDS_CONTENT_CONTEXT_SAVEVIDEOAS); | 475 IDS_CONTENT_CONTEXT_SAVEVIDEOAS); |
| 476 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, | 476 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, |
| 477 IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION); | 477 IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION); |
| 478 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, | 478 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, |
| 479 IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB); | 479 IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB); |
| 480 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 481 switches::kEnableVideoFullscreen)) { |
| 482 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_FULLSCREEN, |
| 483 IDS_CONTENT_CONTEXT_FULLSCREEN); |
| 484 } |
| 480 } | 485 } |
| 481 | 486 |
| 482 void RenderViewContextMenu::AppendMediaItems() { | 487 void RenderViewContextMenu::AppendMediaItems() { |
| 483 int media_flags = params_.media_flags; | 488 int media_flags = params_.media_flags; |
| 484 | 489 |
| 485 menu_model_.AddItemWithStringId( | 490 menu_model_.AddItemWithStringId( |
| 486 IDC_CONTENT_CONTEXT_PLAYPAUSE, | 491 IDC_CONTENT_CONTEXT_PLAYPAUSE, |
| 487 media_flags & WebContextMenuData::MediaPaused ? | 492 media_flags & WebContextMenuData::MediaPaused ? |
| 488 IDS_CONTENT_CONTEXT_PLAY : | 493 IDS_CONTENT_CONTEXT_PLAY : |
| 489 IDS_CONTENT_CONTEXT_PAUSE); | 494 IDS_CONTENT_CONTEXT_PAUSE); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 | 850 |
| 846 case IDC_CONTENT_CONTEXT_SAVEAVAS: | 851 case IDC_CONTENT_CONTEXT_SAVEAVAS: |
| 847 return (params_.media_flags & | 852 return (params_.media_flags & |
| 848 WebContextMenuData::MediaCanSave) && | 853 WebContextMenuData::MediaCanSave) && |
| 849 params_.src_url.is_valid() && | 854 params_.src_url.is_valid() && |
| 850 URLRequest::IsHandledURL(params_.src_url); | 855 URLRequest::IsHandledURL(params_.src_url); |
| 851 | 856 |
| 852 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: | 857 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: |
| 853 return true; | 858 return true; |
| 854 | 859 |
| 860 case IDC_CONTENT_CONTEXT_FULLSCREEN: |
| 861 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 862 switches::kEnableVideoFullscreen); |
| 863 |
| 855 case IDC_SAVE_PAGE: { | 864 case IDC_SAVE_PAGE: { |
| 856 // Instead of using GetURL here, we use url() (which is the "real" url of | 865 // Instead of using GetURL here, we use url() (which is the "real" url of |
| 857 // the page) from the NavigationEntry because its reflects their origin | 866 // the page) from the NavigationEntry because its reflects their origin |
| 858 // rather than the display one (returned by GetURL) which may be | 867 // rather than the display one (returned by GetURL) which may be |
| 859 // different (like having "view-source:" on the front). | 868 // different (like having "view-source:" on the front). |
| 860 NavigationEntry* active_entry = | 869 NavigationEntry* active_entry = |
| 861 source_tab_contents_->controller().GetActiveEntry(); | 870 source_tab_contents_->controller().GetActiveEntry(); |
| 862 return SavePackage::IsSavableURL( | 871 return SavePackage::IsSavableURL( |
| 863 (active_entry) ? active_entry->url() : GURL()); | 872 (active_entry) ? active_entry->url() : GURL()); |
| 864 } | 873 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 | 1091 |
| 1083 case IDC_CONTENT_CONTEXT_COPYIMAGE: | 1092 case IDC_CONTENT_CONTEXT_COPYIMAGE: |
| 1084 CopyImageAt(params_.x, params_.y); | 1093 CopyImageAt(params_.x, params_.y); |
| 1085 break; | 1094 break; |
| 1086 | 1095 |
| 1087 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: | 1096 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: |
| 1088 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: | 1097 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: |
| 1089 OpenURL(params_.src_url, NEW_BACKGROUND_TAB, PageTransition::LINK); | 1098 OpenURL(params_.src_url, NEW_BACKGROUND_TAB, PageTransition::LINK); |
| 1090 break; | 1099 break; |
| 1091 | 1100 |
| 1101 case IDC_CONTENT_CONTEXT_FULLSCREEN: |
| 1102 UserMetrics::RecordAction( |
| 1103 UserMetricsAction("MediaContextMenu_Fullscreen"), |
| 1104 profile_); |
| 1105 MediaPlayerActionAt( |
| 1106 gfx::Point(params_.x, params_.y), |
| 1107 WebMediaPlayerAction(WebMediaPlayerAction::Fullscreen, true)); |
| 1108 break; |
| 1109 |
| 1092 case IDC_CONTENT_CONTEXT_PLAYPAUSE: { | 1110 case IDC_CONTENT_CONTEXT_PLAYPAUSE: { |
| 1093 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused); | 1111 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused); |
| 1094 if (play) { | 1112 if (play) { |
| 1095 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Play"), | 1113 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Play"), |
| 1096 profile_); | 1114 profile_); |
| 1097 } else { | 1115 } else { |
| 1098 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Pause"), | 1116 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Pause"), |
| 1099 profile_); | 1117 profile_); |
| 1100 } | 1118 } |
| 1101 MediaPlayerActionAt(gfx::Point(params_.x, params_.y), | 1119 MediaPlayerActionAt(gfx::Point(params_.x, params_.y), |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), | 1430 UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), |
| 1413 g_browser_process->clipboard()); | 1431 g_browser_process->clipboard()); |
| 1414 } | 1432 } |
| 1415 | 1433 |
| 1416 void RenderViewContextMenu::MediaPlayerActionAt( | 1434 void RenderViewContextMenu::MediaPlayerActionAt( |
| 1417 const gfx::Point& location, | 1435 const gfx::Point& location, |
| 1418 const WebMediaPlayerAction& action) { | 1436 const WebMediaPlayerAction& action) { |
| 1419 source_tab_contents_->render_view_host()->MediaPlayerActionAt( | 1437 source_tab_contents_->render_view_host()->MediaPlayerActionAt( |
| 1420 location, action); | 1438 location, action); |
| 1421 } | 1439 } |
| OLD | NEW |