| 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 23 matching lines...) Expand all Loading... |
| 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 { | 39 bool IframeSource::AllowCaching() const { |
| 40 return false; | 40 return false; |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool IframeSource::ShouldServiceRequest( | 43 bool IframeSource::ShouldServiceRequest( |
| 44 const net::URLRequest* request) const { | 44 const GURL& url, |
| 45 const std::string& path = request->url().path(); | 45 content::ResourceContext* resource_context, |
| 46 return InstantIOContext::ShouldServiceRequest(request) && | 46 int render_process_id) const { |
| 47 request->url().SchemeIs(chrome::kChromeSearchScheme) && | 47 const std::string& path = url.path(); |
| 48 request->url().host_piece() == GetSource() && ServesPath(path); | 48 return InstantIOContext::ShouldServiceRequest(url, resource_context, |
| 49 render_process_id) && |
| 50 url.SchemeIs(chrome::kChromeSearchScheme) && |
| 51 url.host_piece() == GetSource() && ServesPath(path); |
| 49 } | 52 } |
| 50 | 53 |
| 51 bool IframeSource::ShouldDenyXFrameOptions() const { | 54 bool IframeSource::ShouldDenyXFrameOptions() const { |
| 52 return false; | 55 return false; |
| 53 } | 56 } |
| 54 | 57 |
| 55 bool IframeSource::GetOrigin( | 58 bool IframeSource::GetOrigin( |
| 56 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | 59 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
| 57 std::string* origin) const { | 60 std::string* origin) const { |
| 58 if (wc_getter.is_null()) | 61 if (wc_getter.is_null()) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 88 callback.Run(NULL); | 91 callback.Run(NULL); |
| 89 return; | 92 return; |
| 90 } | 93 } |
| 91 | 94 |
| 92 base::StringPiece template_js = | 95 base::StringPiece template_js = |
| 93 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 96 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); |
| 94 std::string response(template_js.as_string()); | 97 std::string response(template_js.as_string()); |
| 95 base::ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin); | 98 base::ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin); |
| 96 callback.Run(base::RefCountedString::TakeString(&response)); | 99 callback.Run(base::RefCountedString::TakeString(&response)); |
| 97 } | 100 } |
| OLD | NEW |