| 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 18 matching lines...) Expand all Loading... |
| 29 const char GoogleURLTracker::kDefaultGoogleHomepage[] = | 29 const char GoogleURLTracker::kDefaultGoogleHomepage[] = |
| 30 "http://www.google.com/"; | 30 "http://www.google.com/"; |
| 31 const char GoogleURLTracker::kSearchDomainCheckURL[] = | 31 const char GoogleURLTracker::kSearchDomainCheckURL[] = |
| 32 "https://www.google.com/searchdomaincheck?format=url&type=chrome"; | 32 "https://www.google.com/searchdomaincheck?format=url&type=chrome"; |
| 33 | 33 |
| 34 GoogleURLTracker::GoogleURLTracker(Profile* profile, | 34 GoogleURLTracker::GoogleURLTracker(Profile* profile, |
| 35 scoped_ptr<GoogleURLTrackerClient> client, | 35 scoped_ptr<GoogleURLTrackerClient> client, |
| 36 Mode mode) | 36 Mode mode) |
| 37 : profile_(profile), | 37 : profile_(profile), |
| 38 client_(client.Pass()), | 38 client_(client.Pass()), |
| 39 infobar_creator_(base::Bind(&GoogleURLTrackerInfoBarDelegate::Create)), | |
| 40 google_url_(mode == UNIT_TEST_MODE ? | 39 google_url_(mode == UNIT_TEST_MODE ? |
| 41 kDefaultGoogleHomepage : | 40 kDefaultGoogleHomepage : |
| 42 profile->GetPrefs()->GetString(prefs::kLastKnownGoogleURL)), | 41 profile->GetPrefs()->GetString(prefs::kLastKnownGoogleURL)), |
| 43 fetcher_id_(0), | 42 fetcher_id_(0), |
| 44 in_startup_sleep_(true), | 43 in_startup_sleep_(true), |
| 45 already_fetched_(false), | 44 already_fetched_(false), |
| 46 need_to_fetch_(false), | 45 need_to_fetch_(false), |
| 47 need_to_prompt_(false), | 46 need_to_prompt_(false), |
| 48 search_committed_(false), | 47 search_committed_(false), |
| 49 weak_ptr_factory_(this) { | 48 weak_ptr_factory_(this) { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 const GURL& search_url) { | 335 const GURL& search_url) { |
| 337 EntryMap::iterator i(entry_map_.find(infobar_manager)); | 336 EntryMap::iterator i(entry_map_.find(infobar_manager)); |
| 338 DCHECK(i != entry_map_.end()); | 337 DCHECK(i != entry_map_.end()); |
| 339 GoogleURLTrackerMapEntry* map_entry = i->second; | 338 GoogleURLTrackerMapEntry* map_entry = i->second; |
| 340 DCHECK(search_url.is_valid()); | 339 DCHECK(search_url.is_valid()); |
| 341 | 340 |
| 342 UnregisterForEntrySpecificNotifications(map_entry, true); | 341 UnregisterForEntrySpecificNotifications(map_entry, true); |
| 343 if (map_entry->has_infobar_delegate()) { | 342 if (map_entry->has_infobar_delegate()) { |
| 344 map_entry->infobar_delegate()->Update(search_url); | 343 map_entry->infobar_delegate()->Update(search_url); |
| 345 } else { | 344 } else { |
| 346 infobars::InfoBar* infobar = infobar_creator_.Run( | 345 infobars::InfoBar* infobar = GoogleURLTrackerInfoBarDelegate::Create( |
| 347 infobar_manager, this, search_url); | 346 infobar_manager, this, search_url); |
| 348 if (infobar) { | 347 if (infobar) { |
| 349 map_entry->SetInfoBarDelegate( | 348 map_entry->SetInfoBarDelegate( |
| 350 static_cast<GoogleURLTrackerInfoBarDelegate*>(infobar->delegate())); | 349 static_cast<GoogleURLTrackerInfoBarDelegate*>(infobar->delegate())); |
| 351 } else { | 350 } else { |
| 352 map_entry->Close(false); | 351 map_entry->Close(false); |
| 353 } | 352 } |
| 354 } | 353 } |
| 355 } | 354 } |
| 356 | 355 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 416 } |
| 418 if (client_->IsListeningForNavigationStart()) { | 417 if (client_->IsListeningForNavigationStart()) { |
| 419 DCHECK(!search_committed_); | 418 DCHECK(!search_committed_); |
| 420 client_->SetListeningForNavigationStart(false); | 419 client_->SetListeningForNavigationStart(false); |
| 421 } | 420 } |
| 422 } | 421 } |
| 423 | 422 |
| 424 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { | 423 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { |
| 425 callback_list_.Notify(old_url, new_url); | 424 callback_list_.Notify(old_url, new_url); |
| 426 } | 425 } |
| OLD | NEW |