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

Unified Diff: chrome/browser/extensions/api/omnibox/omnibox_api.cc

Issue 23710022: Convert NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED to CallbackList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean-up Created 7 years, 2 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
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());

Powered by Google App Engine
This is Rietveld 408576698