diff options
author | johnnyg@google.com <johnnyg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-31 01:37:27 +0000 |
---|---|---|
committer | johnnyg@google.com <johnnyg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-31 01:37:27 +0000 |
commit | 83a5f08249fa191221ef5ab88abda528319f5db6 (patch) | |
tree | 391ac92f8d517a67b56fc9e70d522cc3cb2fdcdc /chrome | |
parent | a1d1e53e43d287a65a4e5bf09e7e960eae569bbf (diff) | |
download | chromium_src-83a5f08249fa191221ef5ab88abda528319f5db6.zip chromium_src-83a5f08249fa191221ef5ab88abda528319f5db6.tar.gz chromium_src-83a5f08249fa191221ef5ab88abda528319f5db6.tar.bz2 |
Reverting 30656.
Review URL: http://codereview.chromium.org/342072
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30657 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/generated_resources.grd | 6 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 51 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.h | 12 |
3 files changed, 24 insertions, 45 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 7de0c3d..275e7a7a6 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -489,9 +489,6 @@ each locale. --> <message name="IDS_CONTENT_CONTEXT_SEARCHWEBFOR" desc="The name of the Search the Web for 'string' command in the content area context menu"> &Search <ph name="SEARCH_ENGINE">$1<ex>Google</ex></ph> for '<ph name="SEARCH_TERMS">$2<ex>flowers</ex></ph>' </message> - <message name="IDS_CONTENT_CONTEXT_GOTOURL" desc="The name of the Go to 'url' command in the content area context menu"> - &Go to <ph name="URL">$1<ex>http://www.google.com/</ex></ph> - </message> <message name="IDS_CONTENT_CONTEXT_ADDSEARCHENGINE" desc="The name of the Add as Search Engine command in the content area context menu"> Add as search en&gine... </message> @@ -665,9 +662,6 @@ each locale. --> <message name="IDS_CONTENT_CONTEXT_SEARCHWEBFOR" desc="In Title Case: The name of the Search the Web for 'string' command in the content area context menu"> &Search <ph name="SEARCH_ENGINE">$1<ex>Google</ex></ph> for '<ph name="SEARCH_TERMS">$2<ex>flowers</ex></ph>' </message> - <message name="IDS_CONTENT_CONTEXT_GOTOURL" desc="In Title Case: The name of the Go to url for 'string' command in the content area context menu"> - &Go to <ph name="URL">$1<ex>http://www.google.com/</ex></ph> - </message> <message name="IDS_CONTENT_CONTEXT_ADDSEARCHENGINE" desc="In Title Case: The name of the Add as Search Engine command in the content area context menu"> Add As Search En&gine... </message> diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 912c490..ff719c4e 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -18,7 +18,6 @@ #include "chrome/browser/net/browser_url_util.h" #include "chrome/browser/page_info_window.h" #include "chrome/browser/profile.h" -#include "chrome/browser/search_versus_navigate_classifier.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/spellchecker.h" #include "chrome/browser/spellchecker_platform_engine.h" @@ -74,6 +73,7 @@ void RenderViewContextMenu::Init() { } void RenderViewContextMenu::InitMenu() { + bool has_link = !params_.link_url.is_empty(); bool has_selection = !params_.selection_text.empty(); @@ -220,31 +220,16 @@ void RenderViewContextMenu::AppendSearchProvider() { DCHECK(profile_); const TemplateURL* const default_provider = profile_->GetTemplateURLModel()->GetDefaultSearchProvider(); - if (!default_provider) - return; - - std::wstring selection_text = EscapeAmpersands( - l10n_util::TruncateString(params_.selection_text, 50)); - if (selection_text.empty()) - return; - - bool is_search; - profile_->GetSearchVersusNavigateClassifier()->Classify(selection_text, - std::wstring(), &is_search, &selection_navigation_url_, &transition_, - NULL, NULL); - if (!selection_navigation_url_.is_valid()) - return; - - if (is_search) { - string16 label(l10n_util::GetStringFUTF16( - IDS_CONTENT_CONTEXT_SEARCHWEBFOR, - WideToUTF16(default_provider->short_name()), - selection_text)); - AppendMenuItem(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, label); - } else { - string16 label(l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL, - selection_text)); - AppendMenuItem(IDS_CONTENT_CONTEXT_GOTOURL, label); + if (default_provider != NULL) { + string16 selection_text = EscapeAmpersands(WideToUTF16( + l10n_util::TruncateString(params_.selection_text, 50))); + if (!selection_text.empty()) { + string16 label(l10n_util::GetStringFUTF16( + IDS_CONTENT_CONTEXT_SEARCHWEBFOR, + WideToUTF16(default_provider->short_name()), + selection_text)); + AppendMenuItem(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, label); + } } } @@ -460,7 +445,6 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { case IDS_CONTENT_CONTEXT_COPYIMAGE: case IDS_CONTENT_CONTEXT_PRINT: case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: - case IDS_CONTENT_CONTEXT_GOTOURL: case IDC_SPELLCHECK_SUGGESTION_0: case IDC_SPELLCHECK_SUGGESTION_1: case IDC_SPELLCHECK_SUGGESTION_2: @@ -717,9 +701,16 @@ void RenderViewContextMenu::ExecuteItemCommand(int id) { source_tab_contents_->render_view_host()->SelectAll(); break; - case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: - case IDS_CONTENT_CONTEXT_GOTOURL: { - OpenURL(selection_navigation_url_, NEW_FOREGROUND_TAB, transition_); + case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: { + const TemplateURL* const default_provider = + profile_->GetTemplateURLModel()->GetDefaultSearchProvider(); + DCHECK(default_provider); // The context menu should not contain this + // item when there is no provider. + const TemplateURLRef* const search_url = default_provider->url(); + DCHECK(search_url->SupportsReplacement()); + OpenURL(GURL(WideToUTF8(search_url->ReplaceSearchTerms(*default_provider, + params_.selection_text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, + std::wstring()))), NEW_FOREGROUND_TAB, PageTransition::GENERATED); break; } diff --git a/chrome/browser/tab_contents/render_view_context_menu.h b/chrome/browser/tab_contents/render_view_context_menu.h index 599051f..7a4bbc8 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.h +++ b/chrome/browser/tab_contents/render_view_context_menu.h @@ -23,8 +23,9 @@ struct WebMediaPlayerAction; class RenderViewContextMenu { public: - RenderViewContextMenu(TabContents* tab_contents, - const ContextMenuParams& params); + RenderViewContextMenu( + TabContents* tab_contents, + const ContextMenuParams& params); virtual ~RenderViewContextMenu(); @@ -108,13 +109,6 @@ class RenderViewContextMenu { bool IsDevCommandEnabled(int id) const; - // The destination URL to use if the user tries to search for or navigate to - // a text selection. - GURL selection_navigation_url_; - - // The transition type of |selection_navigation_url_|. - PageTransition::Type transition_; - DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu); }; |