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

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

Issue 287103002: Introduce ability to register callback with GoogleURLTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 b191de6bbe39ff2a4d70b5ae5b04830b9f122ee1..b381ee87f65e5d483b74ccde3178e368641c62c5 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/google/google_url_tracker.h"
+#include "chrome/browser/google/google_url_tracker_factory.h"
#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
@@ -980,18 +981,17 @@ base::string16 TemplateURLService::GetKeywordShortName(
void TemplateURLService::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (type == chrome::NOTIFICATION_HISTORY_URL_VISITED) {
- content::Details<history::URLVisitedDetails> visit_details(details);
- if (!loaded_)
- visits_to_add_.push_back(*visit_details.ptr());
- else
- UpdateKeywordSearchTermsForURL(*visit_details.ptr());
- } else {
- DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_URL_UPDATED, type);
- if (loaded_) {
- GoogleBaseURLChanged(
- content::Details<GoogleURLTracker::UpdatedDetails>(details)->first);
- }
+ DCHECK_EQ(type, chrome::NOTIFICATION_HISTORY_URL_VISITED);
+ content::Details<history::URLVisitedDetails> visit_details(details);
+ if (!loaded_)
+ visits_to_add_.push_back(*visit_details.ptr());
+ else
+ UpdateKeywordSearchTermsForURL(*visit_details.ptr());
+}
+
+void TemplateURLService::OnGoogleURLUpdated(GURL old_url, GURL new_url) {
+ if (loaded_) {
+ GoogleBaseURLChanged(old_url);
}
}
@@ -1508,8 +1508,13 @@ void TemplateURLService::Init(const Initializer* initializers,
content::Source<Profile> profile_source(profile_->GetOriginalProfile());
notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED,
profile_source);
- notification_registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED,
- profile_source);
+ GoogleURLTracker* google_url_tracker =
+ GoogleURLTrackerFactory::GetForProfile(profile_);
+ if (google_url_tracker) {
+ google_url_updated_subscription_ =
+ google_url_tracker->RegisterCallback(base::Bind(
+ &TemplateURLService::OnGoogleURLUpdated, base::Unretained(this)));
+ }
pref_change_registrar_.Init(GetPrefs());
pref_change_registrar_.Add(
prefs::kSyncedDefaultSearchProviderGUID,

Powered by Google App Engine
This is Rietveld 408576698