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 #ifndef CHROME_BROWSER_SEARCH_IFRAME_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_IFRAME_SOURCE_H_ |
6 #define CHROME_BROWSER_SEARCH_IFRAME_SOURCE_H_ | 6 #define CHROME_BROWSER_SEARCH_IFRAME_SOURCE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "content/public/browser/url_data_source.h" | 10 #include "content/public/browser/url_data_source.h" |
11 | 11 |
12 // Base class for URL data sources for chrome-search:// iframed content. | 12 // Base class for URL data sources for chrome-search:// iframed content. |
13 class IframeSource : public content::URLDataSource { | 13 class IframeSource : public content::URLDataSource { |
14 public: | 14 public: |
15 IframeSource(); | 15 IframeSource(); |
16 ~IframeSource() override; | 16 ~IframeSource() override; |
17 | 17 |
18 protected: | 18 protected: |
19 // Overridden from content::URLDataSource: | 19 // Overridden from content::URLDataSource: |
20 std::string GetMimeType(const std::string& path_and_query) const override; | 20 std::string GetMimeType(const std::string& path_and_query) const override; |
21 bool AllowCaching() const override; | 21 bool AllowCaching() const override; |
22 bool ShouldDenyXFrameOptions() const override; | 22 bool ShouldDenyXFrameOptions() const override; |
23 bool ShouldServiceRequest(const net::URLRequest* request) const override; | 23 bool ShouldServiceRequest(const GURL& url, |
| 24 content::ResourceContext* resource_context, |
| 25 int render_process_id) const override; |
24 | 26 |
25 // Returns whether this source should serve data for a particular path. | 27 // Returns whether this source should serve data for a particular path. |
26 virtual bool ServesPath(const std::string& path) const = 0; | 28 virtual bool ServesPath(const std::string& path) const = 0; |
27 | 29 |
28 // Sends unmodified resource bytes. | 30 // Sends unmodified resource bytes. |
29 void SendResource( | 31 void SendResource( |
30 int resource_id, | 32 int resource_id, |
31 const content::URLDataSource::GotDataCallback& callback); | 33 const content::URLDataSource::GotDataCallback& callback); |
32 | 34 |
33 // Sends Javascript with an expected postMessage origin interpolated. | 35 // Sends Javascript with an expected postMessage origin interpolated. |
34 void SendJSWithOrigin( | 36 void SendJSWithOrigin( |
35 int resource_id, | 37 int resource_id, |
36 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | 38 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
37 const content::URLDataSource::GotDataCallback& callback); | 39 const content::URLDataSource::GotDataCallback& callback); |
38 | 40 |
39 // This is exposed for testing and should not be overridden. | 41 // This is exposed for testing and should not be overridden. |
40 // Sets |origin| to the URL of the WebContents identified by |wc_getter|. | 42 // Sets |origin| to the URL of the WebContents identified by |wc_getter|. |
41 // Returns true if successful and false if not, for example if the WebContents | 43 // Returns true if successful and false if not, for example if the WebContents |
42 // does not exist | 44 // does not exist |
43 virtual bool GetOrigin( | 45 virtual bool GetOrigin( |
44 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | 46 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
45 std::string* origin) const; | 47 std::string* origin) const; |
46 | 48 |
47 DISALLOW_COPY_AND_ASSIGN(IframeSource); | 49 DISALLOW_COPY_AND_ASSIGN(IframeSource); |
48 }; | 50 }; |
49 | 51 |
50 #endif // CHROME_BROWSER_SEARCH_IFRAME_SOURCE_H_ | 52 #endif // CHROME_BROWSER_SEARCH_IFRAME_SOURCE_H_ |
OLD | NEW |