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

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

Issue 1000773002: Fixes sending the wrong mime-type for scaled resources (.png@2x) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « no previous file | 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 "base/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 kResources[i].identifier, scale_factor)); 177 kResources[i].identifier, scale_factor));
178 callback.Run(response.get()); 178 callback.Run(response.get());
179 return; 179 return;
180 } 180 }
181 } 181 }
182 callback.Run(NULL); 182 callback.Run(NULL);
183 } 183 }
184 184
185 std::string LocalNtpSource::GetMimeType( 185 std::string LocalNtpSource::GetMimeType(
186 const std::string& path) const { 186 const std::string& path) const {
187 const std::string stripped_path = StripParameters(path); 187 const std::string& stripped_path = StripParameters(path);
188 std::string filename;
189 webui::ParsePathAndScale(GURL(GetLocalNtpPath() + stripped_path), &filename,
190 NULL);
188 for (size_t i = 0; i < arraysize(kResources); ++i) { 191 for (size_t i = 0; i < arraysize(kResources); ++i) {
189 if (stripped_path == kResources[i].filename) 192 if (filename == kResources[i].filename)
190 return kResources[i].mime_type; 193 return kResources[i].mime_type;
191 } 194 }
192 return std::string(); 195 return std::string();
193 } 196 }
194 197
195 bool LocalNtpSource::ShouldServiceRequest( 198 bool LocalNtpSource::ShouldServiceRequest(
196 const net::URLRequest* request) const { 199 const net::URLRequest* request) const {
197 DCHECK(request->url().host() == chrome::kChromeSearchLocalNtpHost); 200 DCHECK(request->url().host() == chrome::kChromeSearchLocalNtpHost);
198 if (!InstantIOContext::ShouldServiceRequest(request)) 201 if (!InstantIOContext::ShouldServiceRequest(request))
199 return false; 202 return false;
200 203
201 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { 204 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) {
202 std::string filename; 205 std::string filename;
203 webui::ParsePathAndScale(request->url(), &filename, NULL); 206 webui::ParsePathAndScale(request->url(), &filename, NULL);
204 for (size_t i = 0; i < arraysize(kResources); ++i) { 207 for (size_t i = 0; i < arraysize(kResources); ++i) {
205 if (filename == kResources[i].filename) 208 if (filename == kResources[i].filename)
206 return true; 209 return true;
207 } 210 }
208 } 211 }
209 return false; 212 return false;
210 } 213 }
211 214
212 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { 215 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const {
213 // Allow embedding of most visited iframes. 216 // Allow embedding of most visited iframes.
214 return base::StringPrintf("frame-src %s;", 217 return base::StringPrintf("frame-src %s;",
215 chrome::kChromeSearchMostVisitedUrl); 218 chrome::kChromeSearchMostVisitedUrl);
216 } 219 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698