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

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

Issue 169093009: Separate out logic to handle different category/group of context menu items from RVContextMenu class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@work-mmm-refactor1
Patch Set: fix semicolon Created 6 years, 9 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 22 matching lines...) Expand all
33 #include "chrome/browser/download/download_service_factory.h" 33 #include "chrome/browser/download/download_service_factory.h"
34 #include "chrome/browser/download/download_stats.h" 34 #include "chrome/browser/download/download_stats.h"
35 #include "chrome/browser/extensions/devtools_util.h" 35 #include "chrome/browser/extensions/devtools_util.h"
36 #include "chrome/browser/extensions/extension_host.h" 36 #include "chrome/browser/extensions/extension_host.h"
37 #include "chrome/browser/extensions/extension_service.h" 37 #include "chrome/browser/extensions/extension_service.h"
38 #include "chrome/browser/google/google_util.h" 38 #include "chrome/browser/google/google_util.h"
39 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 39 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
40 #include "chrome/browser/prefs/incognito_mode_prefs.h" 40 #include "chrome/browser/prefs/incognito_mode_prefs.h"
41 #include "chrome/browser/profiles/profile.h" 41 #include "chrome/browser/profiles/profile.h"
42 #include "chrome/browser/profiles/profile_io_data.h" 42 #include "chrome/browser/profiles/profile_io_data.h"
43 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory .h"
43 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h" 44 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h"
44 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" 45 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h"
45 #include "chrome/browser/search/search.h" 46 #include "chrome/browser/search/search.h"
46 #include "chrome/browser/search_engines/search_terms_data.h" 47 #include "chrome/browser/search_engines/search_terms_data.h"
47 #include "chrome/browser/search_engines/template_url.h" 48 #include "chrome/browser/search_engines/template_url.h"
48 #include "chrome/browser/search_engines/template_url_service.h" 49 #include "chrome/browser/search_engines/template_url_service.h"
49 #include "chrome/browser/search_engines/template_url_service_factory.h" 50 #include "chrome/browser/search_engines/template_url_service_factory.h"
50 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" 51 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
51 #include "chrome/browser/spellchecker/spellcheck_service.h" 52 #include "chrome/browser/spellchecker/spellcheck_service.h"
52 #include "chrome/browser/tab_contents/retargeting_details.h" 53 #include "chrome/browser/tab_contents/retargeting_details.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 render_frame_id_(render_frame_host->GetRoutingID()), 408 render_frame_id_(render_frame_host->GetRoutingID()),
408 profile_(Profile::FromBrowserContext( 409 profile_(Profile::FromBrowserContext(
409 source_web_contents_->GetBrowserContext())), 410 source_web_contents_->GetBrowserContext())),
410 menu_model_(this), 411 menu_model_(this),
411 extension_items_(profile_, this, &menu_model_, 412 extension_items_(profile_, this, &menu_model_,
412 base::Bind(MenuItemMatchesParams, params_)), 413 base::Bind(MenuItemMatchesParams, params_)),
413 speech_input_submenu_model_(this), 414 speech_input_submenu_model_(this),
414 protocol_handler_submenu_model_(this), 415 protocol_handler_submenu_model_(this),
415 protocol_handler_registry_( 416 protocol_handler_registry_(
416 ProtocolHandlerRegistryFactory::GetForProfile(profile_)), 417 ProtocolHandlerRegistryFactory::GetForProfile(profile_)),
417 command_executed_(false), 418 command_executed_(false) {
418 is_guest_(false) { 419 content_type_.reset(ContextMenuContentTypeFactory::Create(
419 RenderViewHost* rvh = source_web_contents_->GetRenderViewHost(); 420 source_web_contents_,
420 if (rvh && rvh->GetProcess()->IsGuest()) 421 render_frame_host, params));
421 is_guest_ = true;
422 } 422 }
423 423
424 RenderViewContextMenu::~RenderViewContextMenu() { 424 RenderViewContextMenu::~RenderViewContextMenu() {
425 } 425 }
426 426
427 // Menu construction functions ------------------------------------------------- 427 // Menu construction functions -------------------------------------------------
428 428
429 void RenderViewContextMenu::Init() { 429 void RenderViewContextMenu::Init() {
430 InitMenu(); 430 InitMenu();
431 PlatformInit(); 431 PlatformInit();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 const std::string& id = map_ids[sorted_menu_titles[i]]; 555 const std::string& id = map_ids[sorted_menu_titles[i]];
556 extension_items_.AppendExtensionItems(id, printable_selection_text, 556 extension_items_.AppendExtensionItems(id, printable_selection_text,
557 &index); 557 &index);
558 } 558 }
559 559
560 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime", 560 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime",
561 base::TimeTicks::Now() - begin); 561 base::TimeTicks::Now() - begin);
562 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index); 562 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index);
563 } 563 }
564 564
565 void RenderViewContextMenu::AppendCurrentExtensionItems() {
566 // Avoid appending extension related items when |extension| is null.
567 // For Panel, this happens when the panel is navigated to a url outside of the
568 // extension's package.
569 const Extension* extension = GetExtension();
570 if (extension) {
571 // Only add extension items from this extension.
572 int index = 0;
573 extension_items_.AppendExtensionItems(extension->id(),
574 PrintableSelectionText(), &index);
575 }
576 }
577
565 void RenderViewContextMenu::InitMenu() { 578 void RenderViewContextMenu::InitMenu() {
566 if (chrome::IsRunningInForcedAppMode()) { 579 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_CUSTOM)) {
567 AppendAppModeItems(); 580 AppendCustomItems();
568 return;
569 }
570 581
571 extensions::ViewType view_type = 582 const bool has_selection = !params_.selection_text.empty();
572 extensions::GetViewType(source_web_contents_);
573 if (view_type == extensions::VIEW_TYPE_APP_WINDOW) {
574 AppendPlatformAppItems();
575 return;
576 } else if (view_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
577 AppendPopupExtensionItems();
578 return;
579 } else if (view_type == extensions::VIEW_TYPE_PANEL) {
580 AppendPanelItems();
581 return;
582 }
583
584 const bool has_link = !params_.unfiltered_link_url.is_empty();
585 const bool has_selection = !params_.selection_text.empty();
586
587 if (AppendCustomItems()) {
588 // If there's a selection, don't early return when there are custom items,
589 // but fall through to adding the normal ones after the custom ones.
590 if (has_selection) { 583 if (has_selection) {
584 // We will add more items if there's a selection, so add a separator.
585 // TODO(lazyboy): Clean up separator logic.
591 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 586 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
592 } else {
593 // Don't add items for Pepper menu.
594 if (!params_.custom_context.is_pepper_menu)
595 AppendDeveloperItems();
596 return;
597 } 587 }
598 } 588 }
599 589
600 // When no special node or text is selected and selection has no link, 590 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE))
601 // show page items. 591 AppendPageItems();
602 if (params_.media_type == WebContextMenuData::MediaTypeNone && 592
603 !has_link && 593 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) {
604 !params_.is_editable && 594 // Merge in frame items with page items if we clicked within a frame that
605 !is_guest_ && 595 // needs them.
606 !has_selection) { 596 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
607 if (!params_.page_url.is_empty()) { 597 AppendFrameItems();
608 bool is_devtools = IsDevToolsURL(params_.page_url);
609 if (!is_devtools && !IsInternalResourcesURL(params_.page_url)) {
610 AppendPageItems();
611 // Merge in frame items if we clicked within a frame that needs them.
612 if (!params_.frame_url.is_empty()) {
613 is_devtools = IsDevToolsURL(params_.frame_url);
614 if (!is_devtools && !IsInternalResourcesURL(params_.frame_url)) {
615 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
616 AppendFrameItems();
617 }
618 }
619 }
620 } else {
621 DCHECK(params_.frame_url.is_empty());
622 }
623 } 598 }
624 599
625 // Do not show link related items for guest. 600 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) {
626 if (has_link && !is_guest_) {
627 AppendLinkItems(); 601 AppendLinkItems();
628 if (params_.media_type != WebContextMenuData::MediaTypeNone) 602 if (params_.media_type != WebContextMenuData::MediaTypeNone)
629 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 603 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
630 } 604 }
631 605
632 switch (params_.media_type) { 606 if (content_type_->SupportsGroup(
633 case WebContextMenuData::MediaTypeNone: 607 ContextMenuContentType::ITEM_GROUP_MEDIA_IMAGE)) {
634 break; 608 AppendImageItems();
635 case WebContextMenuData::MediaTypeImage:
636 AppendImageItems();
637 break;
638 case WebContextMenuData::MediaTypeVideo:
639 AppendVideoItems();
640 break;
641 case WebContextMenuData::MediaTypeAudio:
642 AppendAudioItems();
643 break;
644 case WebContextMenuData::MediaTypePlugin:
645 AppendPluginItems();
646 break;
647 #ifdef WEBCONTEXT_MEDIATYPEFILE_DEFINED
648 case WebContextMenuData::MediaTypeFile:
649 break;
650 #endif
651 } 609 }
652 610
653 if (params_.is_editable) 611 if (content_type_->SupportsGroup(
654 AppendEditableItems(); 612 ContextMenuContentType::ITEM_GROUP_SEARCHWEBFORIMAGE)) {
655 else if (has_selection) 613 AppendSearchWebForImageItems();
656 AppendCopyItem();
657
658 if (!is_guest_ && has_selection) {
659 AppendSearchProvider();
660 if (!IsDevToolsURL(params_.page_url))
661 AppendPrintItem();
662 } 614 }
663 615
664 if (!IsDevToolsURL(params_.page_url) && !is_guest_) 616 if (content_type_->SupportsGroup(
617 ContextMenuContentType::ITEM_GROUP_MEDIA_VIDEO)) {
618 AppendVideoItems();
619 }
620
621 if (content_type_->SupportsGroup(
622 ContextMenuContentType::ITEM_GROUP_MEDIA_AUDIO)) {
623 AppendAudioItems();
624 }
625
626 if (content_type_->SupportsGroup(
627 ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) {
628 AppendPluginItems();
629 }
630
631 // ITEM_GROUP_MEDIA_FILE has no specific items.
632
633 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_EDITABLE))
634 AppendEditableItems();
635
636 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_COPY)) {
637 DCHECK(!content_type_->SupportsGroup(
638 ContextMenuContentType::ITEM_GROUP_EDITABLE));
639 AppendCopyItem();
640 }
641
642 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT))
643 AppendPrintItem();
644
645 if (content_type_->SupportsGroup(
646 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)) {
647 DCHECK(!content_type_->SupportsGroup(
648 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION));
665 AppendAllExtensionItems(); 649 AppendAllExtensionItems();
650 }
666 651
667 AppendDeveloperItems(); 652 if (content_type_->SupportsGroup(
653 ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)) {
654 DCHECK(!content_type_->SupportsGroup(
655 ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION));
656 AppendCurrentExtensionItems();
657 }
668 658
669 if (!is_guest_) { 659 if (content_type_->SupportsGroup(
660 ContextMenuContentType::ITEM_GROUP_DEVELOPER)) {
661 AppendDeveloperItems();
662 }
663
664 if (content_type_->SupportsGroup(
665 ContextMenuContentType::ITEM_GROUP_DEVTOOLS_UNPACKED_EXT)) {
666 AppendDevtoolsForUnpackedExtensions();
667 }
668
669 if (content_type_->SupportsGroup(
670 ContextMenuContentType::ITEM_GROUP_PRINT_PREVIEW)) {
671 AppendPrintPreviewItems();
672 }
673 }
674
675 void RenderViewContextMenu::AppendPrintPreviewItems() {
670 #if defined(ENABLE_FULL_PRINTING) 676 #if defined(ENABLE_FULL_PRINTING)
671 if (!print_preview_menu_observer_.get()) { 677 if (!print_preview_menu_observer_.get()) {
672 print_preview_menu_observer_.reset( 678 print_preview_menu_observer_.reset(
673 new PrintPreviewContextMenuObserver(source_web_contents_)); 679 new PrintPreviewContextMenuObserver(source_web_contents_));
674 } 680 }
675 681
676 observers_.AddObserver(print_preview_menu_observer_.get()); 682 observers_.AddObserver(print_preview_menu_observer_.get());
677 #endif 683 #endif
678 }
679 } 684 }
680 685
681 const Extension* RenderViewContextMenu::GetExtension() const { 686 const Extension* RenderViewContextMenu::GetExtension() const {
682 extensions::ExtensionSystem* system = 687 extensions::ExtensionSystem* system =
683 extensions::ExtensionSystem::Get(profile_); 688 extensions::ExtensionSystem::Get(profile_);
684 // There is no process manager in some tests. 689 // There is no process manager in some tests.
685 if (!system->process_manager()) 690 if (!system->process_manager())
686 return NULL; 691 return NULL;
687 692
688 return system->process_manager()->GetExtensionForRenderViewHost( 693 return system->process_manager()->GetExtensionForRenderViewHost(
689 source_web_contents_->GetRenderViewHost()); 694 source_web_contents_->GetRenderViewHost());
690 } 695 }
691 696
692 void RenderViewContextMenu::AppendAppModeItems() {
693 const bool has_selection = !params_.selection_text.empty();
694
695 if (params_.is_editable)
696 AppendEditableItems();
697 else if (has_selection)
698 AppendCopyItem();
699 }
700
701 void RenderViewContextMenu::AppendPlatformAppItems() {
702 const Extension* platform_app = GetExtension();
703
704 // The RVH might be for a process sandboxed from the extension.
705 if (!platform_app)
706 return;
707
708 DCHECK(platform_app->is_platform_app());
709
710 const bool has_selection = !params_.selection_text.empty();
711
712 // Add undo/redo, cut/copy/paste etc for text fields.
713 if (params_.is_editable)
714 AppendEditableItems();
715 else if (has_selection)
716 AppendCopyItem();
717
718 int index = 0;
719 extension_items_.AppendExtensionItems(platform_app->id(),
720 PrintableSelectionText(), &index);
721
722 // Add dev tools for unpacked extensions.
723 if (extensions::Manifest::IsUnpackedLocation(platform_app->location()) ||
724 CommandLine::ForCurrentProcess()->HasSwitch(
725 switches::kDebugPackedApps)) {
726 // Add a separator if there are any items already in the menu.
727 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
728
729 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP,
730 IDS_CONTENT_CONTEXT_RELOAD_PACKAGED_APP);
731 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP,
732 IDS_CONTENT_CONTEXT_RESTART_APP);
733 AppendDeveloperItems();
734 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE,
735 IDS_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE);
736 }
737 }
738
739 void RenderViewContextMenu::AppendPopupExtensionItems() {
740 const bool has_selection = !params_.selection_text.empty();
741
742 if (params_.is_editable)
743 AppendEditableItems();
744 else if (has_selection)
745 AppendCopyItem();
746
747 if (has_selection)
748 AppendSearchProvider();
749
750 AppendAllExtensionItems();
751 AppendDeveloperItems();
752 }
753
754 void RenderViewContextMenu::AppendPanelItems() {
755 bool has_selection = !params_.selection_text.empty();
756
757 // Checking link should take precedence before checking selection since on Mac
758 // right-clicking a link will also make it selected.
759 if (params_.unfiltered_link_url.is_valid())
760 AppendLinkItems();
761
762 if (params_.is_editable)
763 AppendEditableItems();
764 else if (has_selection)
765 AppendCopyItem();
766
767 // Avoid appending extension related items when |extension| is null. This
768 // happens when the panel is navigated to a url outside of the extension's
769 // package.
770 const Extension* extension = GetExtension();
771 if (extension) {
772 // Only add extension items from this extension.
773 int index = 0;
774 extension_items_.AppendExtensionItems(extension->id(),
775 PrintableSelectionText(), &index);
776 }
777 }
778
779 void RenderViewContextMenu::AddMenuItem(int command_id, 697 void RenderViewContextMenu::AddMenuItem(int command_id,
780 const base::string16& title) { 698 const base::string16& title) {
781 menu_model_.AddItem(command_id, title); 699 menu_model_.AddItem(command_id, title);
782 } 700 }
783 701
784 void RenderViewContextMenu::AddCheckItem(int command_id, 702 void RenderViewContextMenu::AddCheckItem(int command_id,
785 const base::string16& title) { 703 const base::string16& title) {
786 menu_model_.AddCheckItem(command_id, title); 704 menu_model_.AddCheckItem(command_id, title);
787 } 705 }
788 706
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 if (!show_developer_items) 753 if (!show_developer_items)
836 return; 754 return;
837 755
838 // In the DevTools popup menu, "developer items" is normally the only 756 // In the DevTools popup menu, "developer items" is normally the only
839 // section, so omit the separator there. 757 // section, so omit the separator there.
840 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 758 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
841 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTELEMENT, 759 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTELEMENT,
842 IDS_CONTENT_CONTEXT_INSPECTELEMENT); 760 IDS_CONTENT_CONTEXT_INSPECTELEMENT);
843 } 761 }
844 762
763 void RenderViewContextMenu::AppendDevtoolsForUnpackedExtensions() {
764 // Add a separator if there are any items already in the menu.
765 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
766
767 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP,
768 IDS_CONTENT_CONTEXT_RELOAD_PACKAGED_APP);
769 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP,
770 IDS_CONTENT_CONTEXT_RESTART_APP);
771 AppendDeveloperItems();
772 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE,
773 IDS_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE);
774 }
775
845 void RenderViewContextMenu::AppendLinkItems() { 776 void RenderViewContextMenu::AppendLinkItems() {
846 if (!params_.link_url.is_empty()) { 777 if (!params_.link_url.is_empty()) {
847 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 778 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB,
848 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); 779 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB);
849 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, 780 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW,
850 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); 781 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW);
851 if (params_.link_url.is_valid()) { 782 if (params_.link_url.is_valid()) {
852 AppendProtocolHandlerSubMenu(); 783 AppendProtocolHandlerSubMenu();
853 } 784 }
854 785
(...skipping 12 matching lines...) Expand all
867 798
868 void RenderViewContextMenu::AppendImageItems() { 799 void RenderViewContextMenu::AppendImageItems() {
869 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 800 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS,
870 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); 801 IDS_CONTENT_CONTEXT_SAVEIMAGEAS);
871 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, 802 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION,
872 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); 803 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION);
873 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, 804 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE,
874 IDS_CONTENT_CONTEXT_COPYIMAGE); 805 IDS_CONTENT_CONTEXT_COPYIMAGE);
875 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, 806 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB,
876 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); 807 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB);
808 }
809
810 void RenderViewContextMenu::AppendSearchWebForImageItems() {
877 const TemplateURL* const default_provider = 811 const TemplateURL* const default_provider =
878 TemplateURLServiceFactory::GetForProfile(profile_)-> 812 TemplateURLServiceFactory::GetForProfile(profile_)->
879 GetDefaultSearchProvider(); 813 GetDefaultSearchProvider();
880 if (!is_guest_ && params_.has_image_contents && default_provider && 814 if (params_.has_image_contents && default_provider &&
881 !default_provider->image_url().empty() && 815 !default_provider->image_url().empty() &&
882 default_provider->image_url_ref().IsValid()) { 816 default_provider->image_url_ref().IsValid()) {
883 menu_model_.AddItem( 817 menu_model_.AddItem(
884 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, 818 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE,
885 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, 819 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE,
886 default_provider->short_name())); 820 default_provider->short_name()));
887 } 821 }
888 AppendPrintItem();
889 } 822 }
890 823
891 void RenderViewContextMenu::AppendAudioItems() { 824 void RenderViewContextMenu::AppendAudioItems() {
892 AppendMediaItems(); 825 AppendMediaItems();
893 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 826 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
894 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, 827 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS,
895 IDS_CONTENT_CONTEXT_SAVEAUDIOAS); 828 IDS_CONTENT_CONTEXT_SAVEAUDIOAS);
896 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, 829 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION,
897 IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION); 830 IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION);
898 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, 831 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB,
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 source_web_contents_->GetRenderViewHost()-> 2044 source_web_contents_->GetRenderViewHost()->
2112 ExecuteMediaPlayerActionAtLocation(location, action); 2045 ExecuteMediaPlayerActionAtLocation(location, action);
2113 } 2046 }
2114 2047
2115 void RenderViewContextMenu::PluginActionAt( 2048 void RenderViewContextMenu::PluginActionAt(
2116 const gfx::Point& location, 2049 const gfx::Point& location,
2117 const WebPluginAction& action) { 2050 const WebPluginAction& action) {
2118 source_web_contents_->GetRenderViewHost()-> 2051 source_web_contents_->GetRenderViewHost()->
2119 ExecutePluginActionAtLocation(location, action); 2052 ExecutePluginActionAtLocation(location, action);
2120 } 2053 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698