| Index: chrome/browser/extensions/api/omnibox/omnibox_api.cc
|
| diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api.cc b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
|
| index 55c7da89cda78575cf0c5b68d4512ff3c6151880..30a4fabf5f35326cc22021bfa7b91ad5f7a507c9 100644
|
| --- a/chrome/browser/extensions/api/omnibox/omnibox_api.cc
|
| +++ b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
|
| @@ -183,8 +183,9 @@ OmniboxAPI::OmniboxAPI(Profile* profile)
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
|
| content::Source<Profile>(profile));
|
| if (url_service_) {
|
| - registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
|
| - content::Source<TemplateURLService>(url_service_));
|
| + template_url_sub_ = url_service_->RegisterOnLoadedCallback(
|
| + base::Bind(&OmniboxAPI::OnTemplateURLsLoaded,
|
| + base::Unretained(this)));
|
| }
|
|
|
| // Use monochrome icons for Omnibox icons.
|
| @@ -194,6 +195,10 @@ OmniboxAPI::OmniboxAPI(Profile* profile)
|
| 0, kOmniboxIconPaddingRight));
|
| }
|
|
|
| +void OmniboxAPI::Shutdown() {
|
| + template_url_sub_.reset();
|
| +}
|
| +
|
| OmniboxAPI::~OmniboxAPI() {
|
| }
|
|
|
| @@ -245,15 +250,7 @@ void OmniboxAPI::Observe(int type,
|
| }
|
| }
|
| } else {
|
| - DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED);
|
| - // Load pending extensions.
|
| - for (PendingExtensions::const_iterator i(pending_extensions_.begin());
|
| - i != pending_extensions_.end(); ++i) {
|
| - url_service_->RegisterExtensionKeyword((*i)->id(),
|
| - (*i)->name(),
|
| - OmniboxInfo::GetKeyword(*i));
|
| - }
|
| - pending_extensions_.clear();
|
| + NOTREACHED();
|
| }
|
| }
|
|
|
| @@ -267,6 +264,18 @@ gfx::Image OmniboxAPI::GetOmniboxPopupIcon(const std::string& extension_id) {
|
| omnibox_popup_icon_manager_.GetIcon(extension_id));
|
| }
|
|
|
| +void OmniboxAPI::OnTemplateURLsLoaded() {
|
| + // Register keywords for pending extensions.
|
| + template_url_sub_.reset();
|
| + for (PendingExtensions::const_iterator i(pending_extensions_.begin());
|
| + i != pending_extensions_.end(); ++i) {
|
| + url_service_->RegisterExtensionKeyword((*i)->id(),
|
| + (*i)->name(),
|
| + OmniboxInfo::GetKeyword(*i));
|
| + }
|
| + pending_extensions_.clear();
|
| +}
|
| +
|
| template <>
|
| void ProfileKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() {
|
| DependsOn(ExtensionSystemFactory::GetInstance());
|
|
|