diff options
-rw-r--r-- | chrome/browser/search_engines/template_url_model.cc | 17 | ||||
-rw-r--r-- | chrome/browser/search_engines/template_url_model.h | 8 |
2 files changed, 9 insertions, 16 deletions
diff --git a/chrome/browser/search_engines/template_url_model.cc b/chrome/browser/search_engines/template_url_model.cc index 97dd1d0..5a36b0e 100644 --- a/chrome/browser/search_engines/template_url_model.cc +++ b/chrome/browser/search_engines/template_url_model.cc @@ -92,30 +92,21 @@ TemplateURLModel::~TemplateURLModel() { } STLDeleteElements(&template_urls_); - - NotificationService* ns = NotificationService::current(); - if (profile_) { - ns->RemoveObserver(this, NotificationType::HISTORY_URL_VISITED, - Source<Profile>(profile_->GetOriginalProfile())); - } - ns->RemoveObserver(this, NotificationType::GOOGLE_URL_UPDATED, - NotificationService::AllSources()); } void TemplateURLModel::Init(const Initializer* initializers, int num_initializers) { // Register for notifications. - NotificationService* ns = NotificationService::current(); if (profile_) { // TODO(sky): bug 1166191. The keywords should be moved into the history // db, which will mean we no longer need this notification and the history // backend can handle automatically adding the search terms as the user // navigates. - ns->AddObserver(this, NotificationType::HISTORY_URL_VISITED, - Source<Profile>(profile_->GetOriginalProfile())); + registrar_.Add(this, NotificationType::HISTORY_URL_VISITED, + Source<Profile>(profile_->GetOriginalProfile())); } - ns->AddObserver(this, NotificationType::GOOGLE_URL_UPDATED, - NotificationService::AllSources()); + registrar_.Add(this, NotificationType::GOOGLE_URL_UPDATED, + NotificationService::AllSources()); // Add specific initializers, if any. for (int i(0); i < num_initializers; ++i) { diff --git a/chrome/browser/search_engines/template_url_model.h b/chrome/browser/search_engines/template_url_model.h index 094c506..c0e169b 100644 --- a/chrome/browser/search_engines/template_url_model.h +++ b/chrome/browser/search_engines/template_url_model.h @@ -13,7 +13,7 @@ #include "chrome/browser/history/history_notifications.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/webdata/web_data_service.h" -#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" class GURL; class PrefService; @@ -217,6 +217,8 @@ class TemplateURLModel : public WebDataServiceConsumer, typedef std::map<std::wstring, const TemplateURL*> KeywordToTemplateMap; typedef std::vector<const TemplateURL*> TemplateURLVector; + typedef std::set<const TemplateURL*> TemplateURLSet; + typedef std::map<std::string, TemplateURLSet> HostToURLsMap; // Helper functor for FindMatchingKeywords(), for finding the range of // keywords which begin with a prefix. @@ -298,6 +300,8 @@ class TemplateURLModel : public WebDataServiceConsumer, // {google:baseSuggestURL}. void GoogleBaseURLChanged(); + NotificationRegistrar registrar_; + // Mapping from keyword to the TemplateURL. KeywordToTemplateMap keyword_to_template_map_; @@ -306,8 +310,6 @@ class TemplateURLModel : public WebDataServiceConsumer, ObserverList<TemplateURLModelObserver> model_observers_; // Maps from host to set of TemplateURLs whose search url host is host. - typedef std::set<const TemplateURL*> TemplateURLSet; - typedef std::map<std::string, TemplateURLSet> HostToURLsMap; HostToURLsMap host_to_urls_map_; // Used to obtain the WebDataService. |