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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 | 534 |
535 // Replace the scheme with "chrome-search:". | 535 // Replace the scheme with "chrome-search:". |
536 url_canon::Replacements<char> replacements; | 536 url_canon::Replacements<char> replacements; |
537 std::string search_scheme(chrome::kChromeSearchScheme); | 537 std::string search_scheme(chrome::kChromeSearchScheme); |
538 replacements.SetScheme(search_scheme.data(), | 538 replacements.SetScheme(search_scheme.data(), |
539 url_parse::Component(0, search_scheme.length())); | 539 url_parse::Component(0, search_scheme.length())); |
540 | 540 |
541 // If the URL corresponds to an online NTP, replace the host with | 541 // If the URL corresponds to an online NTP, replace the host with |
542 // "online-ntp". | 542 // "online-ntp". |
543 std::string online_ntp_host(chrome::kChromeSearchOnlineNtpHost); | 543 std::string online_ntp_host(chrome::kChromeSearchOnlineNtpHost); |
544 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); | 544 const GURL new_tab_url(GetNewTabPageURL(profile)); |
545 if (template_url) { | 545 if (new_tab_url.is_valid() && |
546 const GURL instant_url = TemplateURLRefToGURL( | 546 search::MatchesOriginAndPath(url, new_tab_url)) { |
547 template_url->instant_url_ref(), kDisableStartMargin, false, false); | 547 replacements.SetHost(online_ntp_host.c_str(), |
kmadhusu
2014/01/13 17:12:19
Do we need to change the host to "ntp" or somethin
samarth
2014/02/03 22:47:12
This will make the host for the cacheable NTP be "
kmadhusu
2014/02/03 22:54:25
Yes. Do we need to change the host name to "cachea
samarth
2014/02/03 23:32:19
This name is not persisted anywhere, so it doesn't
| |
548 if (instant_url.is_valid() && | 548 url_parse::Component(0, online_ntp_host.length())); |
549 search::MatchesOriginAndPath(url, instant_url)) { | |
550 replacements.SetHost(online_ntp_host.c_str(), | |
551 url_parse::Component(0, online_ntp_host.length())); | |
552 } | |
553 } | 549 } |
554 | 550 |
555 effective_url = effective_url.ReplaceComponents(replacements); | 551 effective_url = effective_url.ReplaceComponents(replacements); |
556 return effective_url; | 552 return effective_url; |
557 } | 553 } |
558 | 554 |
559 bool HandleNewTabURLRewrite(GURL* url, | 555 bool HandleNewTabURLRewrite(GURL* url, |
560 content::BrowserContext* browser_context) { | 556 content::BrowserContext* browser_context) { |
561 if (!IsInstantExtendedAPIEnabled()) | 557 if (!IsInstantExtendedAPIEnabled()) |
562 return false; | 558 return false; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 | 671 |
676 // Given a FieldTrialFlags object, returns the boolean value of the provided | 672 // Given a FieldTrialFlags object, returns the boolean value of the provided |
677 // flag. | 673 // flag. |
678 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 674 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
679 bool default_value, | 675 bool default_value, |
680 const FieldTrialFlags& flags) { | 676 const FieldTrialFlags& flags) { |
681 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 677 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
682 } | 678 } |
683 | 679 |
684 } // namespace chrome | 680 } // namespace chrome |
OLD | NEW |