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

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

Issue 632243002: |Print..| menu should be consistent in contextmenu with and without selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments update. Created 6 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
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 extensions::WebViewGuest::GetViewInstanceId(source_web_contents_)); 470 extensions::WebViewGuest::GetViewInstanceId(source_web_contents_));
471 extension_items_.AppendExtensionItems(key, 471 extension_items_.AppendExtensionItems(key,
472 PrintableSelectionText(), 472 PrintableSelectionText(),
473 &index, 473 &index,
474 false); // is_action_menu 474 false); // is_action_menu
475 } 475 }
476 } 476 }
477 477
478 void RenderViewContextMenu::InitMenu() { 478 void RenderViewContextMenu::InitMenu() {
479 RenderViewContextMenuBase::InitMenu(); 479 RenderViewContextMenuBase::InitMenu();
480 480 bool rotation_item_appended = false;
481 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) 481 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE))
482 AppendPageItems(); 482 AppendPageItems();
483 483
484 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) { 484 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) {
485 // Merge in frame items with page items if we clicked within a frame that 485 // Merge in frame items with page items if we clicked within a frame that
486 // needs them. 486 // needs them.
487 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 487 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
488 AppendFrameItems(); 488 AppendFrameItems();
489 } 489 }
490 490
(...skipping 23 matching lines...) Expand all
514 AppendAudioItems(); 514 AppendAudioItems();
515 } 515 }
516 516
517 if (content_type_->SupportsGroup( 517 if (content_type_->SupportsGroup(
518 ContextMenuContentType::ITEM_GROUP_MEDIA_CANVAS)) { 518 ContextMenuContentType::ITEM_GROUP_MEDIA_CANVAS)) {
519 AppendCanvasItems(); 519 AppendCanvasItems();
520 } 520 }
521 521
522 if (content_type_->SupportsGroup( 522 if (content_type_->SupportsGroup(
523 ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { 523 ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) {
524 AppendPluginItems(); 524 rotation_item_appended = AppendPluginItems();
525 } 525 }
526 526
527 // ITEM_GROUP_MEDIA_FILE has no specific items. 527 // ITEM_GROUP_MEDIA_FILE has no specific items.
528 528
529 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_EDITABLE)) 529 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_EDITABLE))
530 AppendEditableItems(); 530 AppendEditableItems();
531 531
532 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_COPY)) { 532 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_COPY)) {
533 DCHECK(!content_type_->SupportsGroup( 533 DCHECK(!content_type_->SupportsGroup(
534 ContextMenuContentType::ITEM_GROUP_EDITABLE)); 534 ContextMenuContentType::ITEM_GROUP_EDITABLE));
535 AppendCopyItem(); 535 AppendCopyItem();
536 } 536 }
537 537
538 if (content_type_->SupportsGroup( 538 if (content_type_->SupportsGroup(
539 ContextMenuContentType::ITEM_GROUP_SEARCH_PROVIDER)) { 539 ContextMenuContentType::ITEM_GROUP_SEARCH_PROVIDER)) {
540 AppendSearchProvider(); 540 AppendSearchProvider();
541 } 541 }
542 542
543 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT)) 543 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT))
544 AppendPrintItem(); 544 AppendPrintItem();
545 545
546 if (rotation_item_appended)
547 AppendRotationItems();
548
546 if (content_type_->SupportsGroup( 549 if (content_type_->SupportsGroup(
547 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)) { 550 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)) {
548 DCHECK(!content_type_->SupportsGroup( 551 DCHECK(!content_type_->SupportsGroup(
549 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)); 552 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION));
550 AppendAllExtensionItems(); 553 AppendAllExtensionItems();
551 } 554 }
552 555
553 if (content_type_->SupportsGroup( 556 if (content_type_->SupportsGroup(
554 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)) { 557 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)) {
555 DCHECK(!content_type_->SupportsGroup( 558 DCHECK(!content_type_->SupportsGroup(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 media_flags & WebContextMenuData::MediaMuted ? 757 media_flags & WebContextMenuData::MediaMuted ?
755 IDS_CONTENT_CONTEXT_UNMUTE : 758 IDS_CONTENT_CONTEXT_UNMUTE :
756 IDS_CONTENT_CONTEXT_MUTE); 759 IDS_CONTENT_CONTEXT_MUTE);
757 760
758 menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_LOOP, 761 menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_LOOP,
759 IDS_CONTENT_CONTEXT_LOOP); 762 IDS_CONTENT_CONTEXT_LOOP);
760 menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_CONTROLS, 763 menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_CONTROLS,
761 IDS_CONTENT_CONTEXT_CONTROLS); 764 IDS_CONTENT_CONTEXT_CONTROLS);
762 } 765 }
763 766
764 void RenderViewContextMenu::AppendPluginItems() { 767 // This function will returns true if we need to add the rotation items else
768 // returns false. As rotation items should be added after copy, search, print
769 // context menu items.
Avi (use Gerrit) 2014/10/08 12:42:48 :\ When you return bool from a function it means s
Deepak 2014/10/08 13:38:26 Done.
770 bool RenderViewContextMenu::AppendPluginItems() {
765 if (params_.page_url == params_.src_url) { 771 if (params_.page_url == params_.src_url) {
766 // Full page plugin, so show page menu items. 772 // Full page plugin, so show page menu items.
767 if (params_.link_url.is_empty() && params_.selection_text.empty()) 773 if (params_.link_url.is_empty() && params_.selection_text.empty())
768 AppendPageItems(); 774 AppendPageItems();
769 } else { 775 } else {
770 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, 776 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS,
771 IDS_CONTENT_CONTEXT_SAVEPAGEAS); 777 IDS_CONTENT_CONTEXT_SAVEPAGEAS);
772 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); 778 // |IDC_PRINT| should be added here as we want print menu item when pdf
779 // launched with out of process flags then |content_type_->SupportsGroup|
780 // does not have |ContextMenuContentType::ITEM_GROUP_PRINT|.
781 if (!content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT))
782 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT);
773 } 783 }
774 784
775 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { 785 if (params_.media_flags & WebContextMenuData::MediaCanRotate)
776 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 786 return true;
Avi (use Gerrit) 2014/10/08 12:42:48 Is there a reason why we need the boolean at all?
Deepak 2014/10/08 13:38:26 Done.
777 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, 787
778 IDS_CONTENT_CONTEXT_ROTATECW); 788 return false;
779 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW,
780 IDS_CONTENT_CONTEXT_ROTATECCW);
781 }
782 } 789 }
783 790
784 void RenderViewContextMenu::AppendPageItems() { 791 void RenderViewContextMenu::AppendPageItems() {
785 menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); 792 menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK);
786 menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); 793 menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD);
787 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); 794 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD);
788 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 795 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
789 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, 796 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE,
790 IDS_CONTENT_CONTEXT_SAVEPAGEAS); 797 IDS_CONTENT_CONTEXT_SAVEPAGEAS);
791 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); 798 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 if (menu_model_.GetIndexOfCommandId(IDC_PRINT) != -1) 837 if (menu_model_.GetIndexOfCommandId(IDC_PRINT) != -1)
831 return; 838 return;
832 839
833 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && 840 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) &&
834 (params_.media_type == WebContextMenuData::MediaTypeNone || 841 (params_.media_type == WebContextMenuData::MediaTypeNone ||
835 params_.media_flags & WebContextMenuData::MediaCanPrint)) { 842 params_.media_flags & WebContextMenuData::MediaCanPrint)) {
836 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); 843 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT);
837 } 844 }
838 } 845 }
839 846
847 void RenderViewContextMenu::AppendRotationItems() {
848 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
849 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW,
850 IDS_CONTENT_CONTEXT_ROTATECW);
851 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW,
852 IDS_CONTENT_CONTEXT_ROTATECCW);
853 }
854
840 void RenderViewContextMenu::AppendSearchProvider() { 855 void RenderViewContextMenu::AppendSearchProvider() {
841 DCHECK(browser_context_); 856 DCHECK(browser_context_);
842 857
843 base::TrimWhitespace(params_.selection_text, base::TRIM_ALL, 858 base::TrimWhitespace(params_.selection_text, base::TRIM_ALL,
844 &params_.selection_text); 859 &params_.selection_text);
845 if (params_.selection_text.empty()) 860 if (params_.selection_text.empty())
846 return; 861 return;
847 862
848 base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars, 863 base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars,
849 base::ASCIIToUTF16(" "), &params_.selection_text); 864 base::ASCIIToUTF16(" "), &params_.selection_text);
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 source_web_contents_->GetRenderViewHost()-> 1798 source_web_contents_->GetRenderViewHost()->
1784 ExecuteMediaPlayerActionAtLocation(location, action); 1799 ExecuteMediaPlayerActionAtLocation(location, action);
1785 } 1800 }
1786 1801
1787 void RenderViewContextMenu::PluginActionAt( 1802 void RenderViewContextMenu::PluginActionAt(
1788 const gfx::Point& location, 1803 const gfx::Point& location,
1789 const WebPluginAction& action) { 1804 const WebPluginAction& action) {
1790 source_web_contents_->GetRenderViewHost()-> 1805 source_web_contents_->GetRenderViewHost()->
1791 ExecutePluginActionAtLocation(location, action); 1806 ExecutePluginActionAtLocation(location, action);
1792 } 1807 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698