| 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/iframe_source.h" | 5 #include "chrome/browser/search/iframe_source.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/search/instant_io_context.h" | 10 #include "chrome/browser/search/instant_io_context.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 return "application/javascript"; | 29 return "application/javascript"; |
| 30 if (base::EndsWith(path, ".png", base::CompareCase::INSENSITIVE_ASCII)) | 30 if (base::EndsWith(path, ".png", base::CompareCase::INSENSITIVE_ASCII)) |
| 31 return "image/png"; | 31 return "image/png"; |
| 32 if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII)) | 32 if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII)) |
| 33 return "text/css"; | 33 return "text/css"; |
| 34 if (base::EndsWith(path, ".html", base::CompareCase::INSENSITIVE_ASCII)) | 34 if (base::EndsWith(path, ".html", base::CompareCase::INSENSITIVE_ASCII)) |
| 35 return "text/html"; | 35 return "text/html"; |
| 36 return std::string(); | 36 return std::string(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool IframeSource::AllowCaching() const { |
| 40 return false; |
| 41 } |
| 42 |
| 39 bool IframeSource::ShouldServiceRequest( | 43 bool IframeSource::ShouldServiceRequest( |
| 40 const net::URLRequest* request) const { | 44 const net::URLRequest* request) const { |
| 41 const std::string& path = request->url().path(); | 45 const std::string& path = request->url().path(); |
| 42 return InstantIOContext::ShouldServiceRequest(request) && | 46 return InstantIOContext::ShouldServiceRequest(request) && |
| 43 request->url().SchemeIs(chrome::kChromeSearchScheme) && | 47 request->url().SchemeIs(chrome::kChromeSearchScheme) && |
| 44 request->url().host_piece() == GetSource() && ServesPath(path); | 48 request->url().host_piece() == GetSource() && ServesPath(path); |
| 45 } | 49 } |
| 46 | 50 |
| 47 bool IframeSource::ShouldDenyXFrameOptions() const { | 51 bool IframeSource::ShouldDenyXFrameOptions() const { |
| 48 return false; | 52 return false; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 callback.Run(NULL); | 88 callback.Run(NULL); |
| 85 return; | 89 return; |
| 86 } | 90 } |
| 87 | 91 |
| 88 base::StringPiece template_js = | 92 base::StringPiece template_js = |
| 89 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 93 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); |
| 90 std::string response(template_js.as_string()); | 94 std::string response(template_js.as_string()); |
| 91 base::ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin); | 95 base::ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin); |
| 92 callback.Run(base::RefCountedString::TakeString(&response)); | 96 callback.Run(base::RefCountedString::TakeString(&response)); |
| 93 } | 97 } |
| OLD | NEW |