| 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" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 std::string config_data_js = GetConfigData(profile_); | 201 std::string config_data_js = GetConfigData(profile_); |
| 202 callback.Run(base::RefCountedString::TakeString(&config_data_js)); | 202 callback.Run(base::RefCountedString::TakeString(&config_data_js)); |
| 203 return; | 203 return; |
| 204 } | 204 } |
| 205 if (stripped_path == kThemeCSSFilename) { | 205 if (stripped_path == kThemeCSSFilename) { |
| 206 std::string theme_css = GetThemeCSS(profile_); | 206 std::string theme_css = GetThemeCSS(profile_); |
| 207 callback.Run(base::RefCountedString::TakeString(&theme_css)); | 207 callback.Run(base::RefCountedString::TakeString(&theme_css)); |
| 208 return; | 208 return; |
| 209 } | 209 } |
| 210 | 210 |
| 211 #if !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS) | 211 #if !defined(GOOGLE_CHROME_BUILD) |
| 212 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 212 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 213 if (command_line->HasSwitch(switches::kLocalNtpReload)) { | 213 if (command_line->HasSwitch(switches::kLocalNtpReload)) { |
| 214 if (stripped_path == "local-ntp.html" || stripped_path == "local-ntp.js" || | 214 if (stripped_path == "local-ntp.html" || stripped_path == "local-ntp.js" || |
| 215 stripped_path == "local-ntp.css") { | 215 stripped_path == "local-ntp.css") { |
| 216 base::ReplaceChars(stripped_path, "-", "_", &stripped_path); | 216 base::ReplaceChars(stripped_path, "-", "_", &stripped_path); |
| 217 local_ntp::SendLocalFileResource(stripped_path, callback); | 217 local_ntp::SendLocalFileResource(stripped_path, callback); |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 #endif // !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS) | 221 #endif |
| 222 | 222 |
| 223 float scale = 1.0f; | 223 float scale = 1.0f; |
| 224 std::string filename; | 224 std::string filename; |
| 225 webui::ParsePathAndScale( | 225 webui::ParsePathAndScale( |
| 226 GURL(GetLocalNtpPath() + stripped_path), &filename, &scale); | 226 GURL(GetLocalNtpPath() + stripped_path), &filename, &scale); |
| 227 ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor(scale); | 227 ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor(scale); |
| 228 | 228 |
| 229 for (size_t i = 0; i < arraysize(kResources); ++i) { | 229 for (size_t i = 0; i < arraysize(kResources); ++i) { |
| 230 if (filename == kResources[i].filename) { | 230 if (filename == kResources[i].filename) { |
| 231 scoped_refptr<base::RefCountedStaticMemory> response( | 231 scoped_refptr<base::RefCountedStaticMemory> response( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 return false; | 265 return false; |
| 266 } | 266 } |
| 267 | 267 |
| 268 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { | 268 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { |
| 269 // Allow embedding of most visited iframes. | 269 // Allow embedding of most visited iframes. |
| 270 return base::StringPrintf("frame-src %s;", | 270 return base::StringPrintf("frame-src %s;", |
| 271 chrome::kChromeSearchMostVisitedUrl); | 271 chrome::kChromeSearchMostVisitedUrl); |
| 272 } | 272 } |
| OLD | NEW |