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 |
| 11 #include "apps/app_load_service.h" | 11 #include "apps/app_load_service.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_member.h" | 15 #include "base/prefs/pref_member.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 21 #include "chrome/app/chrome_command_ids.h" | 22 #include "chrome/app/chrome_command_ids.h" |
| 22 #include "chrome/browser/app_mode/app_mode_utils.h" | 23 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 23 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 24 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 24 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 25 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 25 #include "chrome/browser/autocomplete/autocomplete_match.h" | 26 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 26 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
| 28 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 29 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 29 #include "chrome/browser/devtools/devtools_window.h" | 30 #include "chrome/browser/devtools/devtools_window.h" |
| 30 #include "chrome/browser/download/download_service.h" | 31 #include "chrome/browser/download/download_service.h" |
| 31 #include "chrome/browser/download/download_service_factory.h" | 32 #include "chrome/browser/download/download_service_factory.h" |
| 32 #include "chrome/browser/download/download_util.h" | 33 #include "chrome/browser/download/download_util.h" |
| 33 #include "chrome/browser/extensions/extension_host.h" | 34 #include "chrome/browser/extensions/extension_host.h" |
| 34 #include "chrome/browser/extensions/extension_service.h" | 35 #include "chrome/browser/extensions/extension_service.h" |
| 35 #include "chrome/browser/extensions/extension_system.h" | 36 #include "chrome/browser/extensions/extension_system.h" |
| 36 #include "chrome/browser/google/google_util.h" | 37 #include "chrome/browser/google/google_util.h" |
| 37 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 38 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 38 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 39 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 39 #include "chrome/browser/printing/print_preview_context_menu_observer.h" | 40 #include "chrome/browser/printing/print_preview_context_menu_observer.h" |
| 40 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 41 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 41 #include "chrome/browser/printing/print_view_manager.h" | 42 #include "chrome/browser/printing/print_view_manager.h" |
| 42 #include "chrome/browser/profiles/profile.h" | 43 #include "chrome/browser/profiles/profile.h" |
| 43 #include "chrome/browser/profiles/profile_io_data.h" | 44 #include "chrome/browser/profiles/profile_io_data.h" |
| 44 #include "chrome/browser/search/search.h" | 45 #include "chrome/browser/search/search.h" |
| 46 #include "chrome/browser/search_engines/search_terms_data.h" | |
| 45 #include "chrome/browser/search_engines/template_url.h" | 47 #include "chrome/browser/search_engines/template_url.h" |
| 46 #include "chrome/browser/search_engines/template_url_service.h" | 48 #include "chrome/browser/search_engines/template_url_service.h" |
| 47 #include "chrome/browser/search_engines/template_url_service_factory.h" | 49 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 48 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 50 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 49 #include "chrome/browser/spellchecker/spellcheck_service.h" | 51 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 50 #include "chrome/browser/tab_contents/retargeting_details.h" | 52 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 51 #include "chrome/browser/tab_contents/spellchecker_submenu_observer.h" | 53 #include "chrome/browser/tab_contents/spellchecker_submenu_observer.h" |
| 52 #include "chrome/browser/tab_contents/spelling_menu_observer.h" | 54 #include "chrome/browser/tab_contents/spelling_menu_observer.h" |
| 53 #include "chrome/browser/translate/translate_manager.h" | 55 #include "chrome/browser/translate/translate_manager.h" |
| 54 #include "chrome/browser/translate/translate_prefs.h" | 56 #include "chrome/browser/translate/translate_prefs.h" |
| 55 #include "chrome/browser/translate/translate_tab_helper.h" | 57 #include "chrome/browser/translate/translate_tab_helper.h" |
| 56 #include "chrome/browser/ui/browser.h" | 58 #include "chrome/browser/ui/browser.h" |
| 57 #include "chrome/browser/ui/browser_commands.h" | 59 #include "chrome/browser/ui/browser_commands.h" |
| 58 #include "chrome/browser/ui/browser_finder.h" | 60 #include "chrome/browser/ui/browser_finder.h" |
| 59 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 61 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
| 60 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 62 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 61 #include "chrome/common/chrome_constants.h" | 63 #include "chrome/common/chrome_constants.h" |
| 62 #include "chrome/common/chrome_switches.h" | 64 #include "chrome/common/chrome_switches.h" |
| 63 #include "chrome/common/content_restriction.h" | 65 #include "chrome/common/content_restriction.h" |
| 64 #include "chrome/common/extensions/extension.h" | 66 #include "chrome/common/extensions/extension.h" |
| 65 #include "chrome/common/net/url_util.h" | 67 #include "chrome/common/net/url_util.h" |
| 66 #include "chrome/common/pref_names.h" | 68 #include "chrome/common/pref_names.h" |
| 67 #include "chrome/common/print_messages.h" | 69 #include "chrome/common/print_messages.h" |
| 70 #include "chrome/common/render_messages.h" | |
| 68 #include "chrome/common/spellcheck_messages.h" | 71 #include "chrome/common/spellcheck_messages.h" |
| 69 #include "chrome/common/url_constants.h" | 72 #include "chrome/common/url_constants.h" |
| 70 #include "content/public/browser/child_process_security_policy.h" | 73 #include "content/public/browser/child_process_security_policy.h" |
| 71 #include "content/public/browser/download_manager.h" | 74 #include "content/public/browser/download_manager.h" |
| 72 #include "content/public/browser/download_save_info.h" | 75 #include "content/public/browser/download_save_info.h" |
| 73 #include "content/public/browser/download_url_parameters.h" | 76 #include "content/public/browser/download_url_parameters.h" |
| 74 #include "content/public/browser/navigation_details.h" | 77 #include "content/public/browser/navigation_details.h" |
| 75 #include "content/public/browser/navigation_entry.h" | 78 #include "content/public/browser/navigation_entry.h" |
| 76 #include "content/public/browser/notification_service.h" | 79 #include "content/public/browser/notification_service.h" |
| 77 #include "content/public/browser/render_process_host.h" | 80 #include "content/public/browser/render_process_host.h" |
| 78 #include "content/public/browser/render_view_host.h" | 81 #include "content/public/browser/render_view_host.h" |
| 79 #include "content/public/browser/render_widget_host_view.h" | 82 #include "content/public/browser/render_widget_host_view.h" |
| 80 #include "content/public/browser/user_metrics.h" | 83 #include "content/public/browser/user_metrics.h" |
| 81 #include "content/public/browser/web_contents.h" | 84 #include "content/public/browser/web_contents.h" |
| 82 #include "content/public/common/menu_item.h" | 85 #include "content/public/common/menu_item.h" |
| 83 #include "content/public/common/ssl_status.h" | 86 #include "content/public/common/ssl_status.h" |
| 84 #include "content/public/common/url_utils.h" | 87 #include "content/public/common/url_utils.h" |
| 85 #include "extensions/browser/view_type_utils.h" | 88 #include "extensions/browser/view_type_utils.h" |
| 86 #include "grit/generated_resources.h" | 89 #include "grit/generated_resources.h" |
| 87 #include "net/base/escape.h" | 90 #include "net/base/escape.h" |
| 88 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 91 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
| 89 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" | 92 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |
| 90 #include "third_party/WebKit/public/web/WebPluginAction.h" | 93 #include "third_party/WebKit/public/web/WebPluginAction.h" |
| 91 #include "ui/base/clipboard/clipboard.h" | 94 #include "ui/base/clipboard/clipboard.h" |
| 92 #include "ui/base/l10n/l10n_util.h" | 95 #include "ui/base/l10n/l10n_util.h" |
| 93 #include "ui/base/text/text_elider.h" | 96 #include "ui/base/text/text_elider.h" |
| 94 #include "ui/gfx/favicon_size.h" | 97 #include "ui/gfx/favicon_size.h" |
| 98 #include "ui/gfx/point.h" | |
| 99 #include "ui/gfx/size.h" | |
| 95 | 100 |
| 96 using WebKit::WebContextMenuData; | 101 using WebKit::WebContextMenuData; |
| 97 using WebKit::WebMediaPlayerAction; | 102 using WebKit::WebMediaPlayerAction; |
| 98 using WebKit::WebPluginAction; | 103 using WebKit::WebPluginAction; |
| 99 using WebKit::WebString; | 104 using WebKit::WebString; |
| 100 using WebKit::WebURL; | 105 using WebKit::WebURL; |
| 101 using content::BrowserContext; | 106 using content::BrowserContext; |
| 102 using content::ChildProcessSecurityPolicy; | 107 using content::ChildProcessSecurityPolicy; |
| 103 using content::DownloadManager; | 108 using content::DownloadManager; |
| 104 using content::DownloadUrlParameters; | 109 using content::DownloadUrlParameters; |
| 105 using content::NavigationController; | 110 using content::NavigationController; |
| 106 using content::NavigationEntry; | 111 using content::NavigationEntry; |
| 107 using content::OpenURLParams; | 112 using content::OpenURLParams; |
| 108 using content::RenderViewHost; | 113 using content::RenderViewHost; |
| 109 using content::SSLStatus; | 114 using content::SSLStatus; |
| 110 using content::UserMetricsAction; | 115 using content::UserMetricsAction; |
| 111 using content::WebContents; | 116 using content::WebContents; |
| 112 using extensions::Extension; | 117 using extensions::Extension; |
| 113 using extensions::MenuItem; | 118 using extensions::MenuItem; |
| 114 using extensions::MenuManager; | 119 using extensions::MenuManager; |
| 115 | 120 |
| 116 namespace { | 121 namespace { |
| 117 | 122 |
| 123 const int kImageSearchThumbnailMinSize = 300 * 300; | |
| 124 const int kImageSearchThumbnailMaxWidth = 600; | |
| 125 const int kImageSearchThumbnailMaxHeight = 600; | |
|
Kibeom Kim (inactive)
2013/07/31 21:25:54
Actually, Android Chrome need to access these valu
| |
| 126 | |
| 118 // Maps UMA enumeration to IDC. IDC could be changed so we can't use | 127 // Maps UMA enumeration to IDC. IDC could be changed so we can't use |
| 119 // just them and |UMA_HISTOGRAM_CUSTOM_ENUMERATION|. | 128 // just them and |UMA_HISTOGRAM_CUSTOM_ENUMERATION|. |
| 120 // Never change mapping or reuse |enum_id|. Always push back new items. | 129 // Never change mapping or reuse |enum_id|. Always push back new items. |
| 121 // Items that is not used any more by |RenderViewContextMenu.ExecuteCommand| | 130 // Items that is not used any more by |RenderViewContextMenu.ExecuteCommand| |
| 122 // could be deleted, but don't change the rest of |kUmaEnumToControlId|. | 131 // could be deleted, but don't change the rest of |kUmaEnumToControlId|. |
| 123 const struct UmaEnumCommandIdPair { | 132 const struct UmaEnumCommandIdPair { |
| 124 int enum_id; | 133 int enum_id; |
| 125 int control_id; | 134 int control_id; |
| 126 } kUmaEnumToControlId[] = { | 135 } kUmaEnumToControlId[] = { |
| 127 { 0, IDC_CONTENT_CONTEXT_CUSTOM_FIRST }, | 136 { 0, IDC_CONTENT_CONTEXT_CUSTOM_FIRST }, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 { 47, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS }, | 183 { 47, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS }, |
| 175 { 48, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE }, | 184 { 48, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE }, |
| 176 { 49, IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES }, | 185 { 49, IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES }, |
| 177 { 50, IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT }, | 186 { 50, IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT }, |
| 178 { 51, IDC_SPEECH_INPUT_MENU }, | 187 { 51, IDC_SPEECH_INPUT_MENU }, |
| 179 { 52, IDC_CONTENT_CONTEXT_OPENLINKWITH }, | 188 { 52, IDC_CONTENT_CONTEXT_OPENLINKWITH }, |
| 180 { 53, IDC_CHECK_SPELLING_WHILE_TYPING }, | 189 { 53, IDC_CHECK_SPELLING_WHILE_TYPING }, |
| 181 { 54, IDC_SPELLCHECK_MENU }, | 190 { 54, IDC_SPELLCHECK_MENU }, |
| 182 { 55, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE }, | 191 { 55, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE }, |
| 183 { 56, IDC_SPELLCHECK_LANGUAGES_FIRST }, | 192 { 56, IDC_SPELLCHECK_LANGUAGES_FIRST }, |
| 193 {57, IDC_CONTENT_CONTEXT_SEARCHIMAGENEWTAB }, | |
|
Avi (use Gerrit)
2013/07/31 20:11:05
Match style; space after {
Johnny(Jianning) Ding
2013/07/31 21:38:09
Done.
| |
| 184 // Add new items here and use |enum_id| from the next line. | 194 // Add new items here and use |enum_id| from the next line. |
| 185 { 57, 0 }, // Must be the last. Increment |enum_id| when new IDC was added. | 195 { 58, 0 }, // Must be the last. Increment |enum_id| when new IDC was added. |
| 186 }; | 196 }; |
| 187 | 197 |
| 188 // Collapses large ranges of ids before looking for UMA enum. | 198 // Collapses large ranges of ids before looking for UMA enum. |
| 189 int CollapleCommandsForUMA(int id) { | 199 int CollapleCommandsForUMA(int id) { |
| 190 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | 200 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && |
| 191 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { | 201 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { |
| 192 return IDC_CONTENT_CONTEXT_CUSTOM_FIRST; | 202 return IDC_CONTENT_CONTEXT_CUSTOM_FIRST; |
| 193 } | 203 } |
| 194 | 204 |
| 195 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && | 205 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 836 void RenderViewContextMenu::AppendImageItems() { | 846 void RenderViewContextMenu::AppendImageItems() { |
| 837 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, | 847 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, |
| 838 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); | 848 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); |
| 839 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, | 849 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, |
| 840 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); | 850 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); |
| 841 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, | 851 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, |
| 842 IDS_CONTENT_CONTEXT_COPYIMAGE); | 852 IDS_CONTENT_CONTEXT_COPYIMAGE); |
| 843 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, | 853 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, |
| 844 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); | 854 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); |
| 845 AppendPrintItem(); | 855 AppendPrintItem(); |
| 856 const TemplateURL* const default_provider = | |
| 857 TemplateURLServiceFactory::GetForProfile(profile_)-> | |
| 858 GetDefaultSearchProvider(); | |
| 859 if (!default_provider) | |
| 860 return; | |
| 861 SearchTermsData search_terms; | |
| 862 if (!default_provider->image_url().empty() && | |
| 863 default_provider->image_url_ref().IsValidUsingTermsData(search_terms)) { | |
| 864 std::string search_provider_name = | |
| 865 UTF16ToUTF8(default_provider->short_name()); | |
| 866 std::string menu_item_name = | |
| 867 base::StringPrintf("Search Image By %s", search_provider_name.c_str()); | |
|
jingbinw
2013/07/31 20:04:45
I would suggest to rename this as
"Search %s for
Avi (use Gerrit)
2013/07/31 20:11:05
Um...
Every one of our UI strings is localized an
Kibeom Kim (inactive)
2013/07/31 20:20:53
note: just like IDS_CONTENT_CONTEXT_SEARCHWEBFOR i
Avi (use Gerrit)
2013/07/31 20:35:53
Yes. Look for examples (in this very file) with l1
Johnny(Jianning) Ding
2013/07/31 21:26:36
The hard-code "Search Image By %s" should be repla
jingbinw
2013/07/31 23:31:29
Can you rewording the message to be "Search %s for
Peter Kasting
2013/07/31 23:38:22
No, it's not correct. You should never see a .cc
Kibeom Kim (inactive)
2013/08/01 00:14:59
here:
menu_model_.AddItem(
IDC_CONTENT_CONTEXT
| |
| 868 menu_model_.AddItem(IDC_CONTENT_CONTEXT_SEARCHIMAGENEWTAB, | |
| 869 UTF8ToUTF16(menu_item_name)); | |
| 870 } | |
| 846 } | 871 } |
| 847 | 872 |
| 848 void RenderViewContextMenu::AppendAudioItems() { | 873 void RenderViewContextMenu::AppendAudioItems() { |
| 849 AppendMediaItems(); | 874 AppendMediaItems(); |
| 850 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 875 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| 851 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, | 876 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, |
| 852 IDS_CONTENT_CONTEXT_SAVEAUDIOAS); | 877 IDS_CONTENT_CONTEXT_SAVEAUDIOAS); |
| 853 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, | 878 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, |
| 854 IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION); | 879 IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION); |
| 855 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, | 880 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1246 DCHECK(local_state); | 1271 DCHECK(local_state); |
| 1247 // Test if file-selection dialogs are forbidden by policy. | 1272 // Test if file-selection dialogs are forbidden by policy. |
| 1248 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1273 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 1249 return false; | 1274 return false; |
| 1250 | 1275 |
| 1251 return params_.src_url.is_valid() && | 1276 return params_.src_url.is_valid() && |
| 1252 ProfileIOData::IsHandledProtocol(params_.src_url.scheme()); | 1277 ProfileIOData::IsHandledProtocol(params_.src_url.scheme()); |
| 1253 } | 1278 } |
| 1254 | 1279 |
| 1255 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: | 1280 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: |
| 1281 case IDC_CONTENT_CONTEXT_SEARCHIMAGENEWTAB: | |
| 1256 // The images shown in the most visited thumbnails do not currently open | 1282 // The images shown in the most visited thumbnails do not currently open |
| 1257 // in a new tab as they should. Disabling this context menu option for | 1283 // in a new tab as they should. Disabling this context menu option for |
| 1258 // now, as a quick hack, before we resolve this issue (Issue = 2608). | 1284 // now, as a quick hack, before we resolve this issue (Issue = 2608). |
| 1259 // TODO(sidchat): Enable this option once this issue is resolved. | 1285 // TODO(sidchat): Enable this option once this issue is resolved. |
| 1260 if (params_.src_url.scheme() == chrome::kChromeUIScheme || | 1286 if (params_.src_url.scheme() == chrome::kChromeUIScheme || |
| 1261 !params_.src_url.is_valid()) | 1287 !params_.src_url.is_valid()) |
| 1262 return false; | 1288 return false; |
| 1263 return true; | 1289 return true; |
| 1264 | 1290 |
| 1265 case IDC_CONTENT_CONTEXT_COPYIMAGE: | 1291 case IDC_CONTENT_CONTEXT_COPYIMAGE: |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1599 | 1625 |
| 1600 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: | 1626 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: |
| 1601 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: | 1627 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: |
| 1602 WriteURLToClipboard(params_.src_url); | 1628 WriteURLToClipboard(params_.src_url); |
| 1603 break; | 1629 break; |
| 1604 | 1630 |
| 1605 case IDC_CONTENT_CONTEXT_COPYIMAGE: | 1631 case IDC_CONTENT_CONTEXT_COPYIMAGE: |
| 1606 CopyImageAt(params_.x, params_.y); | 1632 CopyImageAt(params_.x, params_.y); |
| 1607 break; | 1633 break; |
| 1608 | 1634 |
| 1635 case IDC_CONTENT_CONTEXT_SEARCHIMAGENEWTAB: | |
| 1636 GetImageThumbnailForSearch(params_.x, params_.y); | |
| 1637 break; | |
| 1638 | |
| 1609 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: | 1639 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: |
| 1610 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: | 1640 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: |
| 1611 OpenURL( | 1641 OpenURL( |
| 1612 params_.src_url, | 1642 params_.src_url, |
| 1613 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, | 1643 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, |
| 1614 params_.frame_id, | 1644 params_.frame_id, |
| 1615 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_LINK); | 1645 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_LINK); |
| 1616 break; | 1646 break; |
| 1617 | 1647 |
| 1618 case IDC_CONTENT_CONTEXT_PLAYPAUSE: { | 1648 case IDC_CONTENT_CONTEXT_PLAYPAUSE: { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2027 chrome::NOTIFICATION_RETARGETING, | 2057 chrome::NOTIFICATION_RETARGETING, |
| 2028 content::Source<Profile>(Profile::FromBrowserContext( | 2058 content::Source<Profile>(Profile::FromBrowserContext( |
| 2029 source_web_contents_->GetBrowserContext())), | 2059 source_web_contents_->GetBrowserContext())), |
| 2030 content::Details<RetargetingDetails>(&details)); | 2060 content::Details<RetargetingDetails>(&details)); |
| 2031 } | 2061 } |
| 2032 | 2062 |
| 2033 void RenderViewContextMenu::CopyImageAt(int x, int y) { | 2063 void RenderViewContextMenu::CopyImageAt(int x, int y) { |
| 2034 source_web_contents_->GetRenderViewHost()->CopyImageAt(x, y); | 2064 source_web_contents_->GetRenderViewHost()->CopyImageAt(x, y); |
| 2035 } | 2065 } |
| 2036 | 2066 |
| 2067 void RenderViewContextMenu::GetImageThumbnailForSearch(int x, int y) { | |
|
Kibeom Kim (inactive)
2013/07/31 21:49:49
How x and y are used?
Johnny(Jianning) Ding
2013/07/31 21:53:47
they are gone.
| |
| 2068 source_web_contents_->GetRenderViewHost()->Send( | |
| 2069 new ChromeViewMsg_RequestThumbnailForContextNode( | |
| 2070 source_web_contents_->GetRenderViewHost()->GetRoutingID(), | |
| 2071 kImageSearchThumbnailMinSize, | |
| 2072 gfx::Size(kImageSearchThumbnailMaxWidth, | |
| 2073 kImageSearchThumbnailMaxHeight))); | |
| 2074 } | |
| 2075 | |
| 2037 void RenderViewContextMenu::Inspect(int x, int y) { | 2076 void RenderViewContextMenu::Inspect(int x, int y) { |
| 2038 content::RecordAction(UserMetricsAction("DevTools_InspectElement")); | 2077 content::RecordAction(UserMetricsAction("DevTools_InspectElement")); |
| 2039 source_web_contents_->GetRenderViewHostAtPosition( | 2078 source_web_contents_->GetRenderViewHostAtPosition( |
| 2040 x, y, base::Bind(&DevToolsInspectElementAt)); | 2079 x, y, base::Bind(&DevToolsInspectElementAt)); |
| 2041 } | 2080 } |
| 2042 | 2081 |
| 2043 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { | 2082 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { |
| 2044 chrome_common_net::WriteURLToClipboard( | 2083 chrome_common_net::WriteURLToClipboard( |
| 2045 url, | 2084 url, |
| 2046 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 2085 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 2047 ui::Clipboard::GetForCurrentThread()); | 2086 ui::Clipboard::GetForCurrentThread()); |
| 2048 } | 2087 } |
| 2049 | 2088 |
| 2050 void RenderViewContextMenu::MediaPlayerActionAt( | 2089 void RenderViewContextMenu::MediaPlayerActionAt( |
| 2051 const gfx::Point& location, | 2090 const gfx::Point& location, |
| 2052 const WebMediaPlayerAction& action) { | 2091 const WebMediaPlayerAction& action) { |
| 2053 source_web_contents_->GetRenderViewHost()-> | 2092 source_web_contents_->GetRenderViewHost()-> |
| 2054 ExecuteMediaPlayerActionAtLocation(location, action); | 2093 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2055 } | 2094 } |
| 2056 | 2095 |
| 2057 void RenderViewContextMenu::PluginActionAt( | 2096 void RenderViewContextMenu::PluginActionAt( |
| 2058 const gfx::Point& location, | 2097 const gfx::Point& location, |
| 2059 const WebPluginAction& action) { | 2098 const WebPluginAction& action) { |
| 2060 source_web_contents_->GetRenderViewHost()-> | 2099 source_web_contents_->GetRenderViewHost()-> |
| 2061 ExecutePluginActionAtLocation(location, action); | 2100 ExecutePluginActionAtLocation(location, action); |
| 2062 } | 2101 } |
| OLD | NEW |