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