| Index: chrome/browser/search_engines/template_url_service.cc
|
| diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
|
| index dacbf3002f6e04f217140a5db613fd2afcc811bd..6a1072fb36fe71584c954eda429d066c8590c3b5 100644
|
| --- a/chrome/browser/search_engines/template_url_service.cc
|
| +++ b/chrome/browser/search_engines/template_url_service.cc
|
| @@ -17,8 +17,6 @@
|
| #include "base/string_util.h"
|
| #include "base/time.h"
|
| #include "base/utf_string_conversions.h"
|
| -#include "chrome/browser/extensions/extension_service.h"
|
| -#include "chrome/browser/extensions/extension_system.h"
|
| #include "chrome/browser/google/google_url_tracker.h"
|
| #include "chrome/browser/history/history.h"
|
| #include "chrome/browser/history/history_notifications.h"
|
| @@ -41,7 +39,6 @@
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/env_vars.h"
|
| -#include "chrome/common/extensions/extension.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "content/public/browser/notification_service.h"
|
| @@ -536,49 +533,37 @@ void TemplateURLService::RemoveAutoGeneratedForOriginBetween(
|
|
|
|
|
| void TemplateURLService::RegisterExtensionKeyword(
|
| - const extensions::Extension* extension) {
|
| - // TODO(mpcomplete): disable the keyword when the extension is disabled.
|
| - if (extension->omnibox_keyword().empty())
|
| - return;
|
| -
|
| - Load();
|
| - if (!loaded_) {
|
| - pending_extension_ids_.push_back(extension->id());
|
| - return;
|
| - }
|
| + const std::string& extension_id,
|
| + const std::string& extension_name,
|
| + const std::string& keyword) {
|
| + DCHECK(loaded_);
|
|
|
| - if (!GetTemplateURLForExtension(extension)) {
|
| + if (!GetTemplateURLForExtension(extension_id)) {
|
| TemplateURLData data;
|
| - data.short_name = UTF8ToUTF16(extension->name());
|
| - data.SetKeyword(UTF8ToUTF16(extension->omnibox_keyword()));
|
| + data.short_name = UTF8ToUTF16(extension_name);
|
| + data.SetKeyword(UTF8ToUTF16(keyword));
|
| // This URL is not actually used for navigation. It holds the extension's
|
| // ID, as well as forcing the TemplateURL to be treated as a search keyword.
|
| data.SetURL(std::string(extensions::kExtensionScheme) + "://" +
|
| - extension->id() + "/?q={searchTerms}");
|
| + extension_id + "/?q={searchTerms}");
|
| Add(new TemplateURL(profile_, data));
|
| }
|
| }
|
|
|
| void TemplateURLService::UnregisterExtensionKeyword(
|
| - const extensions::Extension* extension) {
|
| - if (loaded_) {
|
| - TemplateURL* url = GetTemplateURLForExtension(extension);
|
| - if (url)
|
| - Remove(url);
|
| - } else {
|
| - PendingExtensionIDs::iterator i = std::find(pending_extension_ids_.begin(),
|
| - pending_extension_ids_.end(), extension->id());
|
| - if (i != pending_extension_ids_.end())
|
| - pending_extension_ids_.erase(i);
|
| - }
|
| + const std::string& extension_id) {
|
| + DCHECK(loaded_);
|
| + TemplateURL* url = GetTemplateURLForExtension(extension_id);
|
| + if (url)
|
| + Remove(url);
|
| }
|
|
|
| TemplateURL* TemplateURLService::GetTemplateURLForExtension(
|
| - const extensions::Extension* extension) {
|
| + const std::string& extension_id) {
|
| for (TemplateURLVector::const_iterator i = template_urls_.begin();
|
| i != template_urls_.end(); ++i) {
|
| if ((*i)->IsExtensionKeyword() &&
|
| - ((*i)->url_ref().GetHost() == extension->id()))
|
| + ((*i)->url_ref().GetHost() == extension_id))
|
| return *i;
|
| }
|
|
|
| @@ -1619,16 +1604,6 @@ void TemplateURLService::NotifyLoaded() {
|
| chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
|
| content::Source<TemplateURLService>(this),
|
| content::NotificationService::NoDetails());
|
| -
|
| - for (PendingExtensionIDs::const_iterator i(pending_extension_ids_.begin());
|
| - i != pending_extension_ids_.end(); ++i) {
|
| - const extensions::Extension* extension =
|
| - extensions::ExtensionSystem::Get(profile_)->extension_service()->
|
| - GetExtensionById(*i, true);
|
| - if (extension)
|
| - RegisterExtensionKeyword(extension);
|
| - }
|
| - pending_extension_ids_.clear();
|
| }
|
|
|
| void TemplateURLService::SaveDefaultSearchProviderToPrefs(
|
|
|