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