OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 IOS_WEB_PUBLIC_WEB_UI_IOS_DATA_SOURCE_H_ | 5 #ifndef IOS_WEB_PUBLIC_WEB_UI_IOS_DATA_SOURCE_H_ |
6 #define IOS_WEB_PUBLIC_WEB_UI_IOS_DATA_SOURCE_H_ | 6 #define IOS_WEB_PUBLIC_WEB_UI_IOS_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 "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
11 | 11 |
12 namespace base { | |
13 class DictionaryValue; | |
14 } | |
15 | |
16 namespace web { | 12 namespace web { |
17 class BrowserState; | 13 class BrowserState; |
18 | 14 |
19 // A data source that can help with implementing the common operations needed by | 15 // A data source that can help with implementing the common operations needed by |
20 // WebUIIOS pages. | 16 // WebUIIOS pages. |
21 class WebUIIOSDataSource : public base::SupportsUserData { | 17 class WebUIIOSDataSource : public base::SupportsUserData { |
22 public: | 18 public: |
23 ~WebUIIOSDataSource() override {} | 19 ~WebUIIOSDataSource() override {} |
24 | 20 |
25 static WebUIIOSDataSource* Create(const std::string& source_name); | 21 static WebUIIOSDataSource* Create(const std::string& source_name); |
26 | 22 |
27 // Adds a WebUIIOS data source to |browser_state|. | 23 // Adds a WebUIIOS data source to |browser_state|. |
28 static void Add(BrowserState* browser_state, WebUIIOSDataSource* source); | 24 static void Add(BrowserState* browser_state, WebUIIOSDataSource* source); |
29 | 25 |
30 // Adds a string keyed to its name to our dictionary. | 26 // Adds a string keyed to its name to our dictionary. |
31 virtual void AddString(const std::string& name, | 27 virtual void AddString(const std::string& name, |
32 const base::string16& value) = 0; | 28 const base::string16& value) = 0; |
33 | 29 |
34 // Adds a string keyed to its name to our dictionary. | 30 // Adds a string keyed to its name to our dictionary. |
35 virtual void AddString(const std::string& name, const std::string& value) = 0; | 31 virtual void AddString(const std::string& name, const std::string& value) = 0; |
36 | 32 |
37 // Adds a localized string with resource |ids| keyed to its name to our | 33 // Adds a localized string with resource |ids| keyed to its name to our |
38 // dictionary. | 34 // dictionary. |
39 virtual void AddLocalizedString(const std::string& name, int ids) = 0; | 35 virtual void AddLocalizedString(const std::string& name, int ids) = 0; |
40 | 36 |
41 virtual void AddLocalizedStrings( | |
42 const base::DictionaryValue& localized_strings) = 0; | |
43 | |
44 // Adds a boolean keyed to its name to our dictionary. | 37 // Adds a boolean keyed to its name to our dictionary. |
45 virtual void AddBoolean(const std::string& name, bool value) = 0; | 38 virtual void AddBoolean(const std::string& name, bool value) = 0; |
46 | 39 |
47 // Sets the path which will return the JSON strings. | 40 // Sets the path which will return the JSON strings. |
48 virtual void SetJsonPath(const std::string& path) = 0; | 41 virtual void SetJsonPath(const std::string& path) = 0; |
49 | 42 |
50 // Adds a mapping between a path name and a resource to return. | 43 // Adds a mapping between a path name and a resource to return. |
51 virtual void AddResourcePath(const std::string& path, int resource_id) = 0; | 44 virtual void AddResourcePath(const std::string& path, int resource_id) = 0; |
52 | 45 |
53 // Sets the resource to returned when no other paths match. | 46 // Sets the resource to returned when no other paths match. |
54 virtual void SetDefaultResource(int resource_id) = 0; | 47 virtual void SetDefaultResource(int resource_id) = 0; |
55 | 48 |
56 // The following map to methods on URLDataSource. See the documentation there. | 49 // The following map to methods on URLDataSource. See the documentation there. |
57 virtual void DisableDenyXFrameOptions() = 0; | 50 virtual void DisableDenyXFrameOptions() = 0; |
58 }; | 51 }; |
59 | 52 |
60 } // namespace web | 53 } // namespace web |
61 | 54 |
62 #endif // IOS_WEB_PUBLIC_WEB_UI_IOS_DATA_SOURCE_H_ | 55 #endif // IOS_WEB_PUBLIC_WEB_UI_IOS_DATA_SOURCE_H_ |
OLD | NEW |