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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 998 } | 998 } |
| 999 UMA_HISTOGRAM_ENUMERATION( | 999 UMA_HISTOGRAM_ENUMERATION( |
| 1000 "RenderViewContextMenu.OpenLinkAsUserProfilesState", profiles_state, | 1000 "RenderViewContextMenu.OpenLinkAsUserProfilesState", profiles_state, |
| 1001 OPEN_LINK_AS_USER_PROFILES_STATE_LAST_ENUM_ID); | 1001 OPEN_LINK_AS_USER_PROFILES_STATE_LAST_ENUM_ID); |
| 1002 | 1002 |
| 1003 UMA_HISTOGRAM_ENUMERATION("RenderViewContextMenu.OpenLinkAsUserShown", | 1003 UMA_HISTOGRAM_ENUMERATION("RenderViewContextMenu.OpenLinkAsUserShown", |
| 1004 target_profiles_entries.size(), | 1004 target_profiles_entries.size(), |
| 1005 kOpenLinkAsUserMaxProfilesReported); | 1005 kOpenLinkAsUserMaxProfilesReported); |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 if (target_profiles_entries.size() == 1u) { | 1008 if (multiple_profiles_open_) { |
|
Peter Kasting
2016/06/22 22:53:21
Nit: If you change this to "if (multiple_profiles_
jochen (gone - plz use gerrit)
2016/06/23 09:21:07
the idea is that you need to have at least one add
Peter Kasting
2016/06/23 09:26:13
I don't understand how this reply has anything to
Peter Kasting
2016/06/23 09:39:02
Please reply on the comment thread in question nex
jochen (gone - plz use gerrit)
2016/06/23 09:43:33
ah, thanks for clarifying. updated the CL.
| |
| 1009 int menu_index = static_cast<int>(profile_link_paths_.size()); | 1009 if (target_profiles_entries.size() == 1u) { |
|
Peter Kasting
2016/06/22 22:53:21
Nit: Remove 'u' suffix (2 places)
| |
| 1010 ProfileAttributesEntry* entry = target_profiles_entries.front(); | |
| 1011 profile_link_paths_.push_back(entry->GetPath()); | |
| 1012 menu_model_.AddItem( | |
| 1013 IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, | |
| 1014 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_OPENLINKINPROFILE, | |
| 1015 entry->GetName())); | |
| 1016 AddAvatarToLastMenuItem(entry->GetAvatarIcon(), &menu_model_); | |
| 1017 } else if (target_profiles_entries.size() > 1u) { | |
| 1018 for (ProfileAttributesEntry* entry : target_profiles_entries) { | |
| 1019 int menu_index = static_cast<int>(profile_link_paths_.size()); | 1010 int menu_index = static_cast<int>(profile_link_paths_.size()); |
| 1020 // In extreme cases, we might have more profiles than available | 1011 ProfileAttributesEntry* entry = target_profiles_entries.front(); |
| 1021 // command ids. In that case, just stop creating new entries - the | 1012 profile_link_paths_.push_back(entry->GetPath()); |
| 1022 // menu is probably useless at this point already. | 1013 menu_model_.AddItem( |
| 1023 if (IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index > | 1014 IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, |
| 1024 IDC_OPEN_LINK_IN_PROFILE_LAST) { | 1015 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_OPENLINKINPROFILE, |
| 1025 break; | 1016 entry->GetName())); |
| 1017 AddAvatarToLastMenuItem(entry->GetAvatarIcon(), &menu_model_); | |
| 1018 } else if (target_profiles_entries.size() > 1u) { | |
| 1019 for (ProfileAttributesEntry* entry : target_profiles_entries) { | |
| 1020 int menu_index = static_cast<int>(profile_link_paths_.size()); | |
| 1021 // In extreme cases, we might have more profiles than available | |
| 1022 // command ids. In that case, just stop creating new entries - the | |
| 1023 // menu is probably useless at this point already. | |
| 1024 if (IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index > | |
| 1025 IDC_OPEN_LINK_IN_PROFILE_LAST) { | |
| 1026 break; | |
| 1027 } | |
| 1028 profile_link_paths_.push_back(entry->GetPath()); | |
| 1029 profile_link_submenu_model_.AddItem( | |
| 1030 IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, entry->GetName()); | |
| 1031 AddAvatarToLastMenuItem(entry->GetAvatarIcon(), | |
| 1032 &profile_link_submenu_model_); | |
| 1026 } | 1033 } |
| 1027 profile_link_paths_.push_back(entry->GetPath()); | 1034 menu_model_.AddSubMenuWithStringId( |
| 1028 profile_link_submenu_model_.AddItem( | 1035 IDC_CONTENT_CONTEXT_OPENLINKINPROFILE, |
| 1029 IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, entry->GetName()); | 1036 IDS_CONTENT_CONTEXT_OPENLINKINPROFILES, |
| 1030 AddAvatarToLastMenuItem(entry->GetAvatarIcon(), | 1037 &profile_link_submenu_model_); |
| 1031 &profile_link_submenu_model_); | |
| 1032 } | 1038 } |
| 1033 menu_model_.AddSubMenuWithStringId( | |
| 1034 IDC_CONTENT_CONTEXT_OPENLINKINPROFILE, | |
| 1035 IDS_CONTENT_CONTEXT_OPENLINKINPROFILES, | |
| 1036 &profile_link_submenu_model_); | |
| 1037 } | 1039 } |
| 1038 } | 1040 } |
| 1039 #endif // !defined(OS_CHROMEOS) | 1041 #endif // !defined(OS_CHROMEOS) |
| 1040 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 1042 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| 1041 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, | 1043 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, |
| 1042 IDS_CONTENT_CONTEXT_SAVELINKAS); | 1044 IDS_CONTENT_CONTEXT_SAVELINKAS); |
| 1043 } | 1045 } |
| 1044 | 1046 |
| 1045 menu_model_.AddItemWithStringId( | 1047 menu_model_.AddItemWithStringId( |
| 1046 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, | 1048 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2390 source_web_contents_->GetRenderViewHost()-> | 2392 source_web_contents_->GetRenderViewHost()-> |
| 2391 ExecuteMediaPlayerActionAtLocation(location, action); | 2393 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2392 } | 2394 } |
| 2393 | 2395 |
| 2394 void RenderViewContextMenu::PluginActionAt( | 2396 void RenderViewContextMenu::PluginActionAt( |
| 2395 const gfx::Point& location, | 2397 const gfx::Point& location, |
| 2396 const WebPluginAction& action) { | 2398 const WebPluginAction& action) { |
| 2397 source_web_contents_->GetRenderViewHost()-> | 2399 source_web_contents_->GetRenderViewHost()-> |
| 2398 ExecutePluginActionAtLocation(location, action); | 2400 ExecutePluginActionAtLocation(location, action); |
| 2399 } | 2401 } |
| OLD | NEW |