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

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

Issue 23710022: Convert NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED to CallbackList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments and cleanup 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/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 02f1551a1de9d01df86414c3e862cb2e62673f69..47f43e5c87f4273f86a517ecb8510aa3c46b0da7 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -778,10 +778,18 @@ void TemplateURLService::Load() {
load_handle_ = service_->GetKeywords(this);
} else {
ChangeToLoadedState();
- NotifyLoaded();
+ on_loaded_callbacks_.Notify();
}
}
+scoped_ptr<TemplateURLService::Subscription>
+ TemplateURLService::RegisterOnLoadedCallback(
+ const base::Closure& callback) {
+ return loaded_ ?
+ scoped_ptr<TemplateURLService::Subscription>() :
+ on_loaded_callbacks_.Add(callback);
+}
+
void TemplateURLService::OnWebDataServiceRequestDone(
WebDataService::Handle h,
const WDTypedResult* result) {
@@ -794,7 +802,7 @@ void TemplateURLService::OnWebDataServiceRequestDone(
// loaded.
load_failed_ = true;
ChangeToLoadedState();
- NotifyLoaded();
+ on_loaded_callbacks_.Notify();
return;
}
@@ -826,7 +834,7 @@ void TemplateURLService::OnWebDataServiceRequestDone(
EnsureDefaultSearchProviderExists();
NotifyObservers();
- NotifyLoaded();
+ on_loaded_callbacks_.Notify();
}
string16 TemplateURLService::GetKeywordShortName(const string16& keyword,
@@ -1576,13 +1584,6 @@ void TemplateURLService::ChangeToLoadedState() {
loaded_ = true;
}
-void TemplateURLService::NotifyLoaded() {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
- content::Source<TemplateURLService>(this),
- content::NotificationService::NoDetails());
-}
-
void TemplateURLService::SaveDefaultSearchProviderToPrefs(
const TemplateURL* t_url) {
PrefService* prefs = GetPrefs();

Powered by Google App Engine
This is Rietveld 408576698