Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "chrome/browser/download/download_service_factory.h" | 30 #include "chrome/browser/download/download_service_factory.h" |
| 31 #include "chrome/browser/download/download_stats.h" | 31 #include "chrome/browser/download/download_stats.h" |
| 32 #include "chrome/browser/extensions/devtools_util.h" | 32 #include "chrome/browser/extensions/devtools_util.h" |
| 33 #include "chrome/browser/extensions/extension_service.h" | 33 #include "chrome/browser/extensions/extension_service.h" |
| 34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" | 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" |
| 36 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 36 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 37 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 37 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 38 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 38 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 39 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
| 40 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | |
| 41 #include "chrome/browser/profiles/profile_info_cache.h" | |
| 40 #include "chrome/browser/profiles/profile_io_data.h" | 42 #include "chrome/browser/profiles/profile_io_data.h" |
| 43 #include "chrome/browser/profiles/profile_manager.h" | |
| 44 #include "chrome/browser/profiles/profile_window.h" | |
| 41 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory .h" | 45 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory .h" |
| 42 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h" | 46 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h" |
| 43 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" | 47 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" |
| 44 #include "chrome/browser/search/search.h" | 48 #include "chrome/browser/search/search.h" |
| 45 #include "chrome/browser/search_engines/template_url_service_factory.h" | 49 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 46 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 50 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 47 #include "chrome/browser/spellchecker/spellcheck_service.h" | 51 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 48 #include "chrome/browser/tab_contents/retargeting_details.h" | 52 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 49 #include "chrome/browser/translate/chrome_translate_client.h" | 53 #include "chrome/browser/translate/chrome_translate_client.h" |
| 50 #include "chrome/browser/translate/translate_service.h" | 54 #include "chrome/browser/translate/translate_service.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 {58, IDC_SPELLCHECK_SUGGESTION_0}, | 222 {58, IDC_SPELLCHECK_SUGGESTION_0}, |
| 219 {59, IDC_SPELLCHECK_ADD_TO_DICTIONARY}, | 223 {59, IDC_SPELLCHECK_ADD_TO_DICTIONARY}, |
| 220 {60, IDC_SPELLPANEL_TOGGLE}, | 224 {60, IDC_SPELLPANEL_TOGGLE}, |
| 221 {61, IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB}, | 225 {61, IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB}, |
| 222 {62, IDC_WRITING_DIRECTION_MENU}, | 226 {62, IDC_WRITING_DIRECTION_MENU}, |
| 223 {63, IDC_WRITING_DIRECTION_DEFAULT}, | 227 {63, IDC_WRITING_DIRECTION_DEFAULT}, |
| 224 {64, IDC_WRITING_DIRECTION_LTR}, | 228 {64, IDC_WRITING_DIRECTION_LTR}, |
| 225 {65, IDC_WRITING_DIRECTION_RTL}, | 229 {65, IDC_WRITING_DIRECTION_RTL}, |
| 226 {66, IDC_CONTENT_CONTEXT_SHOW_ORIGINAL_IMAGE}, | 230 {66, IDC_CONTENT_CONTEXT_SHOW_ORIGINAL_IMAGE}, |
| 227 {67, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, | 231 {67, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, |
| 232 {68, IDC_OPEN_LINK_IN_PROFILE_FIRST}, | |
| 228 // Add new items here and use |enum_id| from the next line. | 233 // Add new items here and use |enum_id| from the next line. |
| 229 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. | 234 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. |
| 230 {68, 0}, // Must be the last. Increment |enum_id| when new IDC was added. | 235 {69, 0}, // Must be the last. Increment |enum_id| when new IDC was added. |
| 231 }; | 236 }; |
| 232 | 237 |
| 233 // Collapses large ranges of ids before looking for UMA enum. | 238 // Collapses large ranges of ids before looking for UMA enum. |
| 234 int CollapseCommandsForUMA(int id) { | 239 int CollapseCommandsForUMA(int id) { |
| 235 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); | 240 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); |
| 236 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); | 241 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); |
| 237 | 242 |
| 238 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && | 243 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && |
| 239 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { | 244 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { |
| 240 return IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; | 245 return IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; |
| 241 } | 246 } |
| 242 | 247 |
| 243 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && | 248 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && |
| 244 id <= IDC_SPELLCHECK_LANGUAGES_LAST) { | 249 id <= IDC_SPELLCHECK_LANGUAGES_LAST) { |
| 245 return IDC_SPELLCHECK_LANGUAGES_FIRST; | 250 return IDC_SPELLCHECK_LANGUAGES_FIRST; |
| 246 } | 251 } |
| 247 | 252 |
| 248 if (id >= IDC_SPELLCHECK_SUGGESTION_0 && | 253 if (id >= IDC_SPELLCHECK_SUGGESTION_0 && |
| 249 id <= IDC_SPELLCHECK_SUGGESTION_LAST) { | 254 id <= IDC_SPELLCHECK_SUGGESTION_LAST) { |
| 250 return IDC_SPELLCHECK_SUGGESTION_0; | 255 return IDC_SPELLCHECK_SUGGESTION_0; |
| 251 } | 256 } |
| 252 | 257 |
| 258 if (id >= IDC_OPEN_LINK_IN_PROFILE_FIRST && | |
| 259 id <= IDC_OPEN_LINK_IN_PROFILE_LAST) { | |
| 260 return IDC_OPEN_LINK_IN_PROFILE_FIRST; | |
| 261 } | |
| 262 | |
| 253 return id; | 263 return id; |
| 254 } | 264 } |
| 255 | 265 |
| 256 // Returns UMA enum value for command specified by |id| or -1 if not found. | 266 // Returns UMA enum value for command specified by |id| or -1 if not found. |
| 257 int FindUMAEnumValueForCommand(int id) { | 267 int FindUMAEnumValueForCommand(int id) { |
| 258 if (RenderViewContextMenu::IsContentCustomCommandId(id)) | 268 if (RenderViewContextMenu::IsContentCustomCommandId(id)) |
| 259 return 0; | 269 return 0; |
| 260 | 270 |
| 261 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) | 271 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) |
| 262 return 1; | 272 return 1; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 } | 374 } |
| 365 | 375 |
| 366 RenderViewContextMenu::RenderViewContextMenu( | 376 RenderViewContextMenu::RenderViewContextMenu( |
| 367 content::RenderFrameHost* render_frame_host, | 377 content::RenderFrameHost* render_frame_host, |
| 368 const content::ContextMenuParams& params) | 378 const content::ContextMenuParams& params) |
| 369 : RenderViewContextMenuBase(render_frame_host, params), | 379 : RenderViewContextMenuBase(render_frame_host, params), |
| 370 extension_items_(browser_context_, | 380 extension_items_(browser_context_, |
| 371 this, | 381 this, |
| 372 &menu_model_, | 382 &menu_model_, |
| 373 base::Bind(MenuItemMatchesParams, params_)), | 383 base::Bind(MenuItemMatchesParams, params_)), |
| 384 profile_link_submenu_model_(this), | |
| 374 protocol_handler_submenu_model_(this), | 385 protocol_handler_submenu_model_(this), |
| 375 protocol_handler_registry_( | 386 protocol_handler_registry_( |
| 376 ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())), | 387 ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())), |
| 377 embedder_web_contents_(GetWebContentsToUse(source_web_contents_)) { | 388 embedder_web_contents_(GetWebContentsToUse(source_web_contents_)) { |
| 378 if (!g_custom_id_ranges_initialized) { | 389 if (!g_custom_id_ranges_initialized) { |
| 379 g_custom_id_ranges_initialized = true; | 390 g_custom_id_ranges_initialized = true; |
| 380 SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, | 391 SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, |
| 381 IDC_CONTENT_CONTEXT_CUSTOM_LAST); | 392 IDC_CONTENT_CONTEXT_CUSTOM_LAST); |
| 382 } | 393 } |
| 383 set_content_type(ContextMenuContentTypeFactory::Create( | 394 set_content_type(ContextMenuContentTypeFactory::Create( |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 void RenderViewContextMenu::AppendLinkItems() { | 736 void RenderViewContextMenu::AppendLinkItems() { |
| 726 if (!params_.link_url.is_empty()) { | 737 if (!params_.link_url.is_empty()) { |
| 727 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, | 738 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, |
| 728 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); | 739 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 729 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, | 740 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, |
| 730 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); | 741 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); |
| 731 if (params_.link_url.is_valid()) { | 742 if (params_.link_url.is_valid()) { |
| 732 AppendProtocolHandlerSubMenu(); | 743 AppendProtocolHandlerSubMenu(); |
| 733 } | 744 } |
| 734 | 745 |
| 746 // g_browser_process->profile_manager() is NULL during unit tests. | |
|
Peter Kasting
2015/06/15 23:45:15
Is null, or may be null? (i.e. Is it ever non-nul
jochen (gone - plz use gerrit)
2015/06/16 08:00:14
it's always null during the context menu unit test
Peter Kasting
2015/06/16 08:20:24
OK. (Prefer "null" to "NULL", though.)
jochen (gone - plz use gerrit)
2015/06/16 09:01:50
done
| |
| 747 if (g_browser_process->profile_manager() && | |
| 748 GetProfile()->GetProfileType() == Profile::REGULAR_PROFILE) { | |
| 749 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 750 ProfileInfoCache& profile_info_cache = | |
|
Peter Kasting
2015/06/15 23:45:15
I believe that if you mark ProfileInfoCache::GetAv
jochen (gone - plz use gerrit)
2015/06/16 08:00:13
done
| |
| 751 profile_manager->GetProfileInfoCache(); | |
| 752 | |
| 753 std::vector<Profile*> target_profiles; | |
|
Peter Kasting
2015/06/15 23:45:15
Nit: Maybe above this block say something like "Fi
jochen (gone - plz use gerrit)
2015/06/16 08:00:13
done
| |
| 754 std::vector<Profile*> all_profiles = profile_manager->GetLoadedProfiles(); | |
| 755 chrome::HostDesktopType desktop_type = | |
| 756 chrome::FindBrowserWithWebContents(source_web_contents_) | |
|
Peter Kasting
2015/06/15 23:45:15
See null-check question I have about this in Execu
jochen (gone - plz use gerrit)
2015/06/16 08:00:13
done
| |
| 757 ->host_desktop_type(); | |
| 758 for (std::vector<Profile*>::iterator it = all_profiles.begin(); | |
| 759 it != all_profiles.end(); ++it) { | |
|
Peter Kasting
2015/06/15 23:45:15
Nit: Use range-based for
jochen (gone - plz use gerrit)
2015/06/16 08:00:14
done
| |
| 760 if ((*it)->GetProfileType() != Profile::REGULAR_PROFILE) | |
|
Peter Kasting
2015/06/15 23:45:15
Nit: Shorter:
if ((profile->GetProfileTyp
jochen (gone - plz use gerrit)
2015/06/16 08:00:13
done
| |
| 761 continue; | |
| 762 if (*it == GetProfile()) | |
| 763 continue; | |
| 764 | |
| 765 // A loaded profile doesn't necessary have an open window associated | |
| 766 // with it. | |
| 767 if (!chrome::FindLastActiveWithProfile(*it, desktop_type)) | |
| 768 continue; | |
| 769 target_profiles.push_back(*it); | |
| 770 } | |
| 771 | |
| 772 if (target_profiles.size() == 1) { | |
| 773 Profile* profile = target_profiles[0]; | |
| 774 size_t profile_index = | |
| 775 profile_info_cache.GetIndexOfProfileWithPath(profile->GetPath()); | |
| 776 menu_model_.AddItem( | |
| 777 IDC_OPEN_LINK_IN_PROFILE_FIRST + profile_index, | |
| 778 l10n_util::GetStringFUTF16( | |
| 779 IDS_CONTENT_CONTEXT_OPENLINKINPROFILE, | |
| 780 profile_info_cache.GetNameOfProfileAtIndex(profile_index))); | |
| 781 } else if (target_profiles.size() > 1) { | |
|
Peter Kasting
2015/06/15 23:45:15
Can this conditional ever fail?
jochen (gone - plz use gerrit)
2015/06/16 08:00:13
there could be no target_profile (since target_pro
Peter Kasting
2015/06/16 08:20:24
OK; how about "} else if (!target_profiles.empty()
jochen (gone - plz use gerrit)
2015/06/16 09:01:50
done
| |
| 782 for (std::vector<Profile*>::iterator it = target_profiles.begin(); | |
| 783 it != target_profiles.end(); ++it) { | |
|
Peter Kasting
2015/06/15 23:45:15
Nit: Use range-based for
jochen (gone - plz use gerrit)
2015/06/16 08:00:14
done
| |
| 784 Profile* profile = *it; | |
| 785 size_t profile_index = | |
| 786 profile_info_cache.GetIndexOfProfileWithPath(profile->GetPath()); | |
| 787 profile_link_submenu_model_.AddItem( | |
| 788 IDC_OPEN_LINK_IN_PROFILE_FIRST + profile_index, | |
| 789 profile_info_cache.GetNameOfProfileAtIndex(profile_index)); | |
| 790 gfx::Image icon = | |
| 791 profile_info_cache.GetAvatarIconOfProfileAtIndex(profile_index); | |
| 792 int width = icon.Width(); | |
| 793 int height = icon.Height(); | |
| 794 gfx::CalculateFaviconTargetSize(&width, &height); | |
| 795 profile_link_submenu_model_.SetIcon( | |
| 796 profile_link_submenu_model_.GetItemCount() - 1, | |
| 797 profiles::GetSizedAvatarIcon(icon, true, width, height)); | |
| 798 } | |
| 799 menu_model_.AddSubMenuWithStringId( | |
| 800 IDC_CONTENT_CONTEXT_OPENLINKINPROFILE, | |
| 801 IDS_CONTENT_CONTEXT_OPENLINKINPROFILES, | |
| 802 &profile_link_submenu_model_); | |
| 803 } | |
| 804 } | |
| 805 | |
| 735 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, | 806 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, |
| 736 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); | 807 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); |
| 737 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, | 808 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, |
| 738 IDS_CONTENT_CONTEXT_SAVELINKAS); | 809 IDS_CONTENT_CONTEXT_SAVELINKAS); |
| 739 } | 810 } |
| 740 | 811 |
| 741 menu_model_.AddItemWithStringId( | 812 menu_model_.AddItemWithStringId( |
| 742 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, | 813 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, |
| 743 params_.link_url.SchemeIs(url::kMailToScheme) ? | 814 params_.link_url.SchemeIs(url::kMailToScheme) ? |
| 744 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : | 815 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1087 | 1158 |
| 1088 // Extension items. | 1159 // Extension items. |
| 1089 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) | 1160 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) |
| 1090 return extension_items_.IsCommandIdEnabled(id); | 1161 return extension_items_.IsCommandIdEnabled(id); |
| 1091 | 1162 |
| 1092 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && | 1163 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && |
| 1093 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { | 1164 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { |
| 1094 return true; | 1165 return true; |
| 1095 } | 1166 } |
| 1096 | 1167 |
| 1168 if (id >= IDC_OPEN_LINK_IN_PROFILE_FIRST && | |
| 1169 id <= IDC_OPEN_LINK_IN_PROFILE_LAST) { | |
| 1170 return params_.link_url.is_valid(); | |
| 1171 } | |
| 1172 | |
| 1097 IncognitoModePrefs::Availability incognito_avail = | 1173 IncognitoModePrefs::Availability incognito_avail = |
| 1098 IncognitoModePrefs::GetAvailability(prefs); | 1174 IncognitoModePrefs::GetAvailability(prefs); |
| 1099 switch (id) { | 1175 switch (id) { |
| 1100 case IDC_BACK: | 1176 case IDC_BACK: |
| 1101 return embedder_web_contents_->GetController().CanGoBack(); | 1177 return embedder_web_contents_->GetController().CanGoBack(); |
| 1102 | 1178 |
| 1103 case IDC_FORWARD: | 1179 case IDC_FORWARD: |
| 1104 return embedder_web_contents_->GetController().CanGoForward(); | 1180 return embedder_web_contents_->GetController().CanGoForward(); |
| 1105 | 1181 |
| 1106 case IDC_RELOAD: { | 1182 case IDC_RELOAD: { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1153 // There are some application locales which can't be used as a | 1229 // There are some application locales which can't be used as a |
| 1154 // target language for translation. | 1230 // target language for translation. |
| 1155 translate::TranslateDownloadManager::IsSupportedLanguage( | 1231 translate::TranslateDownloadManager::IsSupportedLanguage( |
| 1156 target_lang) && | 1232 target_lang) && |
| 1157 // Disable on the Instant Extended NTP. | 1233 // Disable on the Instant Extended NTP. |
| 1158 !chrome::IsInstantNTP(embedder_web_contents_); | 1234 !chrome::IsInstantNTP(embedder_web_contents_); |
| 1159 } | 1235 } |
| 1160 | 1236 |
| 1161 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: | 1237 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: |
| 1162 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: | 1238 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: |
| 1239 case IDC_CONTENT_CONTEXT_OPENLINKINPROFILE: | |
| 1163 return params_.link_url.is_valid(); | 1240 return params_.link_url.is_valid(); |
| 1164 | 1241 |
| 1165 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: | 1242 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: |
| 1166 return params_.unfiltered_link_url.is_valid(); | 1243 return params_.unfiltered_link_url.is_valid(); |
| 1167 | 1244 |
| 1168 case IDC_CONTENT_CONTEXT_SAVELINKAS: { | 1245 case IDC_CONTENT_CONTEXT_SAVELINKAS: { |
| 1169 PrefService* local_state = g_browser_process->local_state(); | 1246 PrefService* local_state = g_browser_process->local_state(); |
| 1170 DCHECK(local_state); | 1247 DCHECK(local_state); |
| 1171 // Test if file-selection dialogs are forbidden by policy. | 1248 // Test if file-selection dialogs are forbidden by policy. |
| 1172 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1249 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1410 int handlerIndex = id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; | 1487 int handlerIndex = id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; |
| 1411 WindowOpenDisposition disposition = | 1488 WindowOpenDisposition disposition = |
| 1412 ForceNewTabDispositionFromEventFlags(event_flags); | 1489 ForceNewTabDispositionFromEventFlags(event_flags); |
| 1413 OpenURL(handlers[handlerIndex].TranslateUrl(params_.link_url), | 1490 OpenURL(handlers[handlerIndex].TranslateUrl(params_.link_url), |
| 1414 GetDocumentURL(params_), | 1491 GetDocumentURL(params_), |
| 1415 disposition, | 1492 disposition, |
| 1416 ui::PAGE_TRANSITION_LINK); | 1493 ui::PAGE_TRANSITION_LINK); |
| 1417 return; | 1494 return; |
| 1418 } | 1495 } |
| 1419 | 1496 |
| 1497 if (id >= IDC_OPEN_LINK_IN_PROFILE_FIRST && | |
| 1498 id <= IDC_OPEN_LINK_IN_PROFILE_LAST) { | |
| 1499 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 1500 ProfileInfoCache& profile_info_cache = | |
| 1501 profile_manager->GetProfileInfoCache(); | |
| 1502 | |
| 1503 base::FilePath profile_path = profile_info_cache.GetPathOfProfileAtIndex( | |
| 1504 id - IDC_OPEN_LINK_IN_PROFILE_FIRST); | |
| 1505 Profile* profile = profile_manager->GetProfileByPath(profile_path); | |
| 1506 DCHECK(profile); | |
| 1507 | |
| 1508 chrome::HostDesktopType desktop_type = | |
| 1509 chrome::FindBrowserWithWebContents(source_web_contents_) | |
|
Peter Kasting
2015/06/15 23:45:15
The code below for IDC_CONTENT_CONTEXT_OPENLINKNEW
jochen (gone - plz use gerrit)
2015/06/16 08:00:13
fair point. I'm getting the desktop_top from the n
| |
| 1510 ->host_desktop_type(); | |
| 1511 | |
| 1512 Browser* browser = chrome::FindLastActiveWithProfile(profile, desktop_type); | |
| 1513 chrome::NavigateParams nav_params(browser, params_.link_url, | |
| 1514 ui::PAGE_TRANSITION_LINK); | |
| 1515 nav_params.disposition = NEW_FOREGROUND_TAB; | |
| 1516 nav_params.referrer = content::Referrer::SanitizeForRequest( | |
| 1517 params_.link_url, | |
| 1518 content::Referrer(GetDocumentURL(params_).GetAsReferrer(), | |
| 1519 params_.referrer_policy)); | |
| 1520 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; | |
| 1521 if (!browser) { | |
| 1522 profiles::FindOrCreateNewWindowForProfile( | |
| 1523 profile, chrome::startup::IS_NOT_PROCESS_STARTUP, | |
| 1524 chrome::startup::IS_NOT_FIRST_RUN, desktop_type, | |
| 1525 false /* always_create */); | |
| 1526 nav_params.browser = | |
| 1527 chrome::FindLastActiveWithProfile(profile, desktop_type); | |
| 1528 DCHECK(nav_params.browser); | |
| 1529 nav_params.disposition = CURRENT_TAB; | |
| 1530 } | |
| 1531 chrome::Navigate(&nav_params); | |
| 1532 return; | |
| 1533 } | |
| 1534 | |
| 1420 switch (id) { | 1535 switch (id) { |
| 1421 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: { | 1536 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: { |
| 1422 Browser* browser = | 1537 Browser* browser = |
| 1423 chrome::FindBrowserWithWebContents(source_web_contents_); | 1538 chrome::FindBrowserWithWebContents(source_web_contents_); |
| 1424 OpenURL(params_.link_url, | 1539 OpenURL(params_.link_url, |
| 1425 GetDocumentURL(params_), | 1540 GetDocumentURL(params_), |
| 1426 !browser || browser->is_app() ? | 1541 !browser || browser->is_app() ? |
| 1427 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB, | 1542 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB, |
| 1428 ui::PAGE_TRANSITION_LINK); | 1543 ui::PAGE_TRANSITION_LINK); |
| 1429 break; | 1544 break; |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1910 source_web_contents_->GetRenderViewHost()-> | 2025 source_web_contents_->GetRenderViewHost()-> |
| 1911 ExecuteMediaPlayerActionAtLocation(location, action); | 2026 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1912 } | 2027 } |
| 1913 | 2028 |
| 1914 void RenderViewContextMenu::PluginActionAt( | 2029 void RenderViewContextMenu::PluginActionAt( |
| 1915 const gfx::Point& location, | 2030 const gfx::Point& location, |
| 1916 const WebPluginAction& action) { | 2031 const WebPluginAction& action) { |
| 1917 source_web_contents_->GetRenderViewHost()-> | 2032 source_web_contents_->GetRenderViewHost()-> |
| 1918 ExecutePluginActionAtLocation(location, action); | 2033 ExecutePluginActionAtLocation(location, action); |
| 1919 } | 2034 } |
| OLD | NEW |