| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (path == kHtmlFilename) | 67 if (path == kHtmlFilename) |
| 68 return "text/html"; | 68 return "text/html"; |
| 69 if (path == kJSFilename) | 69 if (path == kJSFilename) |
| 70 return "application/javascript"; | 70 return "application/javascript"; |
| 71 if (path == kCssFilename) | 71 if (path == kCssFilename) |
| 72 return "text/css"; | 72 return "text/css"; |
| 73 if (path == kCloseBarFilename || path == kCloseBarHoverFilename || | 73 if (path == kCloseBarFilename || path == kCloseBarHoverFilename || |
| 74 path == kCloseBarActiveFilename) { | 74 path == kCloseBarActiveFilename) { |
| 75 return "image/png"; | 75 return "image/png"; |
| 76 } | 76 } |
| 77 return ""; | 77 return std::string(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool LocalNtpSource::ShouldServiceRequest( | 80 bool LocalNtpSource::ShouldServiceRequest( |
| 81 const net::URLRequest* request) const { | 81 const net::URLRequest* request) const { |
| 82 DCHECK(request->url().host() == chrome::kChromeSearchLocalNtpHost); | 82 DCHECK(request->url().host() == chrome::kChromeSearchLocalNtpHost); |
| 83 | 83 |
| 84 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { | 84 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { |
| 85 DCHECK(StartsWithASCII(request->url().path(), "/", true)); | 85 DCHECK(StartsWithASCII(request->url().path(), "/", true)); |
| 86 std::string filename = request->url().path().substr(1); | 86 std::string filename = request->url().path().substr(1); |
| 87 return filename == kHtmlFilename || filename == kJSFilename || | 87 return filename == kHtmlFilename || filename == kJSFilename || |
| 88 filename == kCssFilename || filename == kCloseBarFilename || | 88 filename == kCssFilename || filename == kCloseBarFilename || |
| 89 filename == kCloseBarHoverFilename || | 89 filename == kCloseBarHoverFilename || |
| 90 filename == kCloseBarActiveFilename; | 90 filename == kCloseBarActiveFilename; |
| 91 } | 91 } |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| OLD | NEW |