| OLD | NEW | 
|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search/search.h" | 5 #include "chrome/browser/search/search.h" | 
| 6 | 6 | 
| 7 #include <stddef.h> | 7 #include <stddef.h> | 
| 8 | 8 | 
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" | 
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" | 
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 483 | 483 | 
| 484 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { | 484 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { | 
| 485   CHECK(ShouldAssignURLToInstantRenderer(url, profile)) | 485   CHECK(ShouldAssignURLToInstantRenderer(url, profile)) | 
| 486       << "Error granting Instant access."; | 486       << "Error granting Instant access."; | 
| 487 | 487 | 
| 488   if (url.SchemeIs(chrome::kChromeSearchScheme)) | 488   if (url.SchemeIs(chrome::kChromeSearchScheme)) | 
| 489     return url; | 489     return url; | 
| 490 | 490 | 
| 491   GURL effective_url(url); | 491   GURL effective_url(url); | 
| 492 | 492 | 
| 493   // Replace the scheme with "chrome-search:". | 493   // Replace the scheme with "chrome-search:", and clear the port, since | 
|  | 494   // chrome-search is a scheme without port. | 
| 494   url::Replacements<char> replacements; | 495   url::Replacements<char> replacements; | 
| 495   std::string search_scheme(chrome::kChromeSearchScheme); | 496   std::string search_scheme(chrome::kChromeSearchScheme); | 
| 496   replacements.SetScheme(search_scheme.data(), | 497   replacements.SetScheme(search_scheme.data(), | 
| 497                          url::Component(0, search_scheme.length())); | 498                          url::Component(0, search_scheme.length())); | 
|  | 499   replacements.ClearPort(); | 
| 498 | 500 | 
| 499   // If this is the URL for a server-provided NTP, replace the host with | 501   // If this is the URL for a server-provided NTP, replace the host with | 
| 500   // "remote-ntp". | 502   // "remote-ntp". | 
| 501   std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost); | 503   std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost); | 
| 502   NewTabURLDetails details = NewTabURLDetails::ForProfile(profile); | 504   NewTabURLDetails details = NewTabURLDetails::ForProfile(profile); | 
| 503   if (details.state == NEW_TAB_URL_VALID && | 505   if (details.state == NEW_TAB_URL_VALID && | 
| 504       MatchesOriginAndPath(url, details.url)) { | 506       MatchesOriginAndPath(url, details.url)) { | 
| 505     replacements.SetHost(remote_ntp_host.c_str(), | 507     replacements.SetHost(remote_ntp_host.c_str(), | 
| 506                          url::Component(0, remote_ntp_host.length())); | 508                          url::Component(0, remote_ntp_host.length())); | 
| 507   } | 509   } | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 584       kUseAltInstantURL, false, flags); | 586       kUseAltInstantURL, false, flags); | 
| 585 } | 587 } | 
| 586 | 588 | 
| 587 bool ShouldUseSearchPathForInstant() { | 589 bool ShouldUseSearchPathForInstant() { | 
| 588   FieldTrialFlags flags; | 590   FieldTrialFlags flags; | 
| 589   return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 591   return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 
| 590       kUseSearchPathForInstant, false, flags); | 592       kUseSearchPathForInstant, false, flags); | 
| 591 } | 593 } | 
| 592 | 594 | 
| 593 }  // namespace search | 595 }  // namespace search | 
| OLD | NEW | 
|---|