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

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: add a missing override; Created 4 years, 8 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 28 matching lines...) Expand all
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
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},
293 // Add new items here and use |enum_id| from the next line. 298 // Add new items here and use |enum_id| from the next line.
294 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. 299 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml.
295 {74, -1, 0}, // Must be the last. Increment |enum_id| when new IDC 300 {78, -1, 0}, // Must be the last. Increment |enum_id| when new IDC
296 // was added. 301 // was added.
297 }; 302 };
298 303
299 // Collapses large ranges of ids before looking for UMA enum. 304 // Collapses large ranges of ids before looking for UMA enum.
300 int CollapseCommandsForUMA(int id) { 305 int CollapseCommandsForUMA(int id) {
301 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); 306 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id));
302 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); 307 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id));
303 308
304 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 309 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
305 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 310 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); 940 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB);
936 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, 941 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW,
937 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); 942 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW);
938 if (params_.link_url.is_valid()) { 943 if (params_.link_url.is_valid()) {
939 AppendProtocolHandlerSubMenu(); 944 AppendProtocolHandlerSubMenu();
940 } 945 }
941 946
942 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 947 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD,
943 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); 948 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD);
944 949
950 AppendOpenWithLinkItems();
951
945 // While ChromeOS supports multiple profiles, only one can be open at a 952 // While ChromeOS supports multiple profiles, only one can be open at a
946 // time. 953 // time.
947 // TODO(jochen): Consider adding support for ChromeOS with similar 954 // TODO(jochen): Consider adding support for ChromeOS with similar
948 // semantics as the profile switcher in the system tray. 955 // semantics as the profile switcher in the system tray.
949 #if !defined(OS_CHROMEOS) 956 #if !defined(OS_CHROMEOS)
950 // g_browser_process->profile_manager() is null during unit tests. 957 // g_browser_process->profile_manager() is null during unit tests.
951 if (g_browser_process->profile_manager() && 958 if (g_browser_process->profile_manager() &&
952 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) { 959 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) {
953 ProfileManager* profile_manager = g_browser_process->profile_manager(); 960 ProfileManager* profile_manager = g_browser_process->profile_manager();
954 // Find all regular profiles other than the current one which have at 961 // Find all regular profiles other than the current one which have at
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); 1037 IDS_CONTENT_CONTEXT_COPYLINKLOCATION);
1031 1038
1032 if (params_.source_type == ui::MENU_SOURCE_TOUCH && 1039 if (params_.source_type == ui::MENU_SOURCE_TOUCH &&
1033 params_.media_type != WebContextMenuData::MediaTypeImage && 1040 params_.media_type != WebContextMenuData::MediaTypeImage &&
1034 !params_.link_text.empty()) { 1041 !params_.link_text.empty()) {
1035 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT, 1042 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT,
1036 IDS_CONTENT_CONTEXT_COPYLINKTEXT); 1043 IDS_CONTENT_CONTEXT_COPYLINKTEXT);
1037 } 1044 }
1038 } 1045 }
1039 1046
1047 void RenderViewContextMenu::AppendOpenWithLinkItems() {
1048 const size_t kMaxOpenWithMenuItems =
1049 IDC_CONTENT_CONTEXT_OPEN_WITH_LAST - IDC_CONTENT_CONTEXT_OPEN_WITH1 + 1;
1050 const size_t kMaxOpenWithSubMenuItems =
1051 IDC_CONTENT_CONTEXT_OPEN_WITH_SUB_LAST -
1052 IDC_CONTENT_CONTEXT_OPEN_WITH_SUB1 + 1;
1053
1054 open_with_menu_observer_.reset(OpenWithMenuFactory::CreateMenu(
1055 this, IDC_CONTENT_CONTEXT_OPEN_WITH1, kMaxOpenWithMenuItems,
1056 IDC_CONTENT_CONTEXT_OPEN_WITH_SUB1, kMaxOpenWithSubMenuItems));
1057 if (open_with_menu_observer_) {
1058 observers_.AddObserver(open_with_menu_observer_.get());
1059 open_with_menu_observer_->InitMenu(params_);
1060 }
1061 }
1062
1040 void RenderViewContextMenu::AppendImageItems() { 1063 void RenderViewContextMenu::AppendImageItems() {
1041 std::map<std::string, std::string>::const_iterator it = 1064 std::map<std::string, std::string>::const_iterator it =
1042 params_.properties.find(data_reduction_proxy::chrome_proxy_header()); 1065 params_.properties.find(data_reduction_proxy::chrome_proxy_header());
1043 if (it != params_.properties.end() && it->second == 1066 if (it != params_.properties.end() && it->second ==
1044 data_reduction_proxy::chrome_proxy_lo_fi_directive()) { 1067 data_reduction_proxy::chrome_proxy_lo_fi_directive()) {
1045 menu_model_.AddItemWithStringId( 1068 menu_model_.AddItemWithStringId(
1046 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE, 1069 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE,
1047 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE); 1070 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE);
1048 } 1071 }
1049 DataReductionProxyChromeSettings* settings = 1072 DataReductionProxyChromeSettings* settings =
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 source_web_contents_->GetRenderViewHost()-> 2300 source_web_contents_->GetRenderViewHost()->
2278 ExecuteMediaPlayerActionAtLocation(location, action); 2301 ExecuteMediaPlayerActionAtLocation(location, action);
2279 } 2302 }
2280 2303
2281 void RenderViewContextMenu::PluginActionAt( 2304 void RenderViewContextMenu::PluginActionAt(
2282 const gfx::Point& location, 2305 const gfx::Point& location,
2283 const WebPluginAction& action) { 2306 const WebPluginAction& action) {
2284 source_web_contents_->GetRenderViewHost()-> 2307 source_web_contents_->GetRenderViewHost()->
2285 ExecutePluginActionAtLocation(location, action); 2308 ExecutePluginActionAtLocation(location, action);
2286 } 2309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698