| 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 "components/google/core/browser/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" | |
| 12 #include "chrome/browser/google/google_url_tracker_factory.h" | |
| 13 #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" | |
| 14 #include "chrome/browser/google/google_url_tracker_navigation_helper.h" | |
| 15 #include "chrome/browser/google/google_util.h" | |
| 16 #include "chrome/common/pref_names.h" | |
| 17 #include "components/google/core/browser/google_pref_names.h" | 11 #include "components/google/core/browser/google_pref_names.h" |
| 18 #include "components/google/core/browser/google_switches.h" | 12 #include "components/google/core/browser/google_switches.h" |
| 19 #include "components/google/core/browser/google_url_tracker_client.h" | 13 #include "components/google/core/browser/google_url_tracker_infobar_delegate.h" |
| 14 #include "components/google/core/browser/google_url_tracker_navigation_helper.h" |
| 20 #include "components/infobars/core/infobar.h" | 15 #include "components/infobars/core/infobar.h" |
| 21 #include "components/infobars/core/infobar_manager.h" | 16 #include "components/infobars/core/infobar_manager.h" |
| 22 #include "content/public/browser/notification_service.h" | |
| 23 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 24 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 25 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
| 26 #include "net/url_request/url_request_status.h" | 20 #include "net/url_request/url_request_status.h" |
| 27 | 21 |
| 28 | 22 |
| 29 const char GoogleURLTracker::kDefaultGoogleHomepage[] = | 23 const char GoogleURLTracker::kDefaultGoogleHomepage[] = |
| 30 "http://www.google.com/"; | 24 "http://www.google.com/"; |
| 31 const char GoogleURLTracker::kSearchDomainCheckURL[] = | 25 const char GoogleURLTracker::kSearchDomainCheckURL[] = |
| 32 "https://www.google.com/searchdomaincheck?format=url&type=chrome"; | 26 "https://www.google.com/searchdomaincheck?format=url&type=chrome"; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 115 } |
| 122 | 116 |
| 123 // See if the response data was valid. It should be | 117 // See if the response data was valid. It should be |
| 124 // "<scheme>://[www.]google.<TLD>/". | 118 // "<scheme>://[www.]google.<TLD>/". |
| 125 std::string url_str; | 119 std::string url_str; |
| 126 source->GetResponseAsString(&url_str); | 120 source->GetResponseAsString(&url_str); |
| 127 base::TrimWhitespace(url_str, base::TRIM_ALL, &url_str); | 121 base::TrimWhitespace(url_str, base::TRIM_ALL, &url_str); |
| 128 GURL url(url_str); | 122 GURL url(url_str); |
| 129 if (!url.is_valid() || (url.path().length() > 1) || url.has_query() || | 123 if (!url.is_valid() || (url.path().length() > 1) || url.has_query() || |
| 130 url.has_ref() || | 124 url.has_ref() || |
| 131 !google_util::IsGoogleDomainUrl(url, google_util::DISALLOW_SUBDOMAIN, | 125 !client_->IsGoogleDomainURL(url)) |
| 132 google_util::DISALLOW_NON_STANDARD_PORTS)) | |
| 133 return; | 126 return; |
| 134 | 127 |
| 135 std::swap(url, fetched_google_url_); | 128 std::swap(url, fetched_google_url_); |
| 136 GURL last_prompted_url( | 129 GURL last_prompted_url( |
| 137 client_->GetPrefs()->GetString(prefs::kLastPromptedGoogleURL)); | 130 client_->GetPrefs()->GetString(prefs::kLastPromptedGoogleURL)); |
| 138 | 131 |
| 139 if (last_prompted_url.is_empty()) { | 132 if (last_prompted_url.is_empty()) { |
| 140 // On the very first run of Chrome, when we've never looked up the URL at | 133 // On the very first run of Chrome, when we've never looked up the URL at |
| 141 // all, we should just silently switch over to whatever we get immediately. | 134 // all, we should just silently switch over to whatever we get immediately. |
| 142 AcceptGoogleURL(true); // Arg is irrelevant. | 135 AcceptGoogleURL(true); // Arg is irrelevant. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 391 } |
| 399 if (client_->IsListeningForNavigationStart()) { | 392 if (client_->IsListeningForNavigationStart()) { |
| 400 DCHECK(!search_committed_); | 393 DCHECK(!search_committed_); |
| 401 client_->SetListeningForNavigationStart(false); | 394 client_->SetListeningForNavigationStart(false); |
| 402 } | 395 } |
| 403 } | 396 } |
| 404 | 397 |
| 405 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { | 398 void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { |
| 406 callback_list_.Notify(old_url, new_url); | 399 callback_list_.Notify(old_url, new_url); |
| 407 } | 400 } |
| OLD | NEW |