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

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: fix unit_tests 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 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_observer.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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 {64, -1, IDC_WRITING_DIRECTION_LTR}, 272 {64, -1, IDC_WRITING_DIRECTION_LTR},
272 {65, -1, IDC_WRITING_DIRECTION_RTL}, 273 {65, -1, IDC_WRITING_DIRECTION_RTL},
273 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, 274 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE},
274 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, 275 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD},
275 {68, -1, IDC_ROUTE_MEDIA}, 276 {68, -1, IDC_ROUTE_MEDIA},
276 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT}, 277 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT},
277 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE}, 278 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE},
278 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST}, 279 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST},
279 {72, -1, IDC_CONTENT_CONTEXT_GENERATEPASSWORD}, 280 {72, -1, IDC_CONTENT_CONTEXT_GENERATEPASSWORD},
280 {73, -1, IDC_SPELLCHECK_MULTI_LINGUAL}, 281 {73, -1, IDC_SPELLCHECK_MULTI_LINGUAL},
282 {74, -1, IDC_CONTENT_CONTEXT_OPEN_WITH1},
283 {75, -1, IDC_CONTENT_CONTEXT_OPEN_WITH2},
284 {76, -1, IDC_CONTENT_CONTEXT_OPEN_WITH3},
285 {77, -1, IDC_CONTENT_CONTEXT_OPEN_WITH4},
281 // Add new items here and use |enum_id| from the next line. 286 // Add new items here and use |enum_id| from the next line.
282 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. 287 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml.
283 {74, -1, 0}, // Must be the last. Increment |enum_id| when new IDC 288 {78, -1, 0}, // Must be the last. Increment |enum_id| when new IDC
284 // was added. 289 // was added.
285 }; 290 };
286 291
287 // Collapses large ranges of ids before looking for UMA enum. 292 // Collapses large ranges of ids before looking for UMA enum.
288 int CollapseCommandsForUMA(int id) { 293 int CollapseCommandsForUMA(int id) {
289 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); 294 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id));
290 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); 295 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id));
291 296
292 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 297 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
293 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 298 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); 896 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB);
892 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, 897 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW,
893 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); 898 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW);
894 if (params_.link_url.is_valid()) { 899 if (params_.link_url.is_valid()) {
895 AppendProtocolHandlerSubMenu(); 900 AppendProtocolHandlerSubMenu();
896 } 901 }
897 902
898 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 903 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD,
899 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); 904 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD);
900 905
906 AppendOpenWithLinkItems();
907
901 // While ChromeOS supports multiple profiles, only one can be open at a 908 // While ChromeOS supports multiple profiles, only one can be open at a
902 // time. 909 // time.
903 // TODO(jochen): Consider adding support for ChromeOS with similar 910 // TODO(jochen): Consider adding support for ChromeOS with similar
904 // semantics as the profile switcher in the system tray. 911 // semantics as the profile switcher in the system tray.
905 #if !defined(OS_CHROMEOS) 912 #if !defined(OS_CHROMEOS)
906 // g_browser_process->profile_manager() is null during unit tests. 913 // g_browser_process->profile_manager() is null during unit tests.
907 if (g_browser_process->profile_manager() && 914 if (g_browser_process->profile_manager() &&
908 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) { 915 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) {
909 ProfileManager* profile_manager = g_browser_process->profile_manager(); 916 ProfileManager* profile_manager = g_browser_process->profile_manager();
910 // Find all regular profiles other than the current one which have at 917 // Find all regular profiles other than the current one which have at
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); 981 IDS_CONTENT_CONTEXT_COPYLINKLOCATION);
975 982
976 if (params_.source_type == ui::MENU_SOURCE_TOUCH && 983 if (params_.source_type == ui::MENU_SOURCE_TOUCH &&
977 params_.media_type != WebContextMenuData::MediaTypeImage && 984 params_.media_type != WebContextMenuData::MediaTypeImage &&
978 !params_.link_text.empty()) { 985 !params_.link_text.empty()) {
979 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT, 986 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT,
980 IDS_CONTENT_CONTEXT_COPYLINKTEXT); 987 IDS_CONTENT_CONTEXT_COPYLINKTEXT);
981 } 988 }
982 } 989 }
983 990
991 void RenderViewContextMenu::AppendOpenWithLinkItems() {
992 if (!open_with_menu_observer_)
993 open_with_menu_observer_.reset(new OpenWithMenuObserver(this));
994 observers_.AddObserver(open_with_menu_observer_.get());
995 open_with_menu_observer_->InitMenu(params_);
996 }
997
984 void RenderViewContextMenu::AppendImageItems() { 998 void RenderViewContextMenu::AppendImageItems() {
985 std::map<std::string, std::string>::const_iterator it = 999 std::map<std::string, std::string>::const_iterator it =
986 params_.properties.find(data_reduction_proxy::chrome_proxy_header()); 1000 params_.properties.find(data_reduction_proxy::chrome_proxy_header());
987 if (it != params_.properties.end() && it->second == 1001 if (it != params_.properties.end() && it->second ==
988 data_reduction_proxy::chrome_proxy_lo_fi_directive()) { 1002 data_reduction_proxy::chrome_proxy_lo_fi_directive()) {
989 menu_model_.AddItemWithStringId( 1003 menu_model_.AddItemWithStringId(
990 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE, 1004 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE,
991 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE); 1005 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE);
992 } 1006 }
993 DataReductionProxyChromeSettings* settings = 1007 DataReductionProxyChromeSettings* settings =
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 source_web_contents_->GetRenderViewHost()-> 2221 source_web_contents_->GetRenderViewHost()->
2208 ExecuteMediaPlayerActionAtLocation(location, action); 2222 ExecuteMediaPlayerActionAtLocation(location, action);
2209 } 2223 }
2210 2224
2211 void RenderViewContextMenu::PluginActionAt( 2225 void RenderViewContextMenu::PluginActionAt(
2212 const gfx::Point& location, 2226 const gfx::Point& location,
2213 const WebPluginAction& action) { 2227 const WebPluginAction& action) {
2214 source_web_contents_->GetRenderViewHost()-> 2228 source_web_contents_->GetRenderViewHost()->
2215 ExecutePluginActionAtLocation(location, action); 2229 ExecutePluginActionAtLocation(location, action);
2216 } 2230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698