Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 std::string LocalNtpSource::GetMimeType( | 243 std::string LocalNtpSource::GetMimeType( |
| 244 const std::string& path) const { | 244 const std::string& path) const { |
| 245 const std::string stripped_path = StripParameters(path); | 245 const std::string stripped_path = StripParameters(path); |
| 246 for (size_t i = 0; i < arraysize(kResources); ++i) { | 246 for (size_t i = 0; i < arraysize(kResources); ++i) { |
| 247 if (stripped_path == kResources[i].filename) | 247 if (stripped_path == kResources[i].filename) |
| 248 return kResources[i].mime_type; | 248 return kResources[i].mime_type; |
| 249 } | 249 } |
| 250 return std::string(); | 250 return std::string(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 bool LocalNtpSource::AllowCaching() const { | |
| 254 return false; | |
|
Marc Treib
2016/11/29 14:52:22
Could you add a comment about why this is necessar
Takashi Toyoshima
2016/11/30 05:54:38
Done.
| |
| 255 } | |
| 256 | |
| 253 bool LocalNtpSource::ShouldServiceRequest( | 257 bool LocalNtpSource::ShouldServiceRequest( |
| 254 const net::URLRequest* request) const { | 258 const net::URLRequest* request) const { |
| 255 DCHECK(request->url().host_piece() == chrome::kChromeSearchLocalNtpHost); | 259 DCHECK(request->url().host_piece() == chrome::kChromeSearchLocalNtpHost); |
| 256 if (!InstantIOContext::ShouldServiceRequest(request)) | 260 if (!InstantIOContext::ShouldServiceRequest(request)) |
| 257 return false; | 261 return false; |
| 258 | 262 |
| 259 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { | 263 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { |
| 260 std::string filename; | 264 std::string filename; |
| 261 webui::ParsePathAndScale(request->url(), &filename, NULL); | 265 webui::ParsePathAndScale(request->url(), &filename, NULL); |
| 262 for (size_t i = 0; i < arraysize(kResources); ++i) { | 266 for (size_t i = 0; i < arraysize(kResources); ++i) { |
| 263 if (filename == kResources[i].filename) | 267 if (filename == kResources[i].filename) |
| 264 return true; | 268 return true; |
| 265 } | 269 } |
| 266 } | 270 } |
| 267 return false; | 271 return false; |
| 268 } | 272 } |
| 269 | 273 |
| 270 std::string LocalNtpSource::GetContentSecurityPolicyChildSrc() const { | 274 std::string LocalNtpSource::GetContentSecurityPolicyChildSrc() const { |
| 271 // Allow embedding of most visited iframes. | 275 // Allow embedding of most visited iframes. |
| 272 return base::StringPrintf("child-src %s;", | 276 return base::StringPrintf("child-src %s;", |
| 273 chrome::kChromeSearchMostVisitedUrl); | 277 chrome::kChromeSearchMostVisitedUrl); |
| 274 } | 278 } |
| OLD | NEW |