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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 (content_type_->SupportsGroup( | 546 if (content_type_->SupportsGroup( |
547 ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { | |
548 AppendRotationItems(); | |
549 } | |
550 | |
551 if (content_type_->SupportsGroup( | |
547 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)) { | 552 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)) { |
548 DCHECK(!content_type_->SupportsGroup( | 553 DCHECK(!content_type_->SupportsGroup( |
549 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)); | 554 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)); |
550 AppendAllExtensionItems(); | 555 AppendAllExtensionItems(); |
551 } | 556 } |
552 | 557 |
553 if (content_type_->SupportsGroup( | 558 if (content_type_->SupportsGroup( |
554 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)) { | 559 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)) { |
555 DCHECK(!content_type_->SupportsGroup( | 560 DCHECK(!content_type_->SupportsGroup( |
556 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)); | 561 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 } | 767 } |
763 | 768 |
764 void RenderViewContextMenu::AppendPluginItems() { | 769 void RenderViewContextMenu::AppendPluginItems() { |
765 if (params_.page_url == params_.src_url) { | 770 if (params_.page_url == params_.src_url) { |
766 // Full page plugin, so show page menu items. | 771 // Full page plugin, so show page menu items. |
767 if (params_.link_url.is_empty() && params_.selection_text.empty()) | 772 if (params_.link_url.is_empty() && params_.selection_text.empty()) |
768 AppendPageItems(); | 773 AppendPageItems(); |
769 } else { | 774 } else { |
770 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, | 775 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, |
771 IDS_CONTENT_CONTEXT_SAVEPAGEAS); | 776 IDS_CONTENT_CONTEXT_SAVEPAGEAS); |
772 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); | 777 // |IDC_PRINT| should be added here as we want print menu item. When pdf |
773 } | 778 // plugin is un-embedded then |content_type_->SupportsGroup| does not have |
774 | 779 // |ContextMenuContentType::ITEM_GROUP_PRINT| so |IDC_PRINT| will not be |
775 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { | 780 // added by |AppendPrintItem|function call. |
raymes
2014/10/13 16:53:29
Would it be accurate to reword the comment as foll
| |
776 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 781 if (!content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT)) |
777 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, | 782 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); |
778 IDS_CONTENT_CONTEXT_ROTATECW); | |
779 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, | |
780 IDS_CONTENT_CONTEXT_ROTATECCW); | |
781 } | 783 } |
782 } | 784 } |
783 | 785 |
784 void RenderViewContextMenu::AppendPageItems() { | 786 void RenderViewContextMenu::AppendPageItems() { |
785 menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); | 787 menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); |
786 menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); | 788 menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); |
787 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); | 789 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); |
788 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 790 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
789 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, | 791 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, |
790 IDS_CONTENT_CONTEXT_SAVEPAGEAS); | 792 IDS_CONTENT_CONTEXT_SAVEPAGEAS); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
830 if (menu_model_.GetIndexOfCommandId(IDC_PRINT) != -1) | 832 if (menu_model_.GetIndexOfCommandId(IDC_PRINT) != -1) |
831 return; | 833 return; |
832 | 834 |
833 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && | 835 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && |
834 (params_.media_type == WebContextMenuData::MediaTypeNone || | 836 (params_.media_type == WebContextMenuData::MediaTypeNone || |
835 params_.media_flags & WebContextMenuData::MediaCanPrint)) { | 837 params_.media_flags & WebContextMenuData::MediaCanPrint)) { |
836 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); | 838 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); |
837 } | 839 } |
838 } | 840 } |
839 | 841 |
842 void RenderViewContextMenu::AppendRotationItems() { | |
843 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { | |
844 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | |
845 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, | |
846 IDS_CONTENT_CONTEXT_ROTATECW); | |
847 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, | |
848 IDS_CONTENT_CONTEXT_ROTATECCW); | |
849 } | |
850 } | |
851 | |
840 void RenderViewContextMenu::AppendSearchProvider() { | 852 void RenderViewContextMenu::AppendSearchProvider() { |
841 DCHECK(browser_context_); | 853 DCHECK(browser_context_); |
842 | 854 |
843 base::TrimWhitespace(params_.selection_text, base::TRIM_ALL, | 855 base::TrimWhitespace(params_.selection_text, base::TRIM_ALL, |
844 ¶ms_.selection_text); | 856 ¶ms_.selection_text); |
845 if (params_.selection_text.empty()) | 857 if (params_.selection_text.empty()) |
846 return; | 858 return; |
847 | 859 |
848 base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars, | 860 base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars, |
849 base::ASCIIToUTF16(" "), ¶ms_.selection_text); | 861 base::ASCIIToUTF16(" "), ¶ms_.selection_text); |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1783 source_web_contents_->GetRenderViewHost()-> | 1795 source_web_contents_->GetRenderViewHost()-> |
1784 ExecuteMediaPlayerActionAtLocation(location, action); | 1796 ExecuteMediaPlayerActionAtLocation(location, action); |
1785 } | 1797 } |
1786 | 1798 |
1787 void RenderViewContextMenu::PluginActionAt( | 1799 void RenderViewContextMenu::PluginActionAt( |
1788 const gfx::Point& location, | 1800 const gfx::Point& location, |
1789 const WebPluginAction& action) { | 1801 const WebPluginAction& action) { |
1790 source_web_contents_->GetRenderViewHost()-> | 1802 source_web_contents_->GetRenderViewHost()-> |
1791 ExecutePluginActionAtLocation(location, action); | 1803 ExecutePluginActionAtLocation(location, action); |
1792 } | 1804 } |
OLD | NEW |