| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 // See if the response data was valid. It should be | 279 // See if the response data was valid. It should be |
| 280 // "<scheme>://[www.]google.<TLD>/". | 280 // "<scheme>://[www.]google.<TLD>/". |
| 281 std::string url_str; | 281 std::string url_str; |
| 282 source->GetResponseAsString(&url_str); | 282 source->GetResponseAsString(&url_str); |
| 283 TrimWhitespace(url_str, TRIM_ALL, &url_str); | 283 TrimWhitespace(url_str, TRIM_ALL, &url_str); |
| 284 GURL url(url_str); | 284 GURL url(url_str); |
| 285 if (!url.is_valid() || (url.path().length() > 1) || url.has_query() || | 285 if (!url.is_valid() || (url.path().length() > 1) || url.has_query() || |
| 286 url.has_ref() || | 286 url.has_ref() || |
| 287 !google_util::IsGoogleDomainUrl(url.spec(), | 287 !google_util::IsGoogleDomainUrl(url.spec(), |
| 288 google_util::DISALLOW_SUBDOMAIN)) | 288 google_util::DISALLOW_SUBDOMAIN, |
| 289 google_util::ALLOW_STANDARD_PORTS)) |
| 289 return; | 290 return; |
| 290 | 291 |
| 291 std::swap(url, fetched_google_url_); | 292 std::swap(url, fetched_google_url_); |
| 292 GURL last_prompted_url( | 293 GURL last_prompted_url( |
| 293 profile_->GetPrefs()->GetString(prefs::kLastPromptedGoogleURL)); | 294 profile_->GetPrefs()->GetString(prefs::kLastPromptedGoogleURL)); |
| 294 | 295 |
| 295 if (last_prompted_url.is_empty()) { | 296 if (last_prompted_url.is_empty()) { |
| 296 // On the very first run of Chrome, when we've never looked up the URL at | 297 // On the very first run of Chrome, when we've never looked up the URL at |
| 297 // all, we should just silently switch over to whatever we get immediately. | 298 // all, we should just silently switch over to whatever we get immediately. |
| 298 AcceptGoogleURL(fetched_google_url_, true); // Second arg is irrelevant. | 299 AcceptGoogleURL(fetched_google_url_, true); // Second arg is irrelevant. |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 const bool registered_for_tab_contents_destroyed = | 630 const bool registered_for_tab_contents_destroyed = |
| 630 registrar_.IsRegistered(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, | 631 registrar_.IsRegistered(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
| 631 map_entry.tab_contents_source); | 632 map_entry.tab_contents_source); |
| 632 DCHECK_NE(registered_for_tab_contents_destroyed, | 633 DCHECK_NE(registered_for_tab_contents_destroyed, |
| 633 map_entry.infobar->showing()); | 634 map_entry.infobar->showing()); |
| 634 if (registered_for_tab_contents_destroyed) { | 635 if (registered_for_tab_contents_destroyed) { |
| 635 registrar_.Remove(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, | 636 registrar_.Remove(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
| 636 map_entry.tab_contents_source); | 637 map_entry.tab_contents_source); |
| 637 } | 638 } |
| 638 } | 639 } |
| OLD | NEW |