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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "build/build_config.h" |
17 #include "chrome/browser/search/instant_io_context.h" | 18 #include "chrome/browser/search/instant_io_context.h" |
18 #include "chrome/browser/search/local_files_ntp_source.h" | 19 #include "chrome/browser/search/local_files_ntp_source.h" |
19 #include "chrome/browser/search/search.h" | 20 #include "chrome/browser/search/search.h" |
20 #include "chrome/browser/search_engines/template_url_service_factory.h" | 21 #include "chrome/browser/search_engines/template_url_service_factory.h" |
21 #include "chrome/browser/themes/theme_properties.h" | 22 #include "chrome/browser/themes/theme_properties.h" |
22 #include "chrome/browser/themes/theme_service.h" | 23 #include "chrome/browser/themes/theme_service.h" |
23 #include "chrome/browser/themes/theme_service_factory.h" | 24 #include "chrome/browser/themes/theme_service_factory.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
26 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 std::string config_data_js = GetConfigData(profile_); | 202 std::string config_data_js = GetConfigData(profile_); |
202 callback.Run(base::RefCountedString::TakeString(&config_data_js)); | 203 callback.Run(base::RefCountedString::TakeString(&config_data_js)); |
203 return; | 204 return; |
204 } | 205 } |
205 if (stripped_path == kThemeCSSFilename) { | 206 if (stripped_path == kThemeCSSFilename) { |
206 std::string theme_css = GetThemeCSS(profile_); | 207 std::string theme_css = GetThemeCSS(profile_); |
207 callback.Run(base::RefCountedString::TakeString(&theme_css)); | 208 callback.Run(base::RefCountedString::TakeString(&theme_css)); |
208 return; | 209 return; |
209 } | 210 } |
210 | 211 |
211 #if !defined(GOOGLE_CHROME_BUILD) | 212 #if !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS) |
212 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 213 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
213 if (command_line->HasSwitch(switches::kLocalNtpReload)) { | 214 if (command_line->HasSwitch(switches::kLocalNtpReload)) { |
214 if (stripped_path == "local-ntp.html" || stripped_path == "local-ntp.js" || | 215 if (stripped_path == "local-ntp.html" || stripped_path == "local-ntp.js" || |
215 stripped_path == "local-ntp.css") { | 216 stripped_path == "local-ntp.css") { |
216 base::ReplaceChars(stripped_path, "-", "_", &stripped_path); | 217 base::ReplaceChars(stripped_path, "-", "_", &stripped_path); |
217 local_ntp::SendLocalFileResource(stripped_path, callback); | 218 local_ntp::SendLocalFileResource(stripped_path, callback); |
218 return; | 219 return; |
219 } | 220 } |
220 } | 221 } |
221 #endif | 222 #endif // !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS) |
222 | 223 |
223 float scale = 1.0f; | 224 float scale = 1.0f; |
224 std::string filename; | 225 std::string filename; |
225 webui::ParsePathAndScale( | 226 webui::ParsePathAndScale( |
226 GURL(GetLocalNtpPath() + stripped_path), &filename, &scale); | 227 GURL(GetLocalNtpPath() + stripped_path), &filename, &scale); |
227 ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor(scale); | 228 ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor(scale); |
228 | 229 |
229 for (size_t i = 0; i < arraysize(kResources); ++i) { | 230 for (size_t i = 0; i < arraysize(kResources); ++i) { |
230 if (filename == kResources[i].filename) { | 231 if (filename == kResources[i].filename) { |
231 scoped_refptr<base::RefCountedStaticMemory> response( | 232 scoped_refptr<base::RefCountedStaticMemory> response( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 264 } |
264 } | 265 } |
265 return false; | 266 return false; |
266 } | 267 } |
267 | 268 |
268 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { | 269 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { |
269 // Allow embedding of most visited iframes. | 270 // Allow embedding of most visited iframes. |
270 return base::StringPrintf("frame-src %s;", | 271 return base::StringPrintf("frame-src %s;", |
271 chrome::kChromeSearchMostVisitedUrl); | 272 chrome::kChromeSearchMostVisitedUrl); |
272 } | 273 } |
OLD | NEW |