Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/browser/search/local_ntp_source.cc

Issue 2670123003: [Local NTP] Cleanup: Remove support for "icons" layout (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/local_ntp/local_ntp.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return false; 81 return false;
82 82
83 const TemplateURL* default_provider = 83 const TemplateURL* default_provider =
84 template_url_service->GetDefaultSearchProvider(); 84 template_url_service->GetDefaultSearchProvider();
85 return default_provider && 85 return default_provider &&
86 (default_provider->GetEngineType( 86 (default_provider->GetEngineType(
87 template_url_service->search_terms_data()) == 87 template_url_service->search_terms_data()) ==
88 SEARCH_ENGINE_GOOGLE); 88 SEARCH_ENGINE_GOOGLE);
89 } 89 }
90 90
91 // Returns whether icon NTP is enabled by experiment.
92 // TODO(huangs): Remove all 3 copies of this routine once Icon NTP launches.
93 bool IsIconNTPEnabled() {
94 // Note: It's important to query the field trial state first, to ensure that
95 // UMA reports the correct group.
96 const std::string group_name = base::FieldTrialList::FindFullName("IconNTP");
97 using base::CommandLine;
98 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableIconNtp))
99 return false;
100 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableIconNtp))
101 return true;
102
103 return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE);
104 }
105
106 // Adds a localized string keyed by resource id to the dictionary. 91 // Adds a localized string keyed by resource id to the dictionary.
107 void AddString(base::DictionaryValue* dictionary, 92 void AddString(base::DictionaryValue* dictionary,
108 const std::string& key, 93 const std::string& key,
109 int resource_id) { 94 int resource_id) {
110 dictionary->SetString(key, l10n_util::GetStringUTF16(resource_id)); 95 dictionary->SetString(key, l10n_util::GetStringUTF16(resource_id));
111 } 96 }
112 97
113 // Adds a localized string for the Google searchbox placeholder text. 98 // Adds a localized string for the Google searchbox placeholder text.
114 void AddGoogleSearchboxPlaceholderString(base::DictionaryValue* dictionary) { 99 void AddGoogleSearchboxPlaceholderString(base::DictionaryValue* dictionary) {
115 base::string16 placeholder = l10n_util::GetStringFUTF16( 100 base::string16 placeholder = l10n_util::GetStringFUTF16(
(...skipping 25 matching lines...) Expand all
141 return translated_strings; 126 return translated_strings;
142 } 127 }
143 128
144 // Returns a JS dictionary of configuration data for the local NTP. 129 // Returns a JS dictionary of configuration data for the local NTP.
145 std::string GetConfigData(Profile* profile) { 130 std::string GetConfigData(Profile* profile) {
146 base::DictionaryValue config_data; 131 base::DictionaryValue config_data;
147 bool is_google = DefaultSearchProviderIsGoogle(profile); 132 bool is_google = DefaultSearchProviderIsGoogle(profile);
148 config_data.Set("translatedStrings", 133 config_data.Set("translatedStrings",
149 GetTranslatedStrings(is_google).release()); 134 GetTranslatedStrings(is_google).release());
150 config_data.SetBoolean("isGooglePage", is_google); 135 config_data.SetBoolean("isGooglePage", is_google);
151 config_data.SetBoolean("useIcons", IsIconNTPEnabled());
152 136
153 // Serialize the dictionary. 137 // Serialize the dictionary.
154 std::string js_text; 138 std::string js_text;
155 JSONStringValueSerializer serializer(&js_text); 139 JSONStringValueSerializer serializer(&js_text);
156 serializer.Serialize(config_data); 140 serializer.Serialize(config_data);
157 141
158 std::string config_data_js; 142 std::string config_data_js;
159 config_data_js.append("var configData = "); 143 config_data_js.append("var configData = ");
160 config_data_js.append(js_text); 144 config_data_js.append(js_text);
161 config_data_js.append(";"); 145 config_data_js.append(";");
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 253 }
270 } 254 }
271 return false; 255 return false;
272 } 256 }
273 257
274 std::string LocalNtpSource::GetContentSecurityPolicyChildSrc() const { 258 std::string LocalNtpSource::GetContentSecurityPolicyChildSrc() const {
275 // Allow embedding of most visited iframes. 259 // Allow embedding of most visited iframes.
276 return base::StringPrintf("child-src %s;", 260 return base::StringPrintf("child-src %s;",
277 chrome::kChromeSearchMostVisitedUrl); 261 chrome::kChromeSearchMostVisitedUrl);
278 } 262 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/local_ntp.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698