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 // launched with out of process flags then |content_type_->SupportsGroup| |
774 | 779 // does not have |ContextMenuContentType::ITEM_GROUP_PRINT|. |
775 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { | 780 if (!content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT)) |
raymes
2014/10/09 20:29:09
I don't fully understand this bit. Why do we add a
| |
776 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 781 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); |
777 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, | |
778 IDS_CONTENT_CONTEXT_ROTATECW); | |
779 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, | |
780 IDS_CONTENT_CONTEXT_ROTATECCW); | |
781 } | 782 } |
782 } | 783 } |
783 | 784 |
784 void RenderViewContextMenu::AppendPageItems() { | 785 void RenderViewContextMenu::AppendPageItems() { |
785 menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); | 786 menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); |
786 menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); | 787 menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); |
787 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); | 788 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); |
788 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 789 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
789 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, | 790 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, |
790 IDS_CONTENT_CONTEXT_SAVEPAGEAS); | 791 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) | 831 if (menu_model_.GetIndexOfCommandId(IDC_PRINT) != -1) |
831 return; | 832 return; |
832 | 833 |
833 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && | 834 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && |
834 (params_.media_type == WebContextMenuData::MediaTypeNone || | 835 (params_.media_type == WebContextMenuData::MediaTypeNone || |
835 params_.media_flags & WebContextMenuData::MediaCanPrint)) { | 836 params_.media_flags & WebContextMenuData::MediaCanPrint)) { |
836 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); | 837 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); |
837 } | 838 } |
838 } | 839 } |
839 | 840 |
841 void RenderViewContextMenu::AppendRotationItems() { | |
842 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { | |
843 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | |
844 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, | |
845 IDS_CONTENT_CONTEXT_ROTATECW); | |
846 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, | |
847 IDS_CONTENT_CONTEXT_ROTATECCW); | |
848 } | |
849 } | |
850 | |
840 void RenderViewContextMenu::AppendSearchProvider() { | 851 void RenderViewContextMenu::AppendSearchProvider() { |
841 DCHECK(browser_context_); | 852 DCHECK(browser_context_); |
842 | 853 |
843 base::TrimWhitespace(params_.selection_text, base::TRIM_ALL, | 854 base::TrimWhitespace(params_.selection_text, base::TRIM_ALL, |
844 ¶ms_.selection_text); | 855 ¶ms_.selection_text); |
845 if (params_.selection_text.empty()) | 856 if (params_.selection_text.empty()) |
846 return; | 857 return; |
847 | 858 |
848 base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars, | 859 base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars, |
849 base::ASCIIToUTF16(" "), ¶ms_.selection_text); | 860 base::ASCIIToUTF16(" "), ¶ms_.selection_text); |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1783 source_web_contents_->GetRenderViewHost()-> | 1794 source_web_contents_->GetRenderViewHost()-> |
1784 ExecuteMediaPlayerActionAtLocation(location, action); | 1795 ExecuteMediaPlayerActionAtLocation(location, action); |
1785 } | 1796 } |
1786 | 1797 |
1787 void RenderViewContextMenu::PluginActionAt( | 1798 void RenderViewContextMenu::PluginActionAt( |
1788 const gfx::Point& location, | 1799 const gfx::Point& location, |
1789 const WebPluginAction& action) { | 1800 const WebPluginAction& action) { |
1790 source_web_contents_->GetRenderViewHost()-> | 1801 source_web_contents_->GetRenderViewHost()-> |
1791 ExecutePluginActionAtLocation(location, action); | 1802 ExecutePluginActionAtLocation(location, action); |
1792 } | 1803 } |
OLD | NEW |