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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 source_web_contents_->GetRenderViewHost()-> | 2105 source_web_contents_->GetRenderViewHost()-> |
2105 ExecuteMediaPlayerActionAtLocation(location, action); | 2106 ExecuteMediaPlayerActionAtLocation(location, action); |
2106 } | 2107 } |
2107 | 2108 |
2108 void RenderViewContextMenu::PluginActionAt( | 2109 void RenderViewContextMenu::PluginActionAt( |
2109 const gfx::Point& location, | 2110 const gfx::Point& location, |
2110 const WebPluginAction& action) { | 2111 const WebPluginAction& action) { |
2111 source_web_contents_->GetRenderViewHost()-> | 2112 source_web_contents_->GetRenderViewHost()-> |
2112 ExecutePluginActionAtLocation(location, action); | 2113 ExecutePluginActionAtLocation(location, action); |
2113 } | 2114 } |
OLD | NEW |