| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/public/browser/resource_request_info.h" | 14 #include "content/public/browser/resource_request_info.h" |
| 15 | 15 |
| 16 class GURL; |
| 16 namespace base { | 17 namespace base { |
| 17 class RefCountedMemory; | 18 class RefCountedMemory; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace net { | |
| 21 class URLRequest; | |
| 22 } | |
| 23 | |
| 24 namespace content { | 21 namespace content { |
| 25 class BrowserContext; | 22 class BrowserContext; |
| 23 class ResourceContext; |
| 26 | 24 |
| 27 // A URLDataSource is an object that can answer requests for WebUI data | 25 // A URLDataSource is an object that can answer requests for WebUI data |
| 28 // asynchronously. An implementation of URLDataSource should handle calls to | 26 // asynchronously. An implementation of URLDataSource should handle calls to |
| 29 // StartDataRequest() by starting its (implementation-specific) asynchronous | 27 // StartDataRequest() by starting its (implementation-specific) asynchronous |
| 30 // request for the data, then running the callback given in that method to | 28 // request for the data, then running the callback given in that method to |
| 31 // notify. | 29 // notify. |
| 32 class CONTENT_EXPORT URLDataSource { | 30 class CONTENT_EXPORT URLDataSource { |
| 33 public: | 31 public: |
| 34 // Adds a URL data source to |browser_context|. | 32 // Adds a URL data source to |browser_context|. |
| 35 static void Add(BrowserContext* browser_context, URLDataSource* source); | 33 static void Add(BrowserContext* browser_context, URLDataSource* source); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 121 |
| 124 // By default, the "X-Frame-Options: DENY" header is sent. To stop this from | 122 // By default, the "X-Frame-Options: DENY" header is sent. To stop this from |
| 125 // happening, return false. It is OK to return false as needed. | 123 // happening, return false. It is OK to return false as needed. |
| 126 virtual bool ShouldDenyXFrameOptions() const; | 124 virtual bool ShouldDenyXFrameOptions() const; |
| 127 | 125 |
| 128 // By default, only chrome: and chrome-devtools: requests are allowed. | 126 // By default, only chrome: and chrome-devtools: requests are allowed. |
| 129 // Override in specific WebUI data sources to enable for additional schemes or | 127 // Override in specific WebUI data sources to enable for additional schemes or |
| 130 // to implement fancier access control. Typically used in concert with | 128 // to implement fancier access control. Typically used in concert with |
| 131 // ContentBrowserClient::GetAdditionalWebUISchemes() to permit additional | 129 // ContentBrowserClient::GetAdditionalWebUISchemes() to permit additional |
| 132 // WebUI scheme support for an embedder. | 130 // WebUI scheme support for an embedder. |
| 133 virtual bool ShouldServiceRequest(const net::URLRequest* request) const; | 131 virtual bool ShouldServiceRequest(const GURL& url, |
| 132 ResourceContext* resource_context, |
| 133 int render_process_id) const; |
| 134 | 134 |
| 135 // By default, Content-Type: header is not sent along with the response. | 135 // By default, Content-Type: header is not sent along with the response. |
| 136 // To start sending mime type returned by GetMimeType in HTTP headers, | 136 // To start sending mime type returned by GetMimeType in HTTP headers, |
| 137 // return true. It is useful when tunneling response served from this data | 137 // return true. It is useful when tunneling response served from this data |
| 138 // source programmatically. Or when AppCache is enabled for this source as it | 138 // source programmatically. Or when AppCache is enabled for this source as it |
| 139 // is for chrome-devtools. | 139 // is for chrome-devtools. |
| 140 virtual bool ShouldServeMimeTypeAsContentTypeHeader() const; | 140 virtual bool ShouldServeMimeTypeAsContentTypeHeader() const; |
| 141 | 141 |
| 142 // This method is called when the request contains "Origin:" header. The value | 142 // This method is called when the request contains "Origin:" header. The value |
| 143 // of the header is passed in |origin| parameter. If the returned value is not | 143 // of the header is passed in |origin| parameter. If the returned value is not |
| 144 // empty, it is used as a value for "Access-Control-Allow-Origin:" response | 144 // empty, it is used as a value for "Access-Control-Allow-Origin:" response |
| 145 // header, otherwise the header is not set. This method should return either | 145 // header, otherwise the header is not set. This method should return either |
| 146 // |origin|, or "*", or "none", or empty string. | 146 // |origin|, or "*", or "none", or empty string. |
| 147 // Default implementation returns an empty string. | 147 // Default implementation returns an empty string. |
| 148 virtual std::string GetAccessControlAllowOriginForOrigin( | 148 virtual std::string GetAccessControlAllowOriginForOrigin( |
| 149 const std::string& origin) const; | 149 const std::string& origin) const; |
| 150 | 150 |
| 151 // Called to inform the source that StartDataRequest() will be called soon. | |
| 152 // Gives the source an opportunity to rewrite |path| to incorporate extra | |
| 153 // information from the URLRequest prior to serving. | |
| 154 virtual void WillServiceRequest( | |
| 155 const net::URLRequest* request, | |
| 156 std::string* path) const {} | |
| 157 | |
| 158 // Whether |path| is gzipped (and should be transmitted gzipped). | 151 // Whether |path| is gzipped (and should be transmitted gzipped). |
| 159 virtual bool IsGzipped(const std::string& path) const; | 152 virtual bool IsGzipped(const std::string& path) const; |
| 160 }; | 153 }; |
| 161 | 154 |
| 162 } // namespace content | 155 } // namespace content |
| 163 | 156 |
| 164 #endif // CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 157 #endif // CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
| OLD | NEW |