Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 1760773004: Add "Open with <ARC-app-name>" items to the context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); 899 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB);
892 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, 900 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW,
893 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); 901 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW);
894 if (params_.link_url.is_valid()) { 902 if (params_.link_url.is_valid()) {
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
909 #if defined(OS_CHROMEOS)
910 AppendArcLinkItems();
911 #else
901 // While ChromeOS supports multiple profiles, only one can be open at a 912 // While ChromeOS supports multiple profiles, only one can be open at a
902 // time. 913 // time.
903 // TODO(jochen): Consider adding support for ChromeOS with similar 914 // TODO(jochen): Consider adding support for ChromeOS with similar
904 // semantics as the profile switcher in the system tray. 915 // semantics as the profile switcher in the system tray.
905 #if !defined(OS_CHROMEOS) 916
906 // g_browser_process->profile_manager() is null during unit tests. 917 // g_browser_process->profile_manager() is null during unit tests.
907 if (g_browser_process->profile_manager() && 918 if (g_browser_process->profile_manager() &&
908 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) { 919 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) {
909 ProfileManager* profile_manager = g_browser_process->profile_manager(); 920 ProfileManager* profile_manager = g_browser_process->profile_manager();
910 // Find all regular profiles other than the current one which have at 921 // Find all regular profiles other than the current one which have at
911 // least one open window. 922 // least one open window.
912 std::vector<ProfileAttributesEntry*> entries = 923 std::vector<ProfileAttributesEntry*> entries =
913 profile_manager->GetProfileAttributesStorage(). 924 profile_manager->GetProfileAttributesStorage().
914 GetAllProfilesAttributesSortedByName(); 925 GetAllProfilesAttributesSortedByName();
915 std::vector<ProfileAttributesEntry*> target_profiles_entries; 926 std::vector<ProfileAttributesEntry*> target_profiles_entries;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, entry->GetName()); 965 IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, entry->GetName());
955 AddIconToLastMenuItem(entry->GetAvatarIcon(), 966 AddIconToLastMenuItem(entry->GetAvatarIcon(),
956 &profile_link_submenu_model_); 967 &profile_link_submenu_model_);
957 } 968 }
958 menu_model_.AddSubMenuWithStringId( 969 menu_model_.AddSubMenuWithStringId(
959 IDC_CONTENT_CONTEXT_OPENLINKINPROFILE, 970 IDC_CONTENT_CONTEXT_OPENLINKINPROFILE,
960 IDS_CONTENT_CONTEXT_OPENLINKINPROFILES, 971 IDS_CONTENT_CONTEXT_OPENLINKINPROFILES,
961 &profile_link_submenu_model_); 972 &profile_link_submenu_model_);
962 } 973 }
963 } 974 }
964 #endif // !defined(OS_CHROMEOS) 975 #endif // defined(OS_CHROMEOS)
965 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 976 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
966 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, 977 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS,
967 IDS_CONTENT_CONTEXT_SAVELINKAS); 978 IDS_CONTENT_CONTEXT_SAVELINKAS);
968 } 979 }
969 980
970 menu_model_.AddItemWithStringId( 981 menu_model_.AddItemWithStringId(
971 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, 982 IDC_CONTENT_CONTEXT_COPYLINKLOCATION,
972 params_.link_url.SchemeIs(url::kMailToScheme) ? 983 params_.link_url.SchemeIs(url::kMailToScheme) ?
973 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : 984 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS :
974 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); 985 IDS_CONTENT_CONTEXT_COPYLINKLOCATION);
975 986
976 if (params_.source_type == ui::MENU_SOURCE_TOUCH && 987 if (params_.source_type == ui::MENU_SOURCE_TOUCH &&
977 params_.media_type != WebContextMenuData::MediaTypeImage && 988 params_.media_type != WebContextMenuData::MediaTypeImage &&
978 !params_.link_text.empty()) { 989 !params_.link_text.empty()) {
979 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT, 990 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT,
980 IDS_CONTENT_CONTEXT_COPYLINKTEXT); 991 IDS_CONTENT_CONTEXT_COPYLINKTEXT);
981 } 992 }
982 } 993 }
983 994
995 #if defined(OS_CHROMEOS)
996 void RenderViewContextMenu::AppendArcLinkItems() {
997 if (!arc_app_menu_observer_)
998 arc_app_menu_observer_.reset(new ArcAppMenuObserver(this));
999 observers_.AddObserver(arc_app_menu_observer_.get());
1000 arc_app_menu_observer_->InitMenu(params_);
1001 }
1002 #endif // defined(OS_CHROMEOS)
1003
984 void RenderViewContextMenu::AppendImageItems() { 1004 void RenderViewContextMenu::AppendImageItems() {
985 std::map<std::string, std::string>::const_iterator it = 1005 std::map<std::string, std::string>::const_iterator it =
986 params_.properties.find(data_reduction_proxy::chrome_proxy_header()); 1006 params_.properties.find(data_reduction_proxy::chrome_proxy_header());
987 if (it != params_.properties.end() && it->second == 1007 if (it != params_.properties.end() && it->second ==
988 data_reduction_proxy::chrome_proxy_lo_fi_directive()) { 1008 data_reduction_proxy::chrome_proxy_lo_fi_directive()) {
989 menu_model_.AddItemWithStringId( 1009 menu_model_.AddItemWithStringId(
990 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE, 1010 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE,
991 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE); 1011 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE);
992 } 1012 }
993 DataReductionProxyChromeSettings* settings = 1013 DataReductionProxyChromeSettings* settings =
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 source_web_contents_->GetRenderViewHost()-> 2226 source_web_contents_->GetRenderViewHost()->
2207 ExecuteMediaPlayerActionAtLocation(location, action); 2227 ExecuteMediaPlayerActionAtLocation(location, action);
2208 } 2228 }
2209 2229
2210 void RenderViewContextMenu::PluginActionAt( 2230 void RenderViewContextMenu::PluginActionAt(
2211 const gfx::Point& location, 2231 const gfx::Point& location,
2212 const WebPluginAction& action) { 2232 const WebPluginAction& action) {
2213 source_web_contents_->GetRenderViewHost()-> 2233 source_web_contents_->GetRenderViewHost()->
2214 ExecutePluginActionAtLocation(location, action); 2234 ExecutePluginActionAtLocation(location, action);
2215 } 2235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698