Chromium Code Reviews| Index: chrome/browser/google/google_url_tracker.cc |
| diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc |
| index e81fc282bbe6d06a9abb12c0cfef939af731e22c..6429b4b224c069da1d2093d3aeb38ebf0020f247 100644 |
| --- a/chrome/browser/google/google_url_tracker.cc |
| +++ b/chrome/browser/google/google_url_tracker.cc |
| @@ -33,17 +33,15 @@ const char GoogleURLTracker::kDefaultGoogleHomepage[] = |
| const char GoogleURLTracker::kSearchDomainCheckURL[] = |
| "https://www.google.com/searchdomaincheck?format=url&type=chrome"; |
| -GoogleURLTracker::GoogleURLTracker( |
| - Profile* profile, |
| - scoped_ptr<GoogleURLTrackerClient> client, |
| - scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper, |
| - Mode mode) |
| +GoogleURLTracker::GoogleURLTracker(Profile* profile, |
| + scoped_ptr<GoogleURLTrackerClient> client, |
| + Mode mode) |
| : profile_(profile), |
| client_(client.Pass()), |
| - nav_helper_(nav_helper.Pass()), |
| infobar_creator_(base::Bind(&GoogleURLTrackerInfoBarDelegate::Create)), |
| - google_url_(mode == UNIT_TEST_MODE ? kDefaultGoogleHomepage : |
| - profile->GetPrefs()->GetString(prefs::kLastKnownGoogleURL)), |
| + google_url_(mode == UNIT_TEST_MODE ? kDefaultGoogleHomepage |
| + : profile->GetPrefs()->GetString( |
| + prefs::kLastKnownGoogleURL)), |
|
Peter Kasting
2014/05/15 21:29:52
Nit: Wrap like this:
google_url_((mode == U
blundell
2014/05/16 11:54:18
Done.
|
| fetcher_id_(0), |
| in_startup_sleep_(true), |
| already_fetched_(false), |
| @@ -53,7 +51,6 @@ GoogleURLTracker::GoogleURLTracker( |
| weak_ptr_factory_(this) { |
| net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| client_->set_google_url_tracker(this); |
| - nav_helper_->SetGoogleURLTracker(this); |
| // Because this function can be called during startup, when kicking off a URL |
| // fetch can eat up 20 ms of time, we delay five seconds, which is hopefully |
| @@ -206,7 +203,6 @@ void GoogleURLTracker::OnIPAddressChanged() { |
| void GoogleURLTracker::Shutdown() { |
| client_.reset(); |
| - nav_helper_.reset(); |
| fetcher_.reset(); |
| weak_ptr_factory_.InvalidateWeakPtrs(); |
| net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| @@ -282,7 +278,7 @@ void GoogleURLTracker::SearchCommitted() { |
| } |
| void GoogleURLTracker::OnNavigationPending( |
| - content::NavigationController* navigation_controller, |
| + GoogleURLTrackerNavigationHelper* nav_helper, |
| InfoBarService* infobar_service, |
| int pending_id) { |
| EntryMap::iterator i(entry_map_.find(infobar_service)); |
| @@ -293,9 +289,8 @@ void GoogleURLTracker::OnNavigationPending( |
| // load to commit, so we can show and/or update the infobar when it does. |
| // (We may already be registered for this if there is an existing infobar |
| // that had a previous pending search that hasn't yet committed.) |
| - if (!nav_helper_->IsListeningForNavigationCommit(navigation_controller)) { |
| - nav_helper_->SetListeningForNavigationCommit(navigation_controller, |
| - true); |
| + if (!nav_helper->IsListeningForNavigationCommit()) { |
| + nav_helper->SetListeningForNavigationCommit(true); |
| } |
| if (i == entry_map_.end()) { |
| // This is a search on a tab that doesn't have one of our infobars, so |
| @@ -304,11 +299,10 @@ void GoogleURLTracker::OnNavigationPending( |
| // yet have an infobar and we're already registered for this, or it has an |
| // infobar and the infobar's owner will handle tearing it down when the |
| // tab is destroyed. |
| - nav_helper_->SetListeningForTabDestruction(navigation_controller, true); |
| + nav_helper->SetListeningForTabDestruction(true); |
| entry_map_.insert(std::make_pair( |
| infobar_service, |
| - new GoogleURLTrackerMapEntry(this, infobar_service, |
| - navigation_controller))); |
| + new GoogleURLTrackerMapEntry(this, infobar_service, nav_helper))); |
| } else if (i->second->has_infobar_delegate()) { |
| // This is a new search on a tab where we already have an infobar. |
| i->second->infobar_delegate()->set_pending_id(pending_id); |
| @@ -361,7 +355,7 @@ void GoogleURLTracker::OnNavigationCommitted(InfoBarService* infobar_service, |
| } |
| void GoogleURLTracker::OnTabClosed( |
| - content::NavigationController* navigation_controller) { |
| + GoogleURLTrackerNavigationHelper* nav_helper) { |
| // Because InfoBarService tears itself down on tab destruction, it's possible |
| // to get a non-NULL InfoBarService pointer here, depending on which order |
| // notifications fired in. Likewise, the pointer in |entry_map_| (and in its |
| @@ -371,7 +365,7 @@ void GoogleURLTracker::OnTabClosed( |
| // function doesn't need to do even that, but others in the call chain from |
| // here might (and have comments pointing back here). |
| for (EntryMap::iterator i(entry_map_.begin()); i != entry_map_.end(); ++i) { |
| - if (i->second->navigation_controller() == navigation_controller) { |
| + if (i->second->navigation_helper() == nav_helper) { |
| i->second->Close(false); |
| return; |
| } |
| @@ -386,26 +380,22 @@ void GoogleURLTracker::CloseAllEntries(bool redo_searches) { |
| } |
| void GoogleURLTracker::UnregisterForEntrySpecificNotifications( |
| - const GoogleURLTrackerMapEntry& map_entry, |
| + GoogleURLTrackerMapEntry& map_entry, |
| bool must_be_listening_for_commit) { |
| // For tabs with map entries but no infobars, we should always be listening |
| // for both these notifications. For tabs with infobars, we may be listening |
| // for navigation commits if the user has performed a new search on this tab. |
| - if (nav_helper_->IsListeningForNavigationCommit( |
| - map_entry.navigation_controller())) { |
| - nav_helper_->SetListeningForNavigationCommit( |
| - map_entry.navigation_controller(), false); |
| + if (map_entry.navigation_helper()->IsListeningForNavigationCommit()) { |
|
blundell
2014/05/15 15:24:14
This is the core of the change: rather than there
|
| + map_entry.navigation_helper()->SetListeningForNavigationCommit(false); |
| } else { |
| DCHECK(!must_be_listening_for_commit); |
| DCHECK(map_entry.has_infobar_delegate()); |
| } |
| const bool registered_for_tab_destruction = |
| - nav_helper_->IsListeningForTabDestruction( |
| - map_entry.navigation_controller()); |
| + map_entry.navigation_helper()->IsListeningForTabDestruction(); |
| DCHECK_NE(registered_for_tab_destruction, map_entry.has_infobar_delegate()); |
| if (registered_for_tab_destruction) { |
| - nav_helper_->SetListeningForTabDestruction( |
| - map_entry.navigation_controller(), false); |
| + map_entry.navigation_helper()->SetListeningForTabDestruction(false); |
| } |
| // Our global listeners for these other notifications should be in place iff |
| @@ -415,8 +405,7 @@ void GoogleURLTracker::UnregisterForEntrySpecificNotifications( |
| // See the various cases inside OnNavigationPending(). |
| for (EntryMap::const_iterator i(entry_map_.begin()); i != entry_map_.end(); |
| ++i) { |
| - if (nav_helper_->IsListeningForNavigationCommit( |
| - i->second->navigation_controller())) { |
| + if (i->second->navigation_helper()->IsListeningForNavigationCommit()) { |
| DCHECK(client_->IsListeningForNavigationStart()); |
| return; |
| } |