OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/local_ntp_source.h" | 5 #include "chrome/browser/search/local_ntp_source.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/search/instant_io_context.h" | 16 #include "chrome/browser/search/instant_io_context.h" |
17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
20 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
21 #include "components/search_engines/template_url_prepopulate_data.h" | 21 #include "components/search_engines/template_url_prepopulate_data.h" |
22 #include "components/search_engines/template_url_service.h" | 22 #include "components/search_engines/template_url_service.h" |
| 23 #include "components/variations/variations_associated_data.h" |
23 #include "grit/browser_resources.h" | 24 #include "grit/browser_resources.h" |
24 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
25 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
28 #include "ui/base/webui/jstemplate_builder.h" | 29 #include "ui/base/webui/jstemplate_builder.h" |
29 #include "ui/base/webui/web_ui_util.h" | 30 #include "ui/base/webui/web_ui_util.h" |
30 #include "ui/resources/grit/ui_resources.h" | 31 #include "ui/resources/grit/ui_resources.h" |
31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
32 | 33 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 const TemplateURL* default_provider = | 75 const TemplateURL* default_provider = |
75 template_url_service->GetDefaultSearchProvider(); | 76 template_url_service->GetDefaultSearchProvider(); |
76 return default_provider && | 77 return default_provider && |
77 (TemplateURLPrepopulateData::GetEngineType( | 78 (TemplateURLPrepopulateData::GetEngineType( |
78 *default_provider, template_url_service->search_terms_data()) == | 79 *default_provider, template_url_service->search_terms_data()) == |
79 SEARCH_ENGINE_GOOGLE); | 80 SEARCH_ENGINE_GOOGLE); |
80 } | 81 } |
81 | 82 |
82 // Returns whether icon NTP is enabled. | 83 // Returns whether icon NTP is enabled. |
83 bool IsIconNTPEnabled() { | 84 bool IsIconNTPEnabled() { |
84 return StartsWithASCII(base::FieldTrialList::FindFullName("IconNTP"), | 85 return variations::GetVariationParamValue("IconNTP", "state") == "enabled"; |
85 "Enabled", true); | |
86 } | 86 } |
87 | 87 |
88 // Returns whether we are in the Fast NTP experiment or not. | 88 // Returns whether we are in the Fast NTP experiment or not. |
89 bool IsLocalNTPFastEnabled() { | 89 bool IsLocalNTPFastEnabled() { |
90 return StartsWithASCII(base::FieldTrialList::FindFullName("LocalNTPFast"), | 90 return StartsWithASCII(base::FieldTrialList::FindFullName("LocalNTPFast"), |
91 "Enabled", true); | 91 "Enabled", true); |
92 } | 92 } |
93 | 93 |
94 // Serves a particular resource. | 94 // Serves a particular resource. |
95 // Used for bypassing the default resources when we are in an experiment. | 95 // Used for bypassing the default resources when we are in an experiment. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 239 } |
240 } | 240 } |
241 return false; | 241 return false; |
242 } | 242 } |
243 | 243 |
244 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { | 244 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { |
245 // Allow embedding of most visited iframes. | 245 // Allow embedding of most visited iframes. |
246 return base::StringPrintf("frame-src %s;", | 246 return base::StringPrintf("frame-src %s;", |
247 chrome::kChromeSearchMostVisitedUrl); | 247 chrome::kChromeSearchMostVisitedUrl); |
248 } | 248 } |
OLD | NEW |