Chromium Code Reviews| 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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:". |
| 494 url::Replacements<char> replacements; | 494 url::Replacements<char> replacements; |
| 495 std::string search_scheme(chrome::kChromeSearchScheme); | 495 std::string search_scheme(chrome::kChromeSearchScheme); |
| 496 replacements.ClearPort(); | |
|
Charlie Reis
2016/04/22 18:11:09
I'll defer to Samarth or someone familiar with the
ncarter (slow)
2016/04/22 20:00:34
We're erasing the underlying scheme anyway (which
Charlie Reis
2016/04/22 20:20:46
That's a good point about losing the scheme. That
| |
| 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())); |
| 498 | 499 |
| 499 // If this is the URL for a server-provided NTP, replace the host with | 500 // If this is the URL for a server-provided NTP, replace the host with |
| 500 // "remote-ntp". | 501 // "remote-ntp". |
| 501 std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost); | 502 std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost); |
| 502 NewTabURLDetails details = NewTabURLDetails::ForProfile(profile); | 503 NewTabURLDetails details = NewTabURLDetails::ForProfile(profile); |
| 503 if (details.state == NEW_TAB_URL_VALID && | 504 if (details.state == NEW_TAB_URL_VALID && |
| 504 MatchesOriginAndPath(url, details.url)) { | 505 MatchesOriginAndPath(url, details.url)) { |
| 505 replacements.SetHost(remote_ntp_host.c_str(), | 506 replacements.SetHost(remote_ntp_host.c_str(), |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 kUseAltInstantURL, false, flags); | 585 kUseAltInstantURL, false, flags); |
| 585 } | 586 } |
| 586 | 587 |
| 587 bool ShouldUseSearchPathForInstant() { | 588 bool ShouldUseSearchPathForInstant() { |
| 588 FieldTrialFlags flags; | 589 FieldTrialFlags flags; |
| 589 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 590 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
| 590 kUseSearchPathForInstant, false, flags); | 591 kUseSearchPathForInstant, false, flags); |
| 591 } | 592 } |
| 592 | 593 |
| 593 } // namespace search | 594 } // namespace search |
| OLD | NEW |