diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-28 18:39:02 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-28 18:39:02 +0000 |
commit | 124646932219f4cd17a3dc80393485e923deb1ba (patch) | |
tree | 9e20a8428541fb543b21503ce76e7a71251a8722 /chrome/browser/tab_contents | |
parent | 96c622f5a85c0a745b5f66856aea419032c934af (diff) | |
download | chromium_src-124646932219f4cd17a3dc80393485e923deb1ba.zip chromium_src-124646932219f4cd17a3dc80393485e923deb1ba.tar.gz chromium_src-124646932219f4cd17a3dc80393485e923deb1ba.tar.bz2 |
Context menus for text selections in editable boxes and links should include the Search menu item. Original patch by Brian Duff (see http://codereview.chromium.org/16510 ), r=me.
BUG=1925
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 50 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.h | 7 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents_view_win.cc | 2 |
3 files changed, 28 insertions, 31 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 4aecf00..9d36be5 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -18,7 +18,7 @@ RenderViewContextMenu::RenderViewContextMenu( Menu::Delegate* delegate, HWND owner, - ContextNode::Type type, + ContextNode node, const std::wstring& misspelled_word, const std::vector<std::wstring>& misspelled_word_suggestions, Profile* profile) @@ -26,40 +26,34 @@ RenderViewContextMenu::RenderViewContextMenu( misspelled_word_(misspelled_word), misspelled_word_suggestions_(misspelled_word_suggestions), profile_(profile) { - InitMenu(type); + InitMenu(node); } RenderViewContextMenu::~RenderViewContextMenu() { } -void RenderViewContextMenu::InitMenu(ContextNode::Type type) { - switch (type) { - case ContextNode::PAGE: +void RenderViewContextMenu::InitMenu(ContextNode node) { + if (node.type & ContextNode::PAGE) AppendPageItems(); - break; - case ContextNode::FRAME: + if (node.type & ContextNode::FRAME) AppendFrameItems(); - break; - case ContextNode::LINK: + if (node.type & ContextNode::LINK) AppendLinkItems(); - break; - case ContextNode::IMAGE: - AppendImageItems(); - break; - case ContextNode::IMAGE_LINK: - AppendLinkItems(); - AppendSeparator(); + + if (node.type & ContextNode::IMAGE) { + if (node.type & ContextNode::LINK) + AppendSeparator(); AppendImageItems(); - break; - case ContextNode::SELECTION: - AppendSelectionItems(); - break; - case ContextNode::EDITABLE: - AppendEditableItems(); - break; - default: - NOTREACHED() << "Unknown ContextNode::Type"; } + + if (node.type & ContextNode::EDITABLE) + AppendEditableItems(); + else if (node.type & ContextNode::SELECTION || + node.type & ContextNode::LINK) + AppendCopyItem(); + + if (node.type & ContextNode::SELECTION) + AppendSearchProvider(); AppendSeparator(); AppendDeveloperItems(); } @@ -74,7 +68,6 @@ void RenderViewContextMenu::AppendLinkItems() { AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_SAVELINKAS); AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_COPYLINKLOCATION); - AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_COPY); } void RenderViewContextMenu::AppendImageItems() { @@ -109,8 +102,11 @@ void RenderViewContextMenu::AppendFrameItems() { AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_VIEWFRAMEINFO); } -void RenderViewContextMenu::AppendSelectionItems() { +void RenderViewContextMenu::AppendCopyItem() { AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_COPY); +} + +void RenderViewContextMenu::AppendSearchProvider() { DCHECK(profile_); if (profile_->GetTemplateURLModel()->GetDefaultSearchProvider() != NULL) AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_SEARCHWEBFOR); diff --git a/chrome/browser/tab_contents/render_view_context_menu.h b/chrome/browser/tab_contents/render_view_context_menu.h index 6c95f57..6d55c03 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.h +++ b/chrome/browser/tab_contents/render_view_context_menu.h @@ -15,7 +15,7 @@ class RenderViewContextMenu : public Menu { RenderViewContextMenu( Menu::Delegate* delegate, HWND owner, - ContextNode::Type type, + ContextNode node, const std::wstring& misspelled_word, const std::vector<std::wstring>& misspelled_word_suggestions, Profile* profile); @@ -23,14 +23,15 @@ class RenderViewContextMenu : public Menu { virtual ~RenderViewContextMenu(); private: - void InitMenu(ContextNode::Type type); + void InitMenu(ContextNode node); void AppendDeveloperItems(); void AppendLinkItems(); void AppendImageItems(); void AppendPageItems(); void AppendFrameItems(); - void AppendSelectionItems(); + void AppendCopyItem(); void AppendEditableItems(); + void AppendSearchProvider(); std::wstring misspelled_word_; std::vector<std::wstring> misspelled_word_suggestions_; diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc index 0c7cbef..ee69af7 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.cc +++ b/chrome/browser/tab_contents/web_contents_view_win.cc @@ -319,7 +319,7 @@ void WebContentsViewWin::ShowContextMenu( RenderViewContextMenuController menu_controller(web_contents_, params); RenderViewContextMenu menu(&menu_controller, GetHWND(), - params.type, + params.node, params.misspelled_word, params.dictionary_suggestions, web_contents_->profile()); |