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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 #include "chrome/browser/printing/print_preview_context_menu_observer.h" | 138 #include "chrome/browser/printing/print_preview_context_menu_observer.h" |
139 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 139 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
140 #endif // defined(ENABLE_PRINT_PREVIEW) | 140 #endif // defined(ENABLE_PRINT_PREVIEW) |
141 #endif // defined(ENABLE_PRINTING) | 141 #endif // defined(ENABLE_PRINTING) |
142 | 142 |
143 #if defined(ENABLE_MEDIA_ROUTER) | 143 #if defined(ENABLE_MEDIA_ROUTER) |
144 #include "chrome/browser/media/router/media_router_dialog_controller.h" | 144 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
145 #include "chrome/browser/media/router/media_router_metrics.h" | 145 #include "chrome/browser/media/router/media_router_metrics.h" |
146 #endif | 146 #endif |
147 | 147 |
148 #if defined(OS_CHROMEOS) | |
149 #include "chrome/browser/renderer_context_menu/arc_app_menu_observer_chromeos.h" | |
150 #endif | |
151 | |
148 using base::UserMetricsAction; | 152 using base::UserMetricsAction; |
149 using blink::WebContextMenuData; | 153 using blink::WebContextMenuData; |
150 using blink::WebMediaPlayerAction; | 154 using blink::WebMediaPlayerAction; |
151 using blink::WebPluginAction; | 155 using blink::WebPluginAction; |
152 using blink::WebString; | 156 using blink::WebString; |
153 using blink::WebURL; | 157 using blink::WebURL; |
154 using content::BrowserContext; | 158 using content::BrowserContext; |
155 using content::ChildProcessSecurityPolicy; | 159 using content::ChildProcessSecurityPolicy; |
156 using content::DownloadManager; | 160 using content::DownloadManager; |
157 using content::DownloadUrlParameters; | 161 using content::DownloadUrlParameters; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 {64, -1, IDC_WRITING_DIRECTION_LTR}, | 275 {64, -1, IDC_WRITING_DIRECTION_LTR}, |
272 {65, -1, IDC_WRITING_DIRECTION_RTL}, | 276 {65, -1, IDC_WRITING_DIRECTION_RTL}, |
273 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, | 277 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, |
274 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, | 278 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, |
275 {68, -1, IDC_ROUTE_MEDIA}, | 279 {68, -1, IDC_ROUTE_MEDIA}, |
276 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT}, | 280 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT}, |
277 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE}, | 281 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE}, |
278 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST}, | 282 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST}, |
279 {72, -1, IDC_CONTENT_CONTEXT_GENERATEPASSWORD}, | 283 {72, -1, IDC_CONTENT_CONTEXT_GENERATEPASSWORD}, |
280 {73, -1, IDC_SPELLCHECK_MULTI_LINGUAL}, | 284 {73, -1, IDC_SPELLCHECK_MULTI_LINGUAL}, |
285 {74, -1, IDC_CONTENT_CONTEXT_ARC_APP1}, | |
286 {75, -1, IDC_CONTENT_CONTEXT_ARC_APP2}, | |
287 {76, -1, IDC_CONTENT_CONTEXT_ARC_APP3}, | |
288 {77, -1, IDC_CONTENT_CONTEXT_ARC_SUB_MENU}, | |
281 // Add new items here and use |enum_id| from the next line. | 289 // Add new items here and use |enum_id| from the next line. |
282 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. | 290 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. |
283 {74, -1, 0}, // Must be the last. Increment |enum_id| when new IDC | 291 {78, -1, 0}, // Must be the last. Increment |enum_id| when new IDC |
284 // was added. | 292 // was added. |
285 }; | 293 }; |
286 | 294 |
287 // Collapses large ranges of ids before looking for UMA enum. | 295 // Collapses large ranges of ids before looking for UMA enum. |
288 int CollapseCommandsForUMA(int id) { | 296 int CollapseCommandsForUMA(int id) { |
289 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); | 297 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); |
290 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); | 298 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); |
291 | 299 |
292 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && | 300 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && |
293 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { | 301 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 AppendProtocolHandlerSubMenu(); | 903 AppendProtocolHandlerSubMenu(); |
896 } | 904 } |
897 | 905 |
898 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, | 906 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, |
899 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); | 907 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); |
900 | 908 |
901 // While ChromeOS supports multiple profiles, only one can be open at a | 909 // While ChromeOS supports multiple profiles, only one can be open at a |
902 // time. | 910 // time. |
903 // TODO(jochen): Consider adding support for ChromeOS with similar | 911 // TODO(jochen): Consider adding support for ChromeOS with similar |
904 // semantics as the profile switcher in the system tray. | 912 // semantics as the profile switcher in the system tray. |
905 #if !defined(OS_CHROMEOS) | 913 #if !defined(OS_CHROMEOS) |
Avi (use Gerrit)
2016/03/05 00:24:11
Reverse this #if, and move the comment above it in
Yusuke Sato
2016/03/05 01:38:24
Done.
| |
906 // g_browser_process->profile_manager() is null during unit tests. | 914 // g_browser_process->profile_manager() is null during unit tests. |
907 if (g_browser_process->profile_manager() && | 915 if (g_browser_process->profile_manager() && |
908 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) { | 916 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) { |
909 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 917 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
910 // Find all regular profiles other than the current one which have at | 918 // Find all regular profiles other than the current one which have at |
911 // least one open window. | 919 // least one open window. |
912 std::vector<ProfileAttributesEntry*> entries = | 920 std::vector<ProfileAttributesEntry*> entries = |
913 profile_manager->GetProfileAttributesStorage(). | 921 profile_manager->GetProfileAttributesStorage(). |
914 GetAllProfilesAttributesSortedByName(); | 922 GetAllProfilesAttributesSortedByName(); |
915 std::vector<ProfileAttributesEntry*> target_profiles_entries; | 923 std::vector<ProfileAttributesEntry*> target_profiles_entries; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
954 IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, entry->GetName()); | 962 IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, entry->GetName()); |
955 AddIconToLastMenuItem(entry->GetAvatarIcon(), | 963 AddIconToLastMenuItem(entry->GetAvatarIcon(), |
956 &profile_link_submenu_model_); | 964 &profile_link_submenu_model_); |
957 } | 965 } |
958 menu_model_.AddSubMenuWithStringId( | 966 menu_model_.AddSubMenuWithStringId( |
959 IDC_CONTENT_CONTEXT_OPENLINKINPROFILE, | 967 IDC_CONTENT_CONTEXT_OPENLINKINPROFILE, |
960 IDS_CONTENT_CONTEXT_OPENLINKINPROFILES, | 968 IDS_CONTENT_CONTEXT_OPENLINKINPROFILES, |
961 &profile_link_submenu_model_); | 969 &profile_link_submenu_model_); |
962 } | 970 } |
963 } | 971 } |
972 #else | |
973 AppendArcLinkItems(); | |
964 #endif // !defined(OS_CHROMEOS) | 974 #endif // !defined(OS_CHROMEOS) |
965 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 975 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
966 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, | 976 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, |
967 IDS_CONTENT_CONTEXT_SAVELINKAS); | 977 IDS_CONTENT_CONTEXT_SAVELINKAS); |
968 } | 978 } |
969 | 979 |
970 menu_model_.AddItemWithStringId( | 980 menu_model_.AddItemWithStringId( |
971 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, | 981 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, |
972 params_.link_url.SchemeIs(url::kMailToScheme) ? | 982 params_.link_url.SchemeIs(url::kMailToScheme) ? |
973 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : | 983 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : |
974 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); | 984 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); |
975 | 985 |
976 if (params_.source_type == ui::MENU_SOURCE_TOUCH && | 986 if (params_.source_type == ui::MENU_SOURCE_TOUCH && |
977 params_.media_type != WebContextMenuData::MediaTypeImage && | 987 params_.media_type != WebContextMenuData::MediaTypeImage && |
978 !params_.link_text.empty()) { | 988 !params_.link_text.empty()) { |
979 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT, | 989 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT, |
980 IDS_CONTENT_CONTEXT_COPYLINKTEXT); | 990 IDS_CONTENT_CONTEXT_COPYLINKTEXT); |
981 } | 991 } |
982 } | 992 } |
983 | 993 |
994 #if defined(OS_CHROMEOS) | |
995 void RenderViewContextMenu::AppendArcLinkItems() { | |
996 if (!arc_app_menu_observer_.get()) | |
997 arc_app_menu_observer_.reset(new ArcAppMenuObserver(this)); | |
998 observers_.AddObserver(arc_app_menu_observer_.get()); | |
999 arc_app_menu_observer_->InitMenu(params_); | |
1000 } | |
1001 #endif // defined(OS_CHROMEOS) | |
1002 | |
984 void RenderViewContextMenu::AppendImageItems() { | 1003 void RenderViewContextMenu::AppendImageItems() { |
985 std::map<std::string, std::string>::const_iterator it = | 1004 std::map<std::string, std::string>::const_iterator it = |
986 params_.properties.find(data_reduction_proxy::chrome_proxy_header()); | 1005 params_.properties.find(data_reduction_proxy::chrome_proxy_header()); |
987 if (it != params_.properties.end() && it->second == | 1006 if (it != params_.properties.end() && it->second == |
988 data_reduction_proxy::chrome_proxy_lo_fi_directive()) { | 1007 data_reduction_proxy::chrome_proxy_lo_fi_directive()) { |
989 menu_model_.AddItemWithStringId( | 1008 menu_model_.AddItemWithStringId( |
990 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE, | 1009 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE, |
991 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE); | 1010 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE); |
992 } | 1011 } |
993 DataReductionProxyChromeSettings* settings = | 1012 DataReductionProxyChromeSettings* settings = |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2206 source_web_contents_->GetRenderViewHost()-> | 2225 source_web_contents_->GetRenderViewHost()-> |
2207 ExecuteMediaPlayerActionAtLocation(location, action); | 2226 ExecuteMediaPlayerActionAtLocation(location, action); |
2208 } | 2227 } |
2209 | 2228 |
2210 void RenderViewContextMenu::PluginActionAt( | 2229 void RenderViewContextMenu::PluginActionAt( |
2211 const gfx::Point& location, | 2230 const gfx::Point& location, |
2212 const WebPluginAction& action) { | 2231 const WebPluginAction& action) { |
2213 source_web_contents_->GetRenderViewHost()-> | 2232 source_web_contents_->GetRenderViewHost()-> |
2214 ExecutePluginActionAtLocation(location, action); | 2233 ExecutePluginActionAtLocation(location, action); |
2215 } | 2234 } |
OLD | NEW |