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_WEB_UI_DATA_SOURCE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class DictionaryValue; | 13 class DictionaryValue; |
14 class RefCountedMemory; | 14 class RefCountedMemory; |
15 } | 15 } |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class BrowserContext; | 18 class BrowserContext; |
19 | 19 |
20 // A data source that can help with implementing the common operations needed by | 20 // A data source that can help with implementing the common operations needed by |
21 // WebUI pages. | 21 // WebUI pages. |
22 class WebUIDataSource { | 22 class WebUIDataSource { |
23 public: | 23 public: |
24 virtual ~WebUIDataSource() {} | 24 virtual ~WebUIDataSource() {} |
25 | 25 |
26 CONTENT_EXPORT static WebUIDataSource* Create(const std::string& source_name); | 26 CONTENT_EXPORT static WebUIDataSource* Create(const std::string& source_name); |
27 | 27 |
| 28 // Adds the necessary resources for mojo bindings returning the |
| 29 // WebUIDataSource that handles the resources. Callers do not own the return |
| 30 // value. |
| 31 CONTENT_EXPORT static WebUIDataSource* AddMojoDataSource( |
| 32 BrowserContext* browser_context); |
| 33 |
28 // Adds a WebUI data source to |browser_context|. | 34 // Adds a WebUI data source to |browser_context|. |
29 CONTENT_EXPORT static void Add(BrowserContext* browser_context, | 35 CONTENT_EXPORT static void Add(BrowserContext* browser_context, |
30 WebUIDataSource* source); | 36 WebUIDataSource* source); |
31 | 37 |
32 // Adds a string keyed to its name to our dictionary. | 38 // Adds a string keyed to its name to our dictionary. |
33 virtual void AddString(const std::string& name, | 39 virtual void AddString(const std::string& name, |
34 const base::string16& value) = 0; | 40 const base::string16& value) = 0; |
35 | 41 |
36 // Adds a string keyed to its name to our dictionary. | 42 // Adds a string keyed to its name to our dictionary. |
37 virtual void AddString(const std::string& name, const std::string& value) = 0; | 43 virtual void AddString(const std::string& name, const std::string& value) = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
64 // Used by SetRequestFilter. The string parameter is the path of the request. | 70 // Used by SetRequestFilter. The string parameter is the path of the request. |
65 // If the callee doesn't want to handle the data, false is returned. Otherwise | 71 // If the callee doesn't want to handle the data, false is returned. Otherwise |
66 // true is returned and the GotDataCallback parameter is called either then or | 72 // true is returned and the GotDataCallback parameter is called either then or |
67 // asynchronously with the response. | 73 // asynchronously with the response. |
68 typedef base::Callback<bool(const std::string&, const GotDataCallback&)> | 74 typedef base::Callback<bool(const std::string&, const GotDataCallback&)> |
69 HandleRequestCallback; | 75 HandleRequestCallback; |
70 | 76 |
71 // Allows a caller to add a filter for URL requests. | 77 // Allows a caller to add a filter for URL requests. |
72 virtual void SetRequestFilter(const HandleRequestCallback& callback) = 0; | 78 virtual void SetRequestFilter(const HandleRequestCallback& callback) = 0; |
73 | 79 |
74 // Adds the necessary resources for mojo bindings. | |
75 virtual void AddMojoResources() = 0; | |
76 | |
77 // The following map to methods on URLDataSource. See the documentation there. | 80 // The following map to methods on URLDataSource. See the documentation there. |
78 // NOTE: it's not acceptable to call DisableContentSecurityPolicy for new | 81 // NOTE: it's not acceptable to call DisableContentSecurityPolicy for new |
79 // pages, see URLDataSource::ShouldAddContentSecurityPolicy and talk to | 82 // pages, see URLDataSource::ShouldAddContentSecurityPolicy and talk to |
80 // tsepez. | 83 // tsepez. |
81 | 84 |
82 // Currently only used by embedders for WebUIs with multiple instances. | 85 // Currently only used by embedders for WebUIs with multiple instances. |
83 virtual void DisableReplaceExistingSource() = 0; | 86 virtual void DisableReplaceExistingSource() = 0; |
84 virtual void DisableContentSecurityPolicy() = 0; | 87 virtual void DisableContentSecurityPolicy() = 0; |
85 virtual void OverrideContentSecurityPolicyObjectSrc( | 88 virtual void OverrideContentSecurityPolicyObjectSrc( |
86 const std::string& data) = 0; | 89 const std::string& data) = 0; |
87 virtual void OverrideContentSecurityPolicyFrameSrc( | 90 virtual void OverrideContentSecurityPolicyFrameSrc( |
88 const std::string& data) = 0; | 91 const std::string& data) = 0; |
89 virtual void DisableDenyXFrameOptions() = 0; | 92 virtual void DisableDenyXFrameOptions() = 0; |
90 }; | 93 }; |
91 | 94 |
92 } // namespace content | 95 } // namespace content |
93 | 96 |
94 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ | 97 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ |
OLD | NEW |