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

Unified Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 335023: Add the feature "Add as seach engine..." when right clicking on ... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/external_tab_container_win.cc ('k') | chrome/common/automation_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/render_view_context_menu.cc
===================================================================
--- chrome/browser/tab_contents/render_view_context_menu.cc (revision 90541)
+++ chrome/browser/tab_contents/render_view_context_menu.cc (working copy)
@@ -42,7 +42,9 @@
#include "chrome/browser/translate/translate_manager.h"
#include "chrome/browser/translate/translate_prefs.h"
#include "chrome/browser/translate/translate_tab_helper.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/download/download_tab_helper.h"
+#include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
@@ -785,6 +787,12 @@
IDS_CONTENT_CONTEXT_DELETE);
menu_model_.AddSeparator();
+ if (!params_.keyword_url.is_empty()) {
+ menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ADDSEARCHENGINE,
+ IDS_CONTENT_CONTEXT_ADDSEARCHENGINE);
+ menu_model_.AddSeparator();
+ }
+
AppendSpellcheckOptionsSubMenu();
#if defined(OS_MACOSX)
@@ -1177,6 +1185,9 @@
return true;
#endif
+ case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE:
+ return !params_.keyword_url.is_empty();
+
case IDC_SPELLCHECK_MENU:
return true;
@@ -1622,6 +1633,36 @@
break;
}
+ case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE: {
+ // Make sure the model is loaded.
+ TemplateURLService* model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (!model)
+ return;
+ model->Load();
+
+ scoped_ptr<TemplateURL> template_url(new TemplateURL);
+ string16 keyword =
+ net::StripWWW(UTF8ToUTF16((params_.page_url.host())));
+ template_url->set_short_name(keyword);
+ template_url->set_keyword(keyword);
+ template_url->SetURL(params_.keyword_url.spec(), 0, 0);
+ template_url->SetFaviconURL(TemplateURL::GenerateFaviconURL(
+ params_.page_url.GetOrigin()));
+
+ TabContentsWrapper* tab_contents_wrapper =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ source_tab_contents_);
+ if (tab_contents_wrapper &&
+ tab_contents_wrapper->search_engine_tab_helper() &&
+ tab_contents_wrapper->search_engine_tab_helper()->delegate()) {
+ // Takes ownership of |template_url|.
+ tab_contents_wrapper->search_engine_tab_helper()->delegate()->
+ ConfirmAddSearchProvider(template_url.release(), profile_);
+ }
+ break;
+ }
+
default:
NOTREACHED();
break;
« no previous file with comments | « chrome/browser/external_tab_container_win.cc ('k') | chrome/common/automation_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698