| 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" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/google/google_url_tracker_factory.h" | 12 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 13 #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" | 13 #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" |
| 14 #include "chrome/browser/google/google_url_tracker_navigation_helper.h" | 14 #include "chrome/browser/google/google_url_tracker_navigation_helper.h" |
| 15 #include "chrome/browser/google/google_util.h" | 15 #include "chrome/browser/google/google_util.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/common/chrome_switches.h" | |
| 18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "components/google/core/browser/google_switches.h" |
| 19 #include "components/google/core/browser/google_url_tracker_client.h" | 19 #include "components/google/core/browser/google_url_tracker_client.h" |
| 20 #include "components/infobars/core/infobar.h" | 20 #include "components/infobars/core/infobar.h" |
| 21 #include "components/infobars/core/infobar_manager.h" | 21 #include "components/infobars/core/infobar_manager.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| 24 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
| 25 #include "net/url_request/url_fetcher.h" | 25 #include "net/url_request/url_fetcher.h" |
| 26 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
| 27 | 27 |
| 28 | 28 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // | 234 // |
| 235 // See comments in header on the class, on RequestServerCheck(), and on the | 235 // See comments in header on the class, on RequestServerCheck(), and on the |
| 236 // various members here for more detail on exactly what the conditions are. | 236 // various members here for more detail on exactly what the conditions are. |
| 237 if (in_startup_sleep_ || already_fetched_ || !need_to_fetch_) | 237 if (in_startup_sleep_ || already_fetched_ || !need_to_fetch_) |
| 238 return; | 238 return; |
| 239 | 239 |
| 240 // Some switches should disable the Google URL tracker entirely. If we can't | 240 // Some switches should disable the Google URL tracker entirely. If we can't |
| 241 // do background networking, we can't do the necessary fetch, and if the user | 241 // do background networking, we can't do the necessary fetch, and if the user |
| 242 // specified a Google base URL manually, we shouldn't bother to look up any | 242 // specified a Google base URL manually, we shouldn't bother to look up any |
| 243 // alternatives or offer to switch to them. | 243 // alternatives or offer to switch to them. |
| 244 if (CommandLine::ForCurrentProcess()->HasSwitch( | 244 if (!client_->IsBackgroundNetworkingEnabled() || |
| 245 switches::kDisableBackgroundNetworking) || | |
| 246 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGoogleBaseURL)) | 245 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGoogleBaseURL)) |
| 247 return; | 246 return; |
| 248 | 247 |
| 249 already_fetched_ = true; | 248 already_fetched_ = true; |
| 250 fetcher_.reset(net::URLFetcher::Create( | 249 fetcher_.reset(net::URLFetcher::Create( |
| 251 fetcher_id_, GURL(kSearchDomainCheckURL), net::URLFetcher::GET, this)); | 250 fetcher_id_, GURL(kSearchDomainCheckURL), net::URLFetcher::GET, this)); |
| 252 ++fetcher_id_; | 251 ++fetcher_id_; |
| 253 // We don't want this fetch to set new entries in the cache or cookies, lest | 252 // We don't want this fetch to set new entries in the cache or cookies, lest |
| 254 // we alarm the user. | 253 // we alarm the user. |
| 255 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | | 254 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 417 } |
| 419 if (client_->IsListeningForNavigationStart()) { | 418 if (client_->IsListeningForNavigationStart()) { |
| 420 DCHECK(!search_committed_); | 419 DCHECK(!search_committed_); |
| 421 client_->SetListeningForNavigationStart(false); | 420 client_->SetListeningForNavigationStart(false); |
| 422 } | 421 } |
| 423 } | 422 } |
| 424 | 423 |
| 425 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { | 424 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { |
| 426 callback_list_.Notify(old_url, new_url); | 425 callback_list_.Notify(old_url, new_url); |
| 427 } | 426 } |
| OLD | NEW |