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 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:". |
|
samarth
2016/04/28 20:25:03
Can you extend this comment to explain why the por
ncarter (slow)
2016/04/28 22:21:49
Done.
| |
| 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(); | |
|
samarth
2016/04/28 20:25:03
nit: this line seems out of order since the search
samarth
2016/04/28 20:25:03
Can you add a test for this in search_unittest.cc?
ncarter (slow)
2016/04/28 22:21:49
Done.
ncarter (slow)
2016/04/28 22:21:49
Done.
| |
| 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 |