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

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

Issue 1357393002: Desktop context menu reorganisation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 20 matching lines...) Expand all
31 #include "chrome/browser/extensions/devtools_util.h" 31 #include "chrome/browser/extensions/devtools_util.h"
32 #include "chrome/browser/extensions/extension_service.h" 32 #include "chrome/browser/extensions/extension_service.h"
33 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 33 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
35 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 35 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
36 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 36 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
37 #include "chrome/browser/prefs/incognito_mode_prefs.h" 37 #include "chrome/browser/prefs/incognito_mode_prefs.h"
38 #include "chrome/browser/profiles/profile.h" 38 #include "chrome/browser/profiles/profile.h"
39 #include "chrome/browser/profiles/profile_io_data.h" 39 #include "chrome/browser/profiles/profile_io_data.h"
40 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory .h" 40 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory .h"
41 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h"
42 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" 41 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h"
43 #include "chrome/browser/search/search.h" 42 #include "chrome/browser/search/search.h"
44 #include "chrome/browser/search_engines/template_url_service_factory.h" 43 #include "chrome/browser/search_engines/template_url_service_factory.h"
45 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" 44 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
46 #include "chrome/browser/spellchecker/spellcheck_service.h" 45 #include "chrome/browser/spellchecker/spellcheck_service.h"
47 #include "chrome/browser/ssl/security_state_model.h" 46 #include "chrome/browser/ssl/security_state_model.h"
48 #include "chrome/browser/tab_contents/retargeting_details.h" 47 #include "chrome/browser/tab_contents/retargeting_details.h"
49 #include "chrome/browser/translate/chrome_translate_client.h" 48 #include "chrome/browser/translate/chrome_translate_client.h"
50 #include "chrome/browser/translate/translate_service.h" 49 #include "chrome/browser/translate/translate_service.h"
51 #include "chrome/browser/ui/browser.h" 50 #include "chrome/browser/ui/browser.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 147
149 const int kImageSearchThumbnailMinSize = 300 * 300; 148 const int kImageSearchThumbnailMinSize = 300 * 300;
150 const int kImageSearchThumbnailMaxWidth = 600; 149 const int kImageSearchThumbnailMaxWidth = 600;
151 const int kImageSearchThumbnailMaxHeight = 600; 150 const int kImageSearchThumbnailMaxHeight = 600;
152 151
153 // Maps UMA enumeration to IDC. IDC could be changed so we can't use 152 // Maps UMA enumeration to IDC. IDC could be changed so we can't use
154 // just them and |UMA_HISTOGRAM_CUSTOM_ENUMERATION|. 153 // just them and |UMA_HISTOGRAM_CUSTOM_ENUMERATION|.
155 // Never change mapping or reuse |enum_id|. Always push back new items. 154 // Never change mapping or reuse |enum_id|. Always push back new items.
156 // Items that is not used any more by |RenderViewContextMenu.ExecuteCommand| 155 // Items that is not used any more by |RenderViewContextMenu.ExecuteCommand|
157 // could be deleted, but don't change the rest of |kUmaEnumToControlId|. 156 // could be deleted, but don't change the rest of |kUmaEnumToControlId|.
157 //
158 // |context_specific_enum_id| matches the ContextMenuOption histogram enum.
159 // Used to track command usage under specific contexts - Specifically Menu
Avi (use Gerrit) 2015/09/26 02:26:15 "... specific contexts, specifically menu items...
edwardjung 2015/09/28 14:11:25 Done.
160 // items under 'link + image' and 'selected text'.
158 const struct UmaEnumCommandIdPair { 161 const struct UmaEnumCommandIdPair {
159 int enum_id; 162 int enum_id;
160 int control_id; 163 int control_id;
164 int context_specific_enum_id;
Avi (use Gerrit) 2015/09/26 02:26:15 This order makes it hard to read the list. Do: co
edwardjung 2015/09/28 14:11:25 Makes sense, done.
161 } kUmaEnumToControlId[] = { 165 } kUmaEnumToControlId[] = {
162 /* 166 /*
163 enum id for 0, 1 are detected using 167 enum id for 0, 1 are detected using
164 RenderViewContextMenu::IsContentCustomCommandId and 168 RenderViewContextMenu::IsContentCustomCommandId and
165 ContextMenuMatcher::IsExtensionsCustomCommandId 169 ContextMenuMatcher::IsExtensionsCustomCommandId
166 */ 170 */
167 {2, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST}, 171 {2, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST},
168 {3, IDC_CONTENT_CONTEXT_OPENLINKNEWTAB}, 172 {3, IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0},
169 {4, IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW}, 173 {4, IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, 15},
170 {5, IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD}, 174 {5, IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 1},
171 {6, IDC_CONTENT_CONTEXT_SAVELINKAS}, 175 {6, IDC_CONTENT_CONTEXT_SAVELINKAS, 5},
172 {7, IDC_CONTENT_CONTEXT_SAVEAVAS}, 176 {7, IDC_CONTENT_CONTEXT_SAVEAVAS, 17},
173 {8, IDC_CONTENT_CONTEXT_SAVEIMAGEAS}, 177 {8, IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 6},
174 {9, IDC_CONTENT_CONTEXT_COPYLINKLOCATION}, 178 {9, IDC_CONTENT_CONTEXT_COPYLINKLOCATION, 2},
175 {10, IDC_CONTENT_CONTEXT_COPYIMAGELOCATION}, 179 {10, IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, 10},
176 {11, IDC_CONTENT_CONTEXT_COPYAVLOCATION}, 180 {11, IDC_CONTENT_CONTEXT_COPYAVLOCATION},
177 {12, IDC_CONTENT_CONTEXT_COPYIMAGE}, 181 {12, IDC_CONTENT_CONTEXT_COPYIMAGE, 9},
178 {13, IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB}, 182 {13, IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, 8},
179 {14, IDC_CONTENT_CONTEXT_OPENAVNEWTAB}, 183 {14, IDC_CONTENT_CONTEXT_OPENAVNEWTAB},
180 {15, IDC_CONTENT_CONTEXT_PLAYPAUSE}, 184 {15, IDC_CONTENT_CONTEXT_PLAYPAUSE},
181 {16, IDC_CONTENT_CONTEXT_MUTE}, 185 {16, IDC_CONTENT_CONTEXT_MUTE},
182 {17, IDC_CONTENT_CONTEXT_LOOP}, 186 {17, IDC_CONTENT_CONTEXT_LOOP},
183 {18, IDC_CONTENT_CONTEXT_CONTROLS}, 187 {18, IDC_CONTENT_CONTEXT_CONTROLS},
184 {19, IDC_CONTENT_CONTEXT_ROTATECW}, 188 {19, IDC_CONTENT_CONTEXT_ROTATECW},
185 {20, IDC_CONTENT_CONTEXT_ROTATECCW}, 189 {20, IDC_CONTENT_CONTEXT_ROTATECCW},
186 {21, IDC_BACK}, 190 {21, IDC_BACK},
187 {22, IDC_FORWARD}, 191 {22, IDC_FORWARD},
188 {23, IDC_SAVE_PAGE}, 192 {23, IDC_SAVE_PAGE},
189 {24, IDC_RELOAD}, 193 {24, IDC_RELOAD},
190 {25, IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP}, 194 {25, IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP},
191 {26, IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP}, 195 {26, IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP},
192 {27, IDC_PRINT}, 196 {27, IDC_PRINT, 16},
193 {28, IDC_VIEW_SOURCE}, 197 {28, IDC_VIEW_SOURCE},
194 {29, IDC_CONTENT_CONTEXT_INSPECTELEMENT}, 198 {29, IDC_CONTENT_CONTEXT_INSPECTELEMENT},
195 {30, IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE}, 199 {30, IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE},
196 {31, IDC_CONTENT_CONTEXT_VIEWPAGEINFO}, 200 {31, IDC_CONTENT_CONTEXT_VIEWPAGEINFO},
197 {32, IDC_CONTENT_CONTEXT_TRANSLATE}, 201 {32, IDC_CONTENT_CONTEXT_TRANSLATE},
198 {33, IDC_CONTENT_CONTEXT_RELOADFRAME}, 202 {33, IDC_CONTENT_CONTEXT_RELOADFRAME},
199 {34, IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE}, 203 {34, IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE},
200 {35, IDC_CONTENT_CONTEXT_VIEWFRAMEINFO}, 204 {35, IDC_CONTENT_CONTEXT_VIEWFRAMEINFO},
201 {36, IDC_CONTENT_CONTEXT_UNDO}, 205 {36, IDC_CONTENT_CONTEXT_UNDO},
202 {37, IDC_CONTENT_CONTEXT_REDO}, 206 {37, IDC_CONTENT_CONTEXT_REDO},
203 {38, IDC_CONTENT_CONTEXT_CUT}, 207 {38, IDC_CONTENT_CONTEXT_CUT},
204 {39, IDC_CONTENT_CONTEXT_COPY}, 208 {39, IDC_CONTENT_CONTEXT_COPY, 4},
205 {40, IDC_CONTENT_CONTEXT_PASTE}, 209 {40, IDC_CONTENT_CONTEXT_PASTE},
206 {41, IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE}, 210 {41, IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE},
207 {42, IDC_CONTENT_CONTEXT_DELETE}, 211 {42, IDC_CONTENT_CONTEXT_DELETE},
208 {43, IDC_CONTENT_CONTEXT_SELECTALL}, 212 {43, IDC_CONTENT_CONTEXT_SELECTALL},
209 {44, IDC_CONTENT_CONTEXT_SEARCHWEBFOR}, 213 {44, IDC_CONTENT_CONTEXT_SEARCHWEBFOR, 17},
210 {45, IDC_CONTENT_CONTEXT_GOTOURL}, 214 {45, IDC_CONTENT_CONTEXT_GOTOURL},
211 {46, IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS}, 215 {46, IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS},
212 {47, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS}, 216 {47, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS},
213 {48, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE}, 217 {48, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE},
214 {52, IDC_CONTENT_CONTEXT_OPENLINKWITH}, 218 {52, IDC_CONTENT_CONTEXT_OPENLINKWITH},
215 {53, IDC_CHECK_SPELLING_WHILE_TYPING}, 219 {53, IDC_CHECK_SPELLING_WHILE_TYPING},
216 {54, IDC_SPELLCHECK_MENU}, 220 {54, IDC_SPELLCHECK_MENU},
217 {55, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE}, 221 {55, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE},
218 {56, IDC_SPELLCHECK_LANGUAGES_FIRST}, 222 {56, IDC_SPELLCHECK_LANGUAGES_FIRST},
219 {57, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE}, 223 {57, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, 11},
220 {58, IDC_SPELLCHECK_SUGGESTION_0}, 224 {58, IDC_SPELLCHECK_SUGGESTION_0},
221 {59, IDC_SPELLCHECK_ADD_TO_DICTIONARY}, 225 {59, IDC_SPELLCHECK_ADD_TO_DICTIONARY},
222 {60, IDC_SPELLPANEL_TOGGLE}, 226 {60, IDC_SPELLPANEL_TOGGLE},
223 {61, IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB}, 227 {61, IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB},
224 {62, IDC_WRITING_DIRECTION_MENU}, 228 {62, IDC_WRITING_DIRECTION_MENU},
225 {63, IDC_WRITING_DIRECTION_DEFAULT}, 229 {63, IDC_WRITING_DIRECTION_DEFAULT},
226 {64, IDC_WRITING_DIRECTION_LTR}, 230 {64, IDC_WRITING_DIRECTION_LTR},
227 {65, IDC_WRITING_DIRECTION_RTL}, 231 {65, IDC_WRITING_DIRECTION_RTL},
228 {66, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, 232 {66, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE},
229 {67, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, 233 {67, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD},
(...skipping 19 matching lines...) Expand all
249 253
250 if (id >= IDC_SPELLCHECK_SUGGESTION_0 && 254 if (id >= IDC_SPELLCHECK_SUGGESTION_0 &&
251 id <= IDC_SPELLCHECK_SUGGESTION_LAST) { 255 id <= IDC_SPELLCHECK_SUGGESTION_LAST) {
252 return IDC_SPELLCHECK_SUGGESTION_0; 256 return IDC_SPELLCHECK_SUGGESTION_0;
253 } 257 }
254 258
255 return id; 259 return id;
256 } 260 }
257 261
258 // Returns UMA enum value for command specified by |id| or -1 if not found. 262 // Returns UMA enum value for command specified by |id| or -1 if not found.
259 int FindUMAEnumValueForCommand(int id) { 263 // |use_specific_context_enum| set to true returns the context_specific_enum_id.
264 int FindUMAEnumValueForCommand(int id, bool use_specific_context_enum) {
Avi (use Gerrit) 2015/09/26 02:26:15 This is a magic bool as a parameter that is imposs
edwardjung 2015/09/28 14:11:25 Understood. Changed to use an enum.
260 if (RenderViewContextMenu::IsContentCustomCommandId(id)) 265 if (RenderViewContextMenu::IsContentCustomCommandId(id))
261 return 0; 266 return 0;
262 267
263 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) 268 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id))
264 return 1; 269 return 1;
265 270
266 id = CollapseCommandsForUMA(id); 271 id = CollapseCommandsForUMA(id);
267 const size_t kMappingSize = arraysize(kUmaEnumToControlId); 272 const size_t kMappingSize = arraysize(kUmaEnumToControlId);
268 for (size_t i = 0; i < kMappingSize; ++i) { 273 for (size_t i = 0; i < kMappingSize; ++i) {
269 if (kUmaEnumToControlId[i].control_id == id) { 274 if (kUmaEnumToControlId[i].control_id == id) {
270 return kUmaEnumToControlId[i].enum_id; 275 if (!use_specific_context_enum) {
276 return kUmaEnumToControlId[i].enum_id;
277 } else if (use_specific_context_enum &&
278 kUmaEnumToControlId[i].context_specific_enum_id > -1) {
Avi (use Gerrit) 2015/09/26 02:26:15 How could this ever not be true? In most of the li
edwardjung 2015/09/28 14:11:25 Understood. Fixed.
279 return kUmaEnumToControlId[i].context_specific_enum_id;
280 }
271 } 281 }
272 } 282 }
283
273 return -1; 284 return -1;
274 } 285 }
275 286
276 // Usually a new tab is expected where this function is used, 287 // Usually a new tab is expected where this function is used,
277 // however users should be able to open a tab in background 288 // however users should be able to open a tab in background
278 // or in a new window. 289 // or in a new window.
279 WindowOpenDisposition ForceNewTabDispositionFromEventFlags( 290 WindowOpenDisposition ForceNewTabDispositionFromEventFlags(
280 int event_flags) { 291 int event_flags) {
281 WindowOpenDisposition disposition = 292 WindowOpenDisposition disposition =
282 ui::DispositionFromEventFlags(event_flags); 293 ui::DispositionFromEventFlags(event_flags);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 : url_formatter::FormatUrl( 345 : url_formatter::FormatUrl(
335 url, languages, url_formatter::kFormatUrlOmitNothing, 346 url, languages, url_formatter::kFormatUrlOmitNothing,
336 net::UnescapeRule::NONE, nullptr, nullptr, nullptr); 347 net::UnescapeRule::NONE, nullptr, nullptr, nullptr);
337 348
338 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); 349 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE);
339 scw.WriteURL(text); 350 scw.WriteURL(text);
340 } 351 }
341 352
342 bool g_custom_id_ranges_initialized = false; 353 bool g_custom_id_ranges_initialized = false;
343 354
344 const int kSpellcheckRadioGroup = 1;
345
346 } // namespace 355 } // namespace
347 356
348 // static 357 // static
349 gfx::Vector2d RenderViewContextMenu::GetOffset( 358 gfx::Vector2d RenderViewContextMenu::GetOffset(
350 RenderFrameHost* render_frame_host) { 359 RenderFrameHost* render_frame_host) {
351 gfx::Vector2d offset; 360 gfx::Vector2d offset;
352 #if defined(ENABLE_EXTENSIONS) 361 #if defined(ENABLE_EXTENSIONS)
353 WebContents* web_contents = 362 WebContents* web_contents =
354 WebContents::FromRenderFrameHost(render_frame_host); 363 WebContents::FromRenderFrameHost(render_frame_host);
355 WebContents* top_level_web_contents = 364 WebContents* top_level_web_contents =
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 false /* is_action_menu */); 560 false /* is_action_menu */);
552 } 561 }
553 #endif // defined(ENABLE_EXTENSIONS) 562 #endif // defined(ENABLE_EXTENSIONS)
554 563
555 void RenderViewContextMenu::InitMenu() { 564 void RenderViewContextMenu::InitMenu() {
556 RenderViewContextMenuBase::InitMenu(); 565 RenderViewContextMenuBase::InitMenu();
557 566
558 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) 567 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE))
559 AppendPageItems(); 568 AppendPageItems();
560 569
561 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) {
562 // Merge in frame items with page items if we clicked within a frame that
563 // needs them.
564 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
565 AppendFrameItems();
566 }
567
568 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) { 570 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) {
569 AppendLinkItems(); 571 AppendLinkItems();
570 if (params_.media_type != WebContextMenuData::MediaTypeNone) 572 if (params_.media_type != WebContextMenuData::MediaTypeNone)
571 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 573 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
572 } 574 }
573 575
574 if (content_type_->SupportsGroup( 576 if (content_type_->SupportsGroup(
575 ContextMenuContentType::ITEM_GROUP_MEDIA_IMAGE)) { 577 ContextMenuContentType::ITEM_GROUP_MEDIA_IMAGE)) {
576 AppendImageItems(); 578 AppendImageItems();
577 } 579 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 DCHECK(!content_type_->SupportsGroup( 612 DCHECK(!content_type_->SupportsGroup(
611 ContextMenuContentType::ITEM_GROUP_EDITABLE)); 613 ContextMenuContentType::ITEM_GROUP_EDITABLE));
612 AppendCopyItem(); 614 AppendCopyItem();
613 } 615 }
614 616
615 if (content_type_->SupportsGroup( 617 if (content_type_->SupportsGroup(
616 ContextMenuContentType::ITEM_GROUP_SEARCH_PROVIDER)) { 618 ContextMenuContentType::ITEM_GROUP_SEARCH_PROVIDER)) {
617 AppendSearchProvider(); 619 AppendSearchProvider();
618 } 620 }
619 621
620 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT)) 622 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT) &&
623 !content_type_->SupportsGroup(
624 ContextMenuContentType::ITEM_GROUP_MEDIA_IMAGE)) {
621 AppendPrintItem(); 625 AppendPrintItem();
626 }
627
628 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_EDITABLE))
629 {
630 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
631 AppendPlatformEditableItems();
632 AppendLanguageSettings();
633 }
Avi (use Gerrit) 2015/09/26 02:26:15 Your indenting is wack; please fix.
edwardjung 2015/09/28 14:11:25 Done.
622 634
623 if (content_type_->SupportsGroup( 635 if (content_type_->SupportsGroup(
624 ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { 636 ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) {
625 AppendRotationItems(); 637 AppendRotationItems();
626 } 638 }
627 639
628 if (content_type_->SupportsGroup( 640 if (content_type_->SupportsGroup(
629 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)) { 641 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)) {
630 DCHECK(!content_type_->SupportsGroup( 642 DCHECK(!content_type_->SupportsGroup(
631 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)); 643 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION));
(...skipping 26 matching lines...) Expand all
658 ContextMenuContentType::ITEM_GROUP_PASSWORD)) { 670 ContextMenuContentType::ITEM_GROUP_PASSWORD)) {
659 AppendPasswordItems(); 671 AppendPasswordItems();
660 } 672 }
661 } 673 }
662 674
663 Profile* RenderViewContextMenu::GetProfile() { 675 Profile* RenderViewContextMenu::GetProfile() {
664 return Profile::FromBrowserContext(browser_context_); 676 return Profile::FromBrowserContext(browser_context_);
665 } 677 }
666 678
667 void RenderViewContextMenu::RecordUsedItem(int id) { 679 void RenderViewContextMenu::RecordUsedItem(int id) {
668 int enum_id = FindUMAEnumValueForCommand(id); 680 int enum_id = FindUMAEnumValueForCommand(id, false);
669 if (enum_id != -1) { 681 if (enum_id != -1) {
670 const size_t kMappingSize = arraysize(kUmaEnumToControlId); 682 const size_t kMappingSize = arraysize(kUmaEnumToControlId);
671 UMA_HISTOGRAM_ENUMERATION("RenderViewContextMenu.Used", enum_id, 683 UMA_HISTOGRAM_ENUMERATION("RenderViewContextMenu.Used", enum_id,
672 kUmaEnumToControlId[kMappingSize - 1].enum_id); 684 kUmaEnumToControlId[kMappingSize - 1].enum_id);
685 // Record to additional context specific histograms.
686 enum_id = FindUMAEnumValueForCommand(id, true);
687
688 // Linked image context.
689 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK) &&
690 content_type_->SupportsGroup(
691 ContextMenuContentType::ITEM_GROUP_MEDIA_IMAGE)) {
692 UMA_HISTOGRAM_ENUMERATION("ContextMenu.SelectedOption.ImageLink", enum_id,
693 kUmaEnumToControlId[kMappingSize - 1].enum_id);
694 }
695 // Selected text context.
696 if (content_type_->SupportsGroup(
697 ContextMenuContentType::ITEM_GROUP_SEARCH_PROVIDER) &&
698 content_type_->SupportsGroup(
699 ContextMenuContentType::ITEM_GROUP_PRINT)) {
Avi (use Gerrit) 2015/09/26 02:26:15 Your indenting is weird; you should indent line 69
edwardjung 2015/09/28 14:11:25 Done.
700 UMA_HISTOGRAM_ENUMERATION("ContextMenu.SelectedOption.SelectedText",
701 enum_id,
702 kUmaEnumToControlId[kMappingSize - 1].enum_id);
703 }
673 } else { 704 } else {
674 NOTREACHED() << "Update kUmaEnumToControlId. Unhanded IDC: " << id; 705 NOTREACHED() << "Update kUmaEnumToControlId. Unhanded IDC: " << id;
675 } 706 }
676 } 707 }
677 708
678 void RenderViewContextMenu::RecordShownItem(int id) { 709 void RenderViewContextMenu::RecordShownItem(int id) {
679 int enum_id = FindUMAEnumValueForCommand(id); 710 int enum_id = FindUMAEnumValueForCommand(id, false);
680 if (enum_id != -1) { 711 if (enum_id != -1) {
681 const size_t kMappingSize = arraysize(kUmaEnumToControlId); 712 const size_t kMappingSize = arraysize(kUmaEnumToControlId);
682 UMA_HISTOGRAM_ENUMERATION("RenderViewContextMenu.Shown", enum_id, 713 UMA_HISTOGRAM_ENUMERATION("RenderViewContextMenu.Shown", enum_id,
683 kUmaEnumToControlId[kMappingSize - 1].enum_id); 714 kUmaEnumToControlId[kMappingSize - 1].enum_id);
684 } else { 715 } else {
685 // Just warning here. It's harder to maintain list of all possibly 716 // Just warning here. It's harder to maintain list of all possibly
686 // visible items than executable items. 717 // visible items than executable items.
687 DLOG(ERROR) << "Update kUmaEnumToControlId. Unhanded IDC: " << id; 718 DLOG(ERROR) << "Update kUmaEnumToControlId. Unhanded IDC: " << id;
688 } 719 }
689 } 720 }
(...skipping 29 matching lines...) Expand all
719 #if defined(DEBUG_DEVTOOLS) 750 #if defined(DEBUG_DEVTOOLS)
720 show_developer_items = true; 751 show_developer_items = true;
721 #endif 752 #endif
722 753
723 if (!show_developer_items) 754 if (!show_developer_items)
724 return; 755 return;
725 756
726 // In the DevTools popup menu, "developer items" is normally the only 757 // In the DevTools popup menu, "developer items" is normally the only
727 // section, so omit the separator there. 758 // section, so omit the separator there.
728 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 759 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
760 // Page context source.
761 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE))
762 menu_model_.AddItemWithStringId(IDC_VIEW_SOURCE,
763 IDS_CONTENT_CONTEXT_VIEWPAGESOURCE);
764 // Frame context source.
765 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME))
766 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE,
767 IDS_CONTENT_CONTEXT_VIEWFRAMESOURCE);
Avi (use Gerrit) 2015/09/26 02:26:15 Are these useful comments? I would say no.
edwardjung 2015/09/28 14:11:25 Removed.
729 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTELEMENT, 768 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTELEMENT,
730 IDS_CONTENT_CONTEXT_INSPECTELEMENT); 769 IDS_CONTENT_CONTEXT_INSPECTELEMENT);
731 } 770 }
732 771
733 void RenderViewContextMenu::AppendDevtoolsForUnpackedExtensions() { 772 void RenderViewContextMenu::AppendDevtoolsForUnpackedExtensions() {
734 // Add a separator if there are any items already in the menu. 773 // Add a separator if there are any items already in the menu.
735 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 774 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
736 775
737 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP, 776 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP,
738 IDS_CONTENT_CONTEXT_RELOAD_PACKAGED_APP); 777 IDS_CONTENT_CONTEXT_RELOAD_PACKAGED_APP);
(...skipping 21 matching lines...) Expand all
760 } 799 }
761 800
762 menu_model_.AddItemWithStringId( 801 menu_model_.AddItemWithStringId(
763 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, 802 IDC_CONTENT_CONTEXT_COPYLINKLOCATION,
764 params_.link_url.SchemeIs(url::kMailToScheme) ? 803 params_.link_url.SchemeIs(url::kMailToScheme) ?
765 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : 804 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS :
766 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); 805 IDS_CONTENT_CONTEXT_COPYLINKLOCATION);
767 } 806 }
768 807
769 void RenderViewContextMenu::AppendImageItems() { 808 void RenderViewContextMenu::AppendImageItems() {
770 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS,
771 IDS_CONTENT_CONTEXT_SAVEIMAGEAS);
772 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION,
773 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION);
774 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE,
775 IDS_CONTENT_CONTEXT_COPYIMAGE);
776 std::map<std::string, std::string>::const_iterator it = 809 std::map<std::string, std::string>::const_iterator it =
777 params_.properties.find(data_reduction_proxy::chrome_proxy_header()); 810 params_.properties.find(data_reduction_proxy::chrome_proxy_header());
778 if (it != params_.properties.end() && it->second == 811 if (it != params_.properties.end() && it->second ==
779 data_reduction_proxy::chrome_proxy_lo_fi_directive()) { 812 data_reduction_proxy::chrome_proxy_lo_fi_directive()) {
780 menu_model_.AddItemWithStringId( 813 menu_model_.AddItemWithStringId(
781 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE, 814 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE,
782 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE); 815 IDS_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE);
783 } 816 }
784 DataReductionProxyChromeSettings* settings = 817 DataReductionProxyChromeSettings* settings =
785 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 818 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
786 browser_context_); 819 browser_context_);
787 if (settings && settings->CanUseDataReductionProxy(params_.src_url)) { 820 if (settings && settings->CanUseDataReductionProxy(params_.src_url)) {
788 menu_model_.AddItemWithStringId( 821 menu_model_.AddItemWithStringId(
789 IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB, 822 IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB,
790 IDS_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB); 823 IDS_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB);
791 } else { 824 } else {
792 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, 825 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB,
793 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); 826 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB);
794 } 827 }
828 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS,
829 IDS_CONTENT_CONTEXT_SAVEIMAGEAS);
830 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE,
831 IDS_CONTENT_CONTEXT_COPYIMAGE);
832 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION,
833 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION);
795 } 834 }
796 835
797 void RenderViewContextMenu::AppendSearchWebForImageItems() { 836 void RenderViewContextMenu::AppendSearchWebForImageItems() {
798 TemplateURLService* service = 837 TemplateURLService* service =
799 TemplateURLServiceFactory::GetForProfile(GetProfile()); 838 TemplateURLServiceFactory::GetForProfile(GetProfile());
800 const TemplateURL* const default_provider = 839 const TemplateURL* const default_provider =
801 service->GetDefaultSearchProvider(); 840 service->GetDefaultSearchProvider();
802 if (params_.has_image_contents && default_provider && 841 if (params_.has_image_contents && default_provider &&
803 !default_provider->image_url().empty() && 842 !default_provider->image_url().empty() &&
804 default_provider->image_url_ref().IsValid(service->search_terms_data())) { 843 default_provider->image_url_ref().IsValid(service->search_terms_data())) {
805 menu_model_.AddItem( 844 menu_model_.AddItem(
806 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, 845 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE,
807 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, 846 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE,
808 default_provider->short_name())); 847 default_provider->short_name()));
809 } 848 }
810 } 849 }
811 850
812 void RenderViewContextMenu::AppendAudioItems() { 851 void RenderViewContextMenu::AppendAudioItems() {
813 AppendMediaItems();
814 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 852 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
853 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB,
854 IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB);
815 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, 855 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS,
816 IDS_CONTENT_CONTEXT_SAVEAUDIOAS); 856 IDS_CONTENT_CONTEXT_SAVEAUDIOAS);
817 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, 857 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION,
818 IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION); 858 IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION);
819 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB,
820 IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB);
821 } 859 }
822 860
823 void RenderViewContextMenu::AppendCanvasItems() { 861 void RenderViewContextMenu::AppendCanvasItems() {
824 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 862 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS,
825 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); 863 IDS_CONTENT_CONTEXT_SAVEIMAGEAS);
826 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, 864 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE,
827 IDS_CONTENT_CONTEXT_COPYIMAGE); 865 IDS_CONTENT_CONTEXT_COPYIMAGE);
828 } 866 }
829 867
830 void RenderViewContextMenu::AppendVideoItems() { 868 void RenderViewContextMenu::AppendVideoItems() {
831 AppendMediaItems();
832 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 869 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
870 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB,
871 IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB);
833 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, 872 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS,
834 IDS_CONTENT_CONTEXT_SAVEVIDEOAS); 873 IDS_CONTENT_CONTEXT_SAVEVIDEOAS);
835 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, 874 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION,
836 IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION); 875 IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION);
837 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB,
838 IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB);
839 }
840
841 void RenderViewContextMenu::AppendMediaItems() {
842 int media_flags = params_.media_flags;
843
844 menu_model_.AddItemWithStringId(
845 IDC_CONTENT_CONTEXT_PLAYPAUSE,
846 media_flags & WebContextMenuData::MediaPaused ?
847 IDS_CONTENT_CONTEXT_PLAY :
848 IDS_CONTENT_CONTEXT_PAUSE);
849
850 menu_model_.AddItemWithStringId(
851 IDC_CONTENT_CONTEXT_MUTE,
852 media_flags & WebContextMenuData::MediaMuted ?
853 IDS_CONTENT_CONTEXT_UNMUTE :
854 IDS_CONTENT_CONTEXT_MUTE);
855
856 menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_LOOP,
857 IDS_CONTENT_CONTEXT_LOOP);
858 menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_CONTROLS,
859 IDS_CONTENT_CONTEXT_CONTROLS);
860 } 876 }
861 877
862 void RenderViewContextMenu::AppendPluginItems() { 878 void RenderViewContextMenu::AppendPluginItems() {
863 if (params_.page_url == params_.src_url || 879 if (params_.page_url == params_.src_url ||
864 guest_view::GuestViewBase::IsGuest(source_web_contents_)) { 880 guest_view::GuestViewBase::IsGuest(source_web_contents_)) {
865 // Full page plugin, so show page menu items. 881 // Full page plugin, so show page menu items.
866 if (params_.link_url.is_empty() && params_.selection_text.empty()) 882 if (params_.link_url.is_empty() && params_.selection_text.empty())
867 AppendPageItems(); 883 AppendPageItems();
868 } else { 884 } else {
869 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, 885 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS,
(...skipping 18 matching lines...) Expand all
888 904
889 if (TranslateService::IsTranslatableURL(params_.page_url)) { 905 if (TranslateService::IsTranslatableURL(params_.page_url)) {
890 std::string locale = g_browser_process->GetApplicationLocale(); 906 std::string locale = g_browser_process->GetApplicationLocale();
891 locale = translate::TranslateDownloadManager::GetLanguageCode(locale); 907 locale = translate::TranslateDownloadManager::GetLanguageCode(locale);
892 base::string16 language = 908 base::string16 language =
893 l10n_util::GetDisplayNameForLocale(locale, locale, true); 909 l10n_util::GetDisplayNameForLocale(locale, locale, true);
894 menu_model_.AddItem( 910 menu_model_.AddItem(
895 IDC_CONTENT_CONTEXT_TRANSLATE, 911 IDC_CONTENT_CONTEXT_TRANSLATE,
896 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_TRANSLATE, language)); 912 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_TRANSLATE, language));
897 } 913 }
898
899 menu_model_.AddItemWithStringId(IDC_VIEW_SOURCE,
900 IDS_CONTENT_CONTEXT_VIEWPAGESOURCE);
901 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_VIEWPAGEINFO,
902 IDS_CONTENT_CONTEXT_VIEWPAGEINFO);
903 }
904
905 void RenderViewContextMenu::AppendFrameItems() {
906 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RELOADFRAME,
907 IDS_CONTENT_CONTEXT_RELOADFRAME);
908 // These two menu items have yet to be implemented.
909 // http://code.google.com/p/chromium/issues/detail?id=11827
910 // IDS_CONTENT_CONTEXT_SAVEFRAMEAS
911 // IDS_CONTENT_CONTEXT_PRINTFRAME
912 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE,
913 IDS_CONTENT_CONTEXT_VIEWFRAMESOURCE);
914 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_VIEWFRAMEINFO,
915 IDS_CONTENT_CONTEXT_VIEWFRAMEINFO);
916 } 914 }
917 915
918 void RenderViewContextMenu::AppendCopyItem() { 916 void RenderViewContextMenu::AppendCopyItem() {
917 if (menu_model_.GetItemCount())
918 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
919 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPY, 919 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPY,
920 IDS_CONTENT_CONTEXT_COPY); 920 IDS_CONTENT_CONTEXT_COPY);
921 } 921 }
922 922
923 void RenderViewContextMenu::AppendPrintItem() { 923 void RenderViewContextMenu::AppendPrintItem() {
924 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && 924 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) &&
925 (params_.media_type == WebContextMenuData::MediaTypeNone || 925 (params_.media_type == WebContextMenuData::MediaTypeNone ||
926 params_.media_flags & WebContextMenuData::MediaCanPrint)) { 926 params_.media_flags & WebContextMenuData::MediaCanPrint)) {
927 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); 927 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT);
928 } 928 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 } 986 }
987 } 987 }
988 } 988 }
989 989
990 void RenderViewContextMenu::AppendEditableItems() { 990 void RenderViewContextMenu::AppendEditableItems() {
991 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode(); 991 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode();
992 992
993 if (use_spellcheck_and_search) 993 if (use_spellcheck_and_search)
994 AppendSpellingSuggestionsSubMenu(); 994 AppendSpellingSuggestionsSubMenu();
995 995
996 if (!IsDevToolsURL(params_.page_url)) { 996 // 'Undo' and 'Redo' for tText input with no suggestions and no text selected.
Avi (use Gerrit) 2015/09/26 02:26:15 typo: tText
edwardjung 2015/09/28 14:11:25 Done.
997 // We make an exception for OSX as context clicking will select the closest
Avi (use Gerrit) 2015/09/26 02:26:15 s/OSX/Mac OS X/ or /OS X/ or /the Mac/
edwardjung 2015/09/28 14:11:25 Done.
998 // word. In this case both items are always shown.
999 #if defined(OS_MACOSX)
1000 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO,
1001 IDS_CONTENT_CONTEXT_UNDO);
1002 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO,
1003 IDS_CONTENT_CONTEXT_REDO);
1004 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1005 #else
1006 if (!IsDevToolsURL(params_.page_url) &&
1007 !menu_model_.GetItemCount() &&
1008 !content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT)) {
997 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, 1009 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO,
998 IDS_CONTENT_CONTEXT_UNDO); 1010 IDS_CONTENT_CONTEXT_UNDO);
999 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO, 1011 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO,
1000 IDS_CONTENT_CONTEXT_REDO); 1012 IDS_CONTENT_CONTEXT_REDO);
1001 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1013 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1002 } 1014 }
1015 #endif
1003 1016
1004 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_CUT, 1017 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_CUT,
1005 IDS_CONTENT_CONTEXT_CUT); 1018 IDS_CONTENT_CONTEXT_CUT);
1006 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPY, 1019 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPY,
1007 IDS_CONTENT_CONTEXT_COPY); 1020 IDS_CONTENT_CONTEXT_COPY);
1008 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE, 1021 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE,
1009 IDS_CONTENT_CONTEXT_PASTE); 1022 IDS_CONTENT_CONTEXT_PASTE);
1010 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, 1023 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE,
1011 IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE); 1024 IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE);
1012 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_DELETE, 1025 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL,
1013 IDS_CONTENT_CONTEXT_DELETE); 1026 IDS_CONTENT_CONTEXT_SELECTALL);
1014 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1015
1016 if (use_spellcheck_and_search && !params_.keyword_url.is_empty()) {
1017 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ADDSEARCHENGINE,
1018 IDS_CONTENT_CONTEXT_ADDSEARCHENGINE);
1019 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1020 }
1021
1022 #if defined(OS_MACOSX)
1023 if (use_spellcheck_and_search)
1024 AppendSpellcheckOptionsSubMenu();
1025 #else
1026 if (chrome::spellcheck_common::IsMultilingualSpellcheckEnabled()) {
1027 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS,
1028 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS);
1029 } else if (use_spellcheck_and_search) {
1030 AppendSpellcheckOptionsSubMenu();
1031 }
1032 #endif // defined(OS_MACOSX)
1033
1034 AppendPlatformEditableItems();
1035 1027
1036 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1028 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1037 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, 1029 }
1038 IDS_CONTENT_CONTEXT_SELECTALL); 1030
1031 void RenderViewContextMenu::AppendLanguageSettings() {
1032 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode();
1033
1034 if (use_spellcheck_and_search)
1035 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS,
1036 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS);
1039 } 1037 }
1040 1038
1041 void RenderViewContextMenu::AppendSpellingSuggestionsSubMenu() { 1039 void RenderViewContextMenu::AppendSpellingSuggestionsSubMenu() {
1042 if (!spelling_menu_observer_.get()) 1040 if (!spelling_menu_observer_.get())
1043 spelling_menu_observer_.reset(new SpellingMenuObserver(this)); 1041 spelling_menu_observer_.reset(new SpellingMenuObserver(this));
1044 observers_.AddObserver(spelling_menu_observer_.get()); 1042 observers_.AddObserver(spelling_menu_observer_.get());
1045 spelling_menu_observer_->InitMenu(params_); 1043 spelling_menu_observer_->InitMenu(params_);
1046 } 1044 }
1047 1045
1048 void RenderViewContextMenu::AppendSpellcheckOptionsSubMenu() {
1049 if (!spellchecker_submenu_observer_.get()) {
1050 spellchecker_submenu_observer_.reset(new SpellCheckerSubMenuObserver(
1051 this, this, kSpellcheckRadioGroup));
1052 }
1053 spellchecker_submenu_observer_->InitMenu(params_);
1054 observers_.AddObserver(spellchecker_submenu_observer_.get());
1055 }
1056
1057 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { 1046 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() {
1058 const ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1047 const ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1059 GetHandlersForLinkUrl(); 1048 GetHandlersForLinkUrl();
1060 if (handlers.empty()) 1049 if (handlers.empty())
1061 return; 1050 return;
1062 size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST - 1051 size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST -
1063 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; 1052 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST;
1064 for (size_t i = 0; i < handlers.size() && i <= max; i++) { 1053 for (size_t i = 0; i < handlers.size() && i <= max; i++) {
1065 protocol_handler_submenu_model_.AddItem( 1054 protocol_handler_submenu_model_.AddItem(
1066 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST + i, 1055 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST + i,
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 source_web_contents_->GetRenderViewHost()-> 1948 source_web_contents_->GetRenderViewHost()->
1960 ExecuteMediaPlayerActionAtLocation(location, action); 1949 ExecuteMediaPlayerActionAtLocation(location, action);
1961 } 1950 }
1962 1951
1963 void RenderViewContextMenu::PluginActionAt( 1952 void RenderViewContextMenu::PluginActionAt(
1964 const gfx::Point& location, 1953 const gfx::Point& location,
1965 const WebPluginAction& action) { 1954 const WebPluginAction& action) {
1966 source_web_contents_->GetRenderViewHost()-> 1955 source_web_contents_->GetRenderViewHost()->
1967 ExecutePluginActionAtLocation(location, action); 1956 ExecutePluginActionAtLocation(location, action);
1968 } 1957 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698