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

Unified Diff: chrome/browser/search_engines/template_url_model.cc

Issue 2807033: Add support for omnibox.onInputStarted and onInputCancelled. (Closed)
Patch Set: fix Stop Created 10 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/extensions/extensions_service.cc ('k') | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/template_url_model.cc
diff --git a/chrome/browser/search_engines/template_url_model.cc b/chrome/browser/search_engines/template_url_model.cc
index b59c8ca319b4102b0f6aa3dd41f8e964877fd22d..bbb07fcd53c916f1253f6c55521bd6e175388783 100644
--- a/chrome/browser/search_engines/template_url_model.cc
+++ b/chrome/browser/search_engines/template_url_model.cc
@@ -1068,9 +1068,7 @@ void TemplateURLModel::RegisterExtensionKeyword(Extension* extension) {
return;
}
- if (GetTemplateURLForExtension(extension))
- return; // Already have this one registered (might be an upgrade).
-
+ const TemplateURL* existing_url = GetTemplateURLForExtension(extension);
std::wstring keyword = UTF8ToWide(extension->omnibox_keyword());
TemplateURL* template_url = new TemplateURL;
@@ -1083,7 +1081,13 @@ void TemplateURLModel::RegisterExtensionKeyword(Extension* extension) {
extension->id() + "/?q={searchTerms}", 0, 0);
template_url->set_safe_for_autoreplace(false);
- Add(template_url);
+ if (existing_url) {
+ // TODO(mpcomplete): only replace if the user hasn't changed the keyword.
+ // (We don't have UI for that yet).
+ Replace(existing_url, template_url);
+ } else {
+ Add(template_url);
+ }
}
void TemplateURLModel::UnregisterExtensionKeyword(Extension* extension) {
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698