OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 39 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
40 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 40 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
41 #include "chrome/browser/profiles/profile.h" | 41 #include "chrome/browser/profiles/profile.h" |
42 #include "chrome/browser/profiles/profile_attributes_entry.h" | 42 #include "chrome/browser/profiles/profile_attributes_entry.h" |
43 #include "chrome/browser/profiles/profile_attributes_storage.h" | 43 #include "chrome/browser/profiles/profile_attributes_storage.h" |
44 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 44 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
45 #include "chrome/browser/profiles/profile_io_data.h" | 45 #include "chrome/browser/profiles/profile_io_data.h" |
46 #include "chrome/browser/profiles/profile_manager.h" | 46 #include "chrome/browser/profiles/profile_manager.h" |
47 #include "chrome/browser/profiles/profile_window.h" | 47 #include "chrome/browser/profiles/profile_window.h" |
48 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory
.h" | 48 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory
.h" |
| 49 #include "chrome/browser/renderer_context_menu/open_with_menu_factory.h" |
49 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" | 50 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" |
50 #include "chrome/browser/search/search.h" | 51 #include "chrome/browser/search/search.h" |
51 #include "chrome/browser/search_engines/template_url_service_factory.h" | 52 #include "chrome/browser/search_engines/template_url_service_factory.h" |
52 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 53 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
53 #include "chrome/browser/spellchecker/spellcheck_service.h" | 54 #include "chrome/browser/spellchecker/spellcheck_service.h" |
54 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 55 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
55 #include "chrome/browser/tab_contents/retargeting_details.h" | 56 #include "chrome/browser/tab_contents/retargeting_details.h" |
56 #include "chrome/browser/translate/chrome_translate_client.h" | 57 #include "chrome/browser/translate/chrome_translate_client.h" |
57 #include "chrome/browser/translate/translate_service.h" | 58 #include "chrome/browser/translate/translate_service.h" |
58 #include "chrome/browser/ui/browser.h" | 59 #include "chrome/browser/ui/browser.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 {64, -1, IDC_WRITING_DIRECTION_LTR}, | 284 {64, -1, IDC_WRITING_DIRECTION_LTR}, |
284 {65, -1, IDC_WRITING_DIRECTION_RTL}, | 285 {65, -1, IDC_WRITING_DIRECTION_RTL}, |
285 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, | 286 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, |
286 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, | 287 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, |
287 {68, -1, IDC_ROUTE_MEDIA}, | 288 {68, -1, IDC_ROUTE_MEDIA}, |
288 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT}, | 289 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT}, |
289 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE}, | 290 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE}, |
290 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST}, | 291 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST}, |
291 {72, -1, IDC_CONTENT_CONTEXT_GENERATEPASSWORD}, | 292 {72, -1, IDC_CONTENT_CONTEXT_GENERATEPASSWORD}, |
292 {73, -1, IDC_SPELLCHECK_MULTI_LINGUAL}, | 293 {73, -1, IDC_SPELLCHECK_MULTI_LINGUAL}, |
| 294 {74, -1, IDC_CONTENT_CONTEXT_OPEN_WITH1}, |
| 295 {75, -1, IDC_CONTENT_CONTEXT_OPEN_WITH2}, |
| 296 {76, -1, IDC_CONTENT_CONTEXT_OPEN_WITH3}, |
| 297 {77, -1, IDC_CONTENT_CONTEXT_OPEN_WITH4}, |
| 298 {78, -1, IDC_CONTENT_CONTEXT_OPEN_WITH5}, |
| 299 {79, -1, IDC_CONTENT_CONTEXT_OPEN_WITH6}, |
| 300 {80, -1, IDC_CONTENT_CONTEXT_OPEN_WITH7}, |
| 301 {81, -1, IDC_CONTENT_CONTEXT_OPEN_WITH8}, |
| 302 {82, -1, IDC_CONTENT_CONTEXT_OPEN_WITH9}, |
| 303 {83, -1, IDC_CONTENT_CONTEXT_OPEN_WITH10}, |
| 304 {84, -1, IDC_CONTENT_CONTEXT_OPEN_WITH11}, |
| 305 {85, -1, IDC_CONTENT_CONTEXT_OPEN_WITH12}, |
| 306 {86, -1, IDC_CONTENT_CONTEXT_OPEN_WITH13}, |
| 307 {87, -1, IDC_CONTENT_CONTEXT_OPEN_WITH14}, |
293 // Add new items here and use |enum_id| from the next line. | 308 // Add new items here and use |enum_id| from the next line. |
294 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. | 309 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. |
295 {74, -1, 0}, // Must be the last. Increment |enum_id| when new IDC | 310 {88, -1, 0}, // Must be the last. Increment |enum_id| when new IDC |
296 // was added. | 311 // was added. |
297 }; | 312 }; |
298 | 313 |
299 // Collapses large ranges of ids before looking for UMA enum. | 314 // Collapses large ranges of ids before looking for UMA enum. |
300 int CollapseCommandsForUMA(int id) { | 315 int CollapseCommandsForUMA(int id) { |
301 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); | 316 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); |
302 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); | 317 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); |
303 | 318 |
304 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && | 319 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && |
305 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { | 320 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); | 950 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); |
936 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, | 951 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, |
937 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); | 952 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); |
938 if (params_.link_url.is_valid()) { | 953 if (params_.link_url.is_valid()) { |
939 AppendProtocolHandlerSubMenu(); | 954 AppendProtocolHandlerSubMenu(); |
940 } | 955 } |
941 | 956 |
942 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, | 957 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, |
943 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); | 958 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); |
944 | 959 |
| 960 AppendOpenWithLinkItems(); |
| 961 |
945 // While ChromeOS supports multiple profiles, only one can be open at a | 962 // While ChromeOS supports multiple profiles, only one can be open at a |
946 // time. | 963 // time. |
947 // TODO(jochen): Consider adding support for ChromeOS with similar | 964 // TODO(jochen): Consider adding support for ChromeOS with similar |
948 // semantics as the profile switcher in the system tray. | 965 // semantics as the profile switcher in the system tray. |
949 #if !defined(OS_CHROMEOS) | 966 #if !defined(OS_CHROMEOS) |
950 // g_browser_process->profile_manager() is null during unit tests. | 967 // g_browser_process->profile_manager() is null during unit tests. |
951 if (g_browser_process->profile_manager() && | 968 if (g_browser_process->profile_manager() && |
952 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) { | 969 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) { |
953 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 970 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
954 // Find all regular profiles other than the current one which have at | 971 // Find all regular profiles other than the current one which have at |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); | 1047 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); |
1031 | 1048 |
1032 if (params_.source_type == ui::MENU_SOURCE_TOUCH && | 1049 if (params_.source_type == ui::MENU_SOURCE_TOUCH && |
1033 params_.media_type != WebContextMenuData::MediaTypeImage && | 1050 params_.media_type != WebContextMenuData::MediaTypeImage && |
1034 !params_.link_text.empty()) { | 1051 !params_.link_text.empty()) { |
1035 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT, | 1052 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT, |
1036 IDS_CONTENT_CONTEXT_COPYLINKTEXT); | 1053 IDS_CONTENT_CONTEXT_COPYLINKTEXT); |
1037 } | 1054 } |
1038 } | 1055 } |
1039 | 1056 |
| 1057 void RenderViewContextMenu::AppendOpenWithLinkItems() { |
| 1058 open_with_menu_observer_.reset(OpenWithMenuFactory::CreateMenu(this)); |
| 1059 if (open_with_menu_observer_) { |
| 1060 observers_.AddObserver(open_with_menu_observer_.get()); |
| 1061 open_with_menu_observer_->InitMenu(params_); |
| 1062 } |
| 1063 } |
| 1064 |
1040 void RenderViewContextMenu::AppendImageItems() { | 1065 void RenderViewContextMenu::AppendImageItems() { |
1041 std::map<std::string, std::string>::const_iterator it = | 1066 std::map<std::string, std::string>::const_iterator it = |
1042 params_.properties.find(data_reduction_proxy::chrome_proxy_header()); | 1067 params_.properties.find(data_reduction_proxy::chrome_proxy_header()); |
1043 if (it != params_.properties.end() && it->second == | 1068 if (it != params_.properties.end() && it->second == |
1044 data_reduction_proxy::chrome_proxy_lo_fi_directive()) { | 1069 data_reduction_proxy::chrome_proxy_lo_fi_directive()) { |
1045 menu_model_.AddItemWithStringId( | 1070 menu_model_.AddItemWithStringId( |
1046 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE, | 1071 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE, |
1047 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE); | 1072 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE); |
1048 } | 1073 } |
1049 DataReductionProxyChromeSettings* settings = | 1074 DataReductionProxyChromeSettings* settings = |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2276 source_web_contents_->GetRenderViewHost()-> | 2301 source_web_contents_->GetRenderViewHost()-> |
2277 ExecuteMediaPlayerActionAtLocation(location, action); | 2302 ExecuteMediaPlayerActionAtLocation(location, action); |
2278 } | 2303 } |
2279 | 2304 |
2280 void RenderViewContextMenu::PluginActionAt( | 2305 void RenderViewContextMenu::PluginActionAt( |
2281 const gfx::Point& location, | 2306 const gfx::Point& location, |
2282 const WebPluginAction& action) { | 2307 const WebPluginAction& action) { |
2283 source_web_contents_->GetRenderViewHost()-> | 2308 source_web_contents_->GetRenderViewHost()-> |
2284 ExecutePluginActionAtLocation(location, action); | 2309 ExecutePluginActionAtLocation(location, action); |
2285 } | 2310 } |
OLD | NEW |