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