Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/tab_contents/render_view_context_menu.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); | 858 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); |
| 859 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, | 859 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, |
| 860 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); | 860 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); |
| 861 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, | 861 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, |
| 862 IDS_CONTENT_CONTEXT_COPYIMAGE); | 862 IDS_CONTENT_CONTEXT_COPYIMAGE); |
| 863 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, | 863 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, |
| 864 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); | 864 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); |
| 865 const TemplateURL* const default_provider = | 865 const TemplateURL* const default_provider = |
| 866 TemplateURLServiceFactory::GetForProfile(profile_)-> | 866 TemplateURLServiceFactory::GetForProfile(profile_)-> |
| 867 GetDefaultSearchProvider(); | 867 GetDefaultSearchProvider(); |
| 868 if (default_provider && !default_provider->image_url().empty() && | 868 if (params_.has_image_contents && default_provider && |
| 869 !default_provider->image_url().empty() && | |
| 869 default_provider->image_url_ref().IsValid()) { | 870 default_provider->image_url_ref().IsValid()) { |
| 870 menu_model_.AddItem( | 871 menu_model_.AddItem( |
| 871 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, | 872 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, |
| 872 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, | 873 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, |
| 873 default_provider->short_name())); | 874 default_provider->short_name())); |
| 874 } | 875 } |
| 875 AppendPrintItem(); | 876 AppendPrintItem(); |
| 876 } | 877 } |
| 877 | 878 |
| 878 void RenderViewContextMenu::AppendAudioItems() { | 879 void RenderViewContextMenu::AppendAudioItems() { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1283 // The images shown in the most visited thumbnails can't be opened or | 1284 // The images shown in the most visited thumbnails can't be opened or |
| 1284 // searched for conventionally. | 1285 // searched for conventionally. |
| 1285 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: | 1286 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: |
| 1286 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: | 1287 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: |
| 1287 return params_.src_url.is_valid() && | 1288 return params_.src_url.is_valid() && |
| 1288 (params_.src_url.scheme() != chrome::kChromeUIScheme); | 1289 (params_.src_url.scheme() != chrome::kChromeUIScheme); |
| 1289 | 1290 |
| 1290 case IDC_CONTENT_CONTEXT_COPYIMAGE: | 1291 case IDC_CONTENT_CONTEXT_COPYIMAGE: |
| 1291 return !params_.is_image_blocked; | 1292 return params_.has_image_contents; |
| 1292 | 1293 |
| 1293 // Media control commands should all be disabled if the player is in an | 1294 // Media control commands should all be disabled if the player is in an |
| 1294 // error state. | 1295 // error state. |
| 1295 case IDC_CONTENT_CONTEXT_PLAYPAUSE: | 1296 case IDC_CONTENT_CONTEXT_PLAYPAUSE: |
| 1296 case IDC_CONTENT_CONTEXT_LOOP: | 1297 case IDC_CONTENT_CONTEXT_LOOP: |
| 1297 return (params_.media_flags & | 1298 return (params_.media_flags & |
| 1298 WebContextMenuData::MediaInError) == 0; | 1299 WebContextMenuData::MediaInError) == 0; |
| 1299 | 1300 |
| 1300 // Mute and unmute should also be disabled if the player has no audio. | 1301 // Mute and unmute should also be disabled if the player has no audio. |
| 1301 case IDC_CONTENT_CONTEXT_MUTE: | 1302 case IDC_CONTENT_CONTEXT_MUTE: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1356 PrefService* local_state = g_browser_process->local_state(); | 1357 PrefService* local_state = g_browser_process->local_state(); |
| 1357 DCHECK(local_state); | 1358 DCHECK(local_state); |
| 1358 // Test if file-selection dialogs are forbidden by policy. | 1359 // Test if file-selection dialogs are forbidden by policy. |
| 1359 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1360 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 1360 return false; | 1361 return false; |
| 1361 | 1362 |
| 1362 // Instead of using GetURL here, we use url() (which is the "real" url of | 1363 // Instead of using GetURL here, we use url() (which is the "real" url of |
| 1363 // the page) from the NavigationEntry because its reflects their origin | 1364 // the page) from the NavigationEntry because its reflects their origin |
| 1364 // rather than the display one (returned by GetURL) which may be | 1365 // rather than the display one (returned by GetURL) which may be |
| 1365 // different (like having "view-source:" on the front). | 1366 // different (like having "view-source:" on the front). |
| 1366 // TODO(nasko): Audit all GetActiveEntry calls in this file. | |
| 1367 NavigationEntry* active_entry = | 1367 NavigationEntry* active_entry = |
| 1368 source_web_contents_->GetController().GetActiveEntry(); | 1368 source_web_contents_->GetController().GetActiveEntry(); |
| 1369 return content::IsSavableURL( | 1369 return content::IsSavableURL( |
| 1370 (active_entry) ? active_entry->GetURL() : GURL()); | 1370 (active_entry) ? active_entry->GetURL() : GURL()); |
| 1371 } | 1371 } |
| 1372 | 1372 |
| 1373 case IDC_CONTENT_CONTEXT_RELOADFRAME: | 1373 case IDC_CONTENT_CONTEXT_RELOADFRAME: |
| 1374 return params_.frame_url.is_valid(); | 1374 return params_.frame_url.is_valid(); |
| 1375 | 1375 |
| 1376 case IDC_CONTENT_CONTEXT_UNDO: | 1376 case IDC_CONTENT_CONTEXT_UNDO: |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1790 DCHECK(platform_app); | 1790 DCHECK(platform_app); |
| 1791 DCHECK(platform_app->is_platform_app()); | 1791 DCHECK(platform_app->is_platform_app()); |
| 1792 | 1792 |
| 1793 extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 1793 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
| 1794 InspectBackgroundPage(platform_app); | 1794 InspectBackgroundPage(platform_app); |
| 1795 break; | 1795 break; |
| 1796 } | 1796 } |
| 1797 | 1797 |
| 1798 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: { | 1798 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: { |
| 1799 NavigationController* controller = &source_web_contents_->GetController(); | 1799 NavigationController* controller = &source_web_contents_->GetController(); |
| 1800 // Important to use GetVisibleEntry to match what's showing in the | 1800 NavigationEntry* nav_entry = controller->GetActiveEntry(); |
|
Peter Kasting
2013/08/20 18:33:16
Is this change correct? It looks surprising to me
| |
| 1801 // omnibox. | |
| 1802 NavigationEntry* nav_entry = controller->GetVisibleEntry(); | |
| 1803 Browser* browser = | 1801 Browser* browser = |
| 1804 chrome::FindBrowserWithWebContents(source_web_contents_); | 1802 chrome::FindBrowserWithWebContents(source_web_contents_); |
| 1805 chrome::ShowWebsiteSettings(browser, source_web_contents_, | 1803 chrome::ShowWebsiteSettings(browser, source_web_contents_, |
| 1806 nav_entry->GetURL(), nav_entry->GetSSL()); | 1804 nav_entry->GetURL(), nav_entry->GetSSL()); |
| 1807 break; | 1805 break; |
| 1808 } | 1806 } |
| 1809 | 1807 |
| 1810 case IDC_CONTENT_CONTEXT_TRANSLATE: { | 1808 case IDC_CONTENT_CONTEXT_TRANSLATE: { |
| 1811 // A translation might have been triggered by the time the menu got | 1809 // A translation might have been triggered by the time the menu got |
| 1812 // selected, do nothing in that case. | 1810 // selected, do nothing in that case. |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2104 source_web_contents_->GetRenderViewHost()-> | 2102 source_web_contents_->GetRenderViewHost()-> |
| 2105 ExecuteMediaPlayerActionAtLocation(location, action); | 2103 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2106 } | 2104 } |
| 2107 | 2105 |
| 2108 void RenderViewContextMenu::PluginActionAt( | 2106 void RenderViewContextMenu::PluginActionAt( |
| 2109 const gfx::Point& location, | 2107 const gfx::Point& location, |
| 2110 const WebPluginAction& action) { | 2108 const WebPluginAction& action) { |
| 2111 source_web_contents_->GetRenderViewHost()-> | 2109 source_web_contents_->GetRenderViewHost()-> |
| 2112 ExecutePluginActionAtLocation(location, action); | 2110 ExecutePluginActionAtLocation(location, action); |
| 2113 } | 2111 } |
| OLD | NEW |