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

Side by Side Diff: content/browser/webui/shared_resources_data_source.cc

Issue 2774263002: Specify AllowCaching = false for dynamically-generated contents (Closed)
Patch Set: typo Created 3 years, 9 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 | « content/browser/webui/shared_resources_data_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/webui/shared_resources_data_source.h" 5 #include "content/browser/webui/shared_resources_data_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } else if (idr == IDR_WEBUI_CSS_TEXT_DEFAULTS_MD) { 102 } else if (idr == IDR_WEBUI_CSS_TEXT_DEFAULTS_MD) {
103 std::string css = webui::GetWebUiCssTextDefaultsMd(); 103 std::string css = webui::GetWebUiCssTextDefaultsMd();
104 bytes = base::RefCountedString::TakeString(&css); 104 bytes = base::RefCountedString::TakeString(&css);
105 } else { 105 } else {
106 bytes = GetContentClient()->GetDataResourceBytes(idr); 106 bytes = GetContentClient()->GetDataResourceBytes(idr);
107 } 107 }
108 108
109 callback.Run(bytes.get()); 109 callback.Run(bytes.get());
110 } 110 }
111 111
112 bool SharedResourcesDataSource::AllowCaching() const {
113 // Should not be cached to reflect dynamically-generated contents that may
114 // depend on the current locale.
115 return false;
116 }
117
112 std::string SharedResourcesDataSource::GetMimeType( 118 std::string SharedResourcesDataSource::GetMimeType(
113 const std::string& path) const { 119 const std::string& path) const {
114 if (path.empty()) 120 if (path.empty())
115 return "text/html"; 121 return "text/html";
116 122
117 #if defined(OS_WIN) 123 #if defined(OS_WIN)
118 base::FilePath file(base::UTF8ToWide(path)); 124 base::FilePath file(base::UTF8ToWide(path));
119 std::string extension = base::WideToUTF8(file.FinalExtension()); 125 std::string extension = base::WideToUTF8(file.FinalExtension());
120 #else 126 #else
121 base::FilePath file(path); 127 base::FilePath file(path);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 std::string allowed_origin_prefix = kChromeUIScheme; 180 std::string allowed_origin_prefix = kChromeUIScheme;
175 allowed_origin_prefix += "://"; 181 allowed_origin_prefix += "://";
176 if (!base::StartsWith(origin, allowed_origin_prefix, 182 if (!base::StartsWith(origin, allowed_origin_prefix,
177 base::CompareCase::SENSITIVE)) { 183 base::CompareCase::SENSITIVE)) {
178 return "null"; 184 return "null";
179 } 185 }
180 return origin; 186 return origin;
181 } 187 }
182 188
183 } // namespace content 189 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webui/shared_resources_data_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698