| 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 GURL old_google_url = google_url_; | 105 UpdatedDetails urls(google_url_, fetched_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(old_google_url, google_url_); | 110 NotifyGoogleURLUpdated(urls.first, urls.second); |
| 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)); |
| 112 need_to_prompt_ = false; | 118 need_to_prompt_ = false; |
| 113 CloseAllEntries(redo_searches); | 119 CloseAllEntries(redo_searches); |
| 114 } | 120 } |
| 115 | 121 |
| 116 void GoogleURLTracker::CancelGoogleURL() { | 122 void GoogleURLTracker::CancelGoogleURL() { |
| 117 profile_->GetPrefs()->SetString(prefs::kLastPromptedGoogleURL, | 123 profile_->GetPrefs()->SetString(prefs::kLastPromptedGoogleURL, |
| 118 fetched_google_url_.spec()); | 124 fetched_google_url_.spec()); |
| 119 need_to_prompt_ = false; | 125 need_to_prompt_ = false; |
| 120 CloseAllEntries(false); | 126 CloseAllEntries(false); |
| 121 } | 127 } |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 } | 427 } |
| 422 if (nav_helper_->IsListeningForNavigationStart()) { | 428 if (nav_helper_->IsListeningForNavigationStart()) { |
| 423 DCHECK(!search_committed_); | 429 DCHECK(!search_committed_); |
| 424 nav_helper_->SetListeningForNavigationStart(false); | 430 nav_helper_->SetListeningForNavigationStart(false); |
| 425 } | 431 } |
| 426 } | 432 } |
| 427 | 433 |
| 428 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { | 434 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { |
| 429 callback_list_.Notify(old_url, new_url); | 435 callback_list_.Notify(old_url, new_url); |
| 430 } | 436 } |
| OLD | NEW |