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

Side by Side Diff: net/base/mime_util.cc

Issue 42013: Slight code change to make some global variables const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « net/base/mime_sniffer.cc ('k') | net/base/net_util.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <string> 5 #include <string>
6 6
7 #include "net/base/mime_util.h" 7 #include "net/base/mime_util.h"
8 #include "net/base/platform_mime_util.h" 8 #include "net/base/platform_mime_util.h"
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 bool MimeUtil::GetMimeTypeFromFile(const FilePath& file_path, 148 bool MimeUtil::GetMimeTypeFromFile(const FilePath& file_path,
149 string* result) const { 149 string* result) const {
150 FilePath::StringType file_name_str = file_path.Extension(); 150 FilePath::StringType file_name_str = file_path.Extension();
151 if (file_name_str.empty()) 151 if (file_name_str.empty())
152 return false; 152 return false;
153 return GetMimeTypeFromExtension(file_name_str.substr(1), result); 153 return GetMimeTypeFromExtension(file_name_str.substr(1), result);
154 } 154 }
155 155
156 // From WebKit's WebCore/platform/MIMETypeRegistry.cpp: 156 // From WebKit's WebCore/platform/MIMETypeRegistry.cpp:
157 157
158 static const char* supported_image_types[] = { 158 static const char* const supported_image_types[] = {
159 "image/jpeg", 159 "image/jpeg",
160 "image/jpg", 160 "image/jpg",
161 "image/png", 161 "image/png",
162 "image/gif", 162 "image/gif",
163 "image/bmp", 163 "image/bmp",
164 "image/x-icon", // ico 164 "image/x-icon", // ico
165 "image/x-xbitmap" // xbm 165 "image/x-xbitmap" // xbm
166 }; 166 };
167 167
168 // Note: does not include javascript types list (see supported_javascript_types) 168 // Note: does not include javascript types list (see supported_javascript_types)
169 static const char* supported_non_image_types[] = { 169 static const char* const supported_non_image_types[] = {
170 "text/html", 170 "text/html",
171 "text/xml", 171 "text/xml",
172 "text/xsl", 172 "text/xsl",
173 "text/plain", 173 "text/plain",
174 "text/", 174 "text/",
175 "image/svg+xml", // SVG is text-based XML, even though it has an image/ type 175 "image/svg+xml", // SVG is text-based XML, even though it has an image/ type
176 "application/xml", 176 "application/xml",
177 "application/xhtml+xml", 177 "application/xhtml+xml",
178 "application/rss+xml", 178 "application/rss+xml",
179 "application/atom+xml", 179 "application/atom+xml",
180 "multipart/x-mixed-replace" 180 "multipart/x-mixed-replace"
181 }; 181 };
182 182
183 // Mozilla 1.8 and WinIE 7 both accept text/javascript and text/ecmascript. 183 // Mozilla 1.8 and WinIE 7 both accept text/javascript and text/ecmascript.
184 // Mozilla 1.8 accepts application/javascript, application/ecmascript, and appl ication/x-javascript, but WinIE 7 doesn't. 184 // Mozilla 1.8 accepts application/javascript, application/ecmascript, and
185 // WinIE 7 accepts text/javascript1.1 - text/javascript1.3, text/jscript, and t ext/livescript, but Mozilla 1.8 doesn't. 185 // application/x-javascript, but WinIE 7 doesn't.
186 // WinIE 7 accepts text/javascript1.1 - text/javascript1.3, text/jscript, and
187 // text/livescript, but Mozilla 1.8 doesn't.
186 // Mozilla 1.8 allows leading and trailing whitespace, but WinIE 7 doesn't. 188 // Mozilla 1.8 allows leading and trailing whitespace, but WinIE 7 doesn't.
187 // Mozilla 1.8 and WinIE 7 both accept the empty string, but neither accept a w hitespace-only string. 189 // Mozilla 1.8 and WinIE 7 both accept the empty string, but neither accept a
188 // We want to accept all the values that either of these browsers accept, but n ot other values. 190 // whitespace-only string.
189 static const char* supported_javascript_types[] = { 191 // We want to accept all the values that either of these browsers accept, but
192 // not other values.
193 static const char* const supported_javascript_types[] = {
190 "text/javascript", 194 "text/javascript",
191 "text/ecmascript", 195 "text/ecmascript",
192 "application/javascript", 196 "application/javascript",
193 "application/ecmascript", 197 "application/ecmascript",
194 "application/x-javascript", 198 "application/x-javascript",
195 "text/javascript1.1", 199 "text/javascript1.1",
196 "text/javascript1.2", 200 "text/javascript1.2",
197 "text/javascript1.3", 201 "text/javascript1.3",
198 "text/jscript", 202 "text/jscript",
199 "text/livescript" 203 "text/livescript"
200 }; 204 };
201 205
202 static const char* view_source_types[] = { 206 static const char* const view_source_types[] = {
203 "text/xml", 207 "text/xml",
204 "text/xsl", 208 "text/xsl",
205 "application/xml", 209 "application/xml",
206 "application/rss+xml", 210 "application/rss+xml",
207 "application/atom+xml", 211 "application/atom+xml",
208 "image/svg+xml" 212 "image/svg+xml"
209 }; 213 };
210 214
211 void MimeUtil::InitializeMimeTypeMaps() { 215 void MimeUtil::InitializeMimeTypeMaps() {
212 for (size_t i = 0; i < arraysize(supported_image_types); ++i) 216 for (size_t i = 0; i < arraysize(supported_image_types); ++i)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 return GetMimeUtil()->IsSupportedMimeType(mime_type); 331 return GetMimeUtil()->IsSupportedMimeType(mime_type);
328 } 332 }
329 333
330 bool MatchesMimeType(const std::string &mime_type_pattern, 334 bool MatchesMimeType(const std::string &mime_type_pattern,
331 const std::string &mime_type) { 335 const std::string &mime_type) {
332 return GetMimeUtil()->MatchesMimeType(mime_type_pattern, mime_type); 336 return GetMimeUtil()->MatchesMimeType(mime_type_pattern, mime_type);
333 } 337 }
334 338
335 } // namespace net 339 } // namespace net
336 340
OLDNEW
« no previous file with comments | « net/base/mime_sniffer.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698