| 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 22 matching lines...) Expand all Loading... |
| 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::ShouldServiceRequest( | 39 bool IframeSource::ShouldServiceRequest( |
| 40 const net::URLRequest* request) const { | 40 const net::URLRequest* request) const { |
| 41 const std::string& path = request->url().path(); | 41 const std::string& path = request->url().path(); |
| 42 return InstantIOContext::ShouldServiceRequest(request) && | 42 return InstantIOContext::ShouldServiceRequest(request) && |
| 43 request->url().SchemeIs(chrome::kChromeSearchScheme) && | 43 request->url().SchemeIs(chrome::kChromeSearchScheme) && |
| 44 request->url().host() == GetSource() && | 44 request->url().host_piece() == GetSource() && ServesPath(path); |
| 45 ServesPath(path); | |
| 46 } | 45 } |
| 47 | 46 |
| 48 bool IframeSource::ShouldDenyXFrameOptions() const { | 47 bool IframeSource::ShouldDenyXFrameOptions() const { |
| 49 return false; | 48 return false; |
| 50 } | 49 } |
| 51 | 50 |
| 52 bool IframeSource::GetOrigin( | 51 bool IframeSource::GetOrigin( |
| 53 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | 52 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
| 54 std::string* origin) const { | 53 std::string* origin) const { |
| 55 if (wc_getter.is_null()) | 54 if (wc_getter.is_null()) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 85 callback.Run(NULL); | 84 callback.Run(NULL); |
| 86 return; | 85 return; |
| 87 } | 86 } |
| 88 | 87 |
| 89 base::StringPiece template_js = | 88 base::StringPiece template_js = |
| 90 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 89 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); |
| 91 std::string response(template_js.as_string()); | 90 std::string response(template_js.as_string()); |
| 92 base::ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin); | 91 base::ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin); |
| 93 callback.Run(base::RefCountedString::TakeString(&response)); | 92 callback.Run(base::RefCountedString::TakeString(&response)); |
| 94 } | 93 } |
| OLD | NEW |