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

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

Issue 2533203002: New Tab Page: chrome-search://local-ntp/ files should not be cachable (Closed)
Patch Set: comment Created 4 years 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/search/local_ntp_source.h ('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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Some resources served by LocalNtpSource, i.e. config.js, are dynamically
255 // generated and could differ on each access. To avoid using old cached
256 // content on reload, disallow caching here. Otherwise, it fails to reflect
257 // newly revised user configurations in the page.
258 return false;
259 }
260
253 bool LocalNtpSource::ShouldServiceRequest( 261 bool LocalNtpSource::ShouldServiceRequest(
254 const net::URLRequest* request) const { 262 const net::URLRequest* request) const {
255 DCHECK(request->url().host_piece() == chrome::kChromeSearchLocalNtpHost); 263 DCHECK(request->url().host_piece() == chrome::kChromeSearchLocalNtpHost);
256 if (!InstantIOContext::ShouldServiceRequest(request)) 264 if (!InstantIOContext::ShouldServiceRequest(request))
257 return false; 265 return false;
258 266
259 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { 267 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) {
260 std::string filename; 268 std::string filename;
261 webui::ParsePathAndScale(request->url(), &filename, NULL); 269 webui::ParsePathAndScale(request->url(), &filename, NULL);
262 for (size_t i = 0; i < arraysize(kResources); ++i) { 270 for (size_t i = 0; i < arraysize(kResources); ++i) {
263 if (filename == kResources[i].filename) 271 if (filename == kResources[i].filename)
264 return true; 272 return true;
265 } 273 }
266 } 274 }
267 return false; 275 return false;
268 } 276 }
269 277
270 std::string LocalNtpSource::GetContentSecurityPolicyChildSrc() const { 278 std::string LocalNtpSource::GetContentSecurityPolicyChildSrc() const {
271 // Allow embedding of most visited iframes. 279 // Allow embedding of most visited iframes.
272 return base::StringPrintf("child-src %s;", 280 return base::StringPrintf("child-src %s;",
273 chrome::kChromeSearchMostVisitedUrl); 281 chrome::kChromeSearchMostVisitedUrl);
274 } 282 }
OLDNEW
« no previous file with comments | « chrome/browser/search/local_ntp_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698