summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-01 21:47:07 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-01 21:47:07 +0000
commit29545125b770f4b8ddeaccc702561a64c886f616 (patch)
tree4bd2d0fda512f5b9ea3f71ce0be9289f98784309 /chrome/browser
parent2fa407804a4830274a06771aa2de6d919e8c0dbf (diff)
downloadchromium_src-29545125b770f4b8ddeaccc702561a64c886f616.zip
chromium_src-29545125b770f4b8ddeaccc702561a64c886f616.tar.gz
chromium_src-29545125b770f4b8ddeaccc702561a64c886f616.tar.bz2
Reverting 30679.
Review URL: http://codereview.chromium.org/341062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30681 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc51
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.h12
2 files changed, 24 insertions, 39 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 255a3ea..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;
-
- string16 selection_text = EscapeAmpersands(WideToUTF16(
- l10n_util::TruncateString(params_.selection_text, 50)));
- if (selection_text.empty())
- return;
-
- bool is_search;
- profile_->GetSearchVersusNavigateClassifier()->Classify(
- UTF16ToWide(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);
};