OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/google/google_url_tracker.h" | 5 #include "chrome/browser/google/google_url_tracker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 // static | 97 // static |
98 void GoogleURLTracker::GoogleURLSearchCommitted(Profile* profile) { | 98 void GoogleURLTracker::GoogleURLSearchCommitted(Profile* profile) { |
99 GoogleURLTracker* tracker = GoogleURLTrackerFactory::GetForProfile(profile); | 99 GoogleURLTracker* tracker = GoogleURLTrackerFactory::GetForProfile(profile); |
100 if (tracker) | 100 if (tracker) |
101 tracker->SearchCommitted(); | 101 tracker->SearchCommitted(); |
102 } | 102 } |
103 | 103 |
104 void GoogleURLTracker::AcceptGoogleURL(bool redo_searches) { | 104 void GoogleURLTracker::AcceptGoogleURL(bool redo_searches) { |
105 UpdatedDetails urls(google_url_, fetched_google_url_); | 105 GURL old_google_url = google_url_; |
106 google_url_ = fetched_google_url_; | 106 google_url_ = fetched_google_url_; |
107 PrefService* prefs = profile_->GetPrefs(); | 107 PrefService* prefs = profile_->GetPrefs(); |
108 prefs->SetString(prefs::kLastKnownGoogleURL, google_url_.spec()); | 108 prefs->SetString(prefs::kLastKnownGoogleURL, google_url_.spec()); |
109 prefs->SetString(prefs::kLastPromptedGoogleURL, google_url_.spec()); | 109 prefs->SetString(prefs::kLastPromptedGoogleURL, google_url_.spec()); |
110 NotifyGoogleURLUpdated(urls.first, urls.second); | 110 NotifyGoogleURLUpdated(old_google_url, google_url_); |
111 | 111 |
112 // TODO(blundell): Convert all clients to use the callback interface and | |
113 // eliminate this notification. crbug.com/373237 | |
114 content::NotificationService::current()->Notify( | |
115 chrome::NOTIFICATION_GOOGLE_URL_UPDATED, | |
116 content::Source<Profile>(profile_), | |
117 content::Details<UpdatedDetails>(&urls)); | |
118 need_to_prompt_ = false; | 112 need_to_prompt_ = false; |
119 CloseAllEntries(redo_searches); | 113 CloseAllEntries(redo_searches); |
120 } | 114 } |
121 | 115 |
122 void GoogleURLTracker::CancelGoogleURL() { | 116 void GoogleURLTracker::CancelGoogleURL() { |
123 profile_->GetPrefs()->SetString(prefs::kLastPromptedGoogleURL, | 117 profile_->GetPrefs()->SetString(prefs::kLastPromptedGoogleURL, |
124 fetched_google_url_.spec()); | 118 fetched_google_url_.spec()); |
125 need_to_prompt_ = false; | 119 need_to_prompt_ = false; |
126 CloseAllEntries(false); | 120 CloseAllEntries(false); |
127 } | 121 } |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 } | 421 } |
428 if (nav_helper_->IsListeningForNavigationStart()) { | 422 if (nav_helper_->IsListeningForNavigationStart()) { |
429 DCHECK(!search_committed_); | 423 DCHECK(!search_committed_); |
430 nav_helper_->SetListeningForNavigationStart(false); | 424 nav_helper_->SetListeningForNavigationStart(false); |
431 } | 425 } |
432 } | 426 } |
433 | 427 |
434 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { | 428 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { |
435 callback_list_.Notify(old_url, new_url); | 429 callback_list_.Notify(old_url, new_url); |
436 } | 430 } |
OLD | NEW |