OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ | 5 #ifndef CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ | 6 #define CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 15 #include "content/browser/webui/url_data_manager.h" |
| 16 #include "content/common/content_export.h" |
16 #include "content/public/browser/url_data_source.h" | 17 #include "content/public/browser/url_data_source.h" |
17 #include "content/public/browser/web_ui_data_source.h" | 18 #include "content/public/browser/web_ui_data_source.h" |
18 | 19 |
19 // A data source that can help with implementing the common operations | 20 // A data source that can help with implementing the common operations |
20 // needed by the chrome WEBUI settings/history/downloads pages. | 21 // needed by the chrome WEBUI settings/history/downloads pages. |
21 // DO NOT DERIVE FROM THIS CLASS! http://crbug.com/169170 | 22 class CONTENT_EXPORT ChromeWebUIDataSource |
22 class ChromeWebUIDataSource : public URLDataSourceImpl, | 23 : public NON_EXPORTED_BASE(URLDataSourceImpl), |
23 public content::WebUIDataSource { | 24 public NON_EXPORTED_BASE(content::WebUIDataSource) { |
24 public: | 25 public: |
25 static content::WebUIDataSource* Create(const std::string& source_name); | 26 static content::WebUIDataSource* Create( |
| 27 const std::string& source_name); |
26 | 28 |
27 // content::WebUIDataSource implementation: | 29 // content::WebUIDataSource implementation: |
28 virtual void AddString(const std::string& name, | 30 virtual void AddString(const std::string& name, |
29 const string16& value) OVERRIDE; | 31 const string16& value) OVERRIDE; |
30 virtual void AddString(const std::string& name, | 32 virtual void AddString(const std::string& name, |
31 const std::string& value) OVERRIDE; | 33 const std::string& value) OVERRIDE; |
32 virtual void AddLocalizedString(const std::string& name, int ids) OVERRIDE; | 34 virtual void AddLocalizedString(const std::string& name, int ids) OVERRIDE; |
33 virtual void AddLocalizedStrings( | 35 virtual void AddLocalizedStrings( |
34 const DictionaryValue& localized_strings) OVERRIDE; | 36 const DictionaryValue& localized_strings) OVERRIDE; |
35 virtual void AddBoolean(const std::string& name, bool value) OVERRIDE; | 37 virtual void AddBoolean(const std::string& name, bool value) OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
54 void SendLocalizedStringsAsJSON( | 56 void SendLocalizedStringsAsJSON( |
55 const content::URLDataSource::GotDataCallback& callback); | 57 const content::URLDataSource::GotDataCallback& callback); |
56 | 58 |
57 // Completes a request by sending the file specified by |idr|. | 59 // Completes a request by sending the file specified by |idr|. |
58 void SendFromResourceBundle( | 60 void SendFromResourceBundle( |
59 const content::URLDataSource::GotDataCallback& callback, int idr); | 61 const content::URLDataSource::GotDataCallback& callback, int idr); |
60 | 62 |
61 private: | 63 private: |
62 class InternalDataSource; | 64 class InternalDataSource; |
63 friend class InternalDataSource; | 65 friend class InternalDataSource; |
64 friend class MockChromeWebUIDataSource; | 66 friend class ChromeWebUIDataSourceTest; |
65 | 67 |
66 explicit ChromeWebUIDataSource(const std::string& source_name); | 68 explicit ChromeWebUIDataSource(const std::string& source_name); |
67 | 69 |
68 // Methods that match content::URLDataSource which are called by | 70 // Methods that match content::URLDataSource which are called by |
69 // InternalDataSource. | 71 // InternalDataSource. |
70 std::string GetSource(); | 72 std::string GetSource(); |
71 std::string GetMimeType(const std::string& path) const; | 73 std::string GetMimeType(const std::string& path) const; |
72 void StartDataRequest( | 74 void StartDataRequest( |
73 const std::string& path, | 75 const std::string& path, |
74 bool is_incognito, | 76 bool is_incognito, |
(...skipping 12 matching lines...) Expand all Loading... |
87 bool add_csp_; | 89 bool add_csp_; |
88 bool object_src_set_; | 90 bool object_src_set_; |
89 std::string object_src_; | 91 std::string object_src_; |
90 bool frame_src_set_; | 92 bool frame_src_set_; |
91 std::string frame_src_; | 93 std::string frame_src_; |
92 bool deny_xframe_options_; | 94 bool deny_xframe_options_; |
93 | 95 |
94 DISALLOW_COPY_AND_ASSIGN(ChromeWebUIDataSource); | 96 DISALLOW_COPY_AND_ASSIGN(ChromeWebUIDataSource); |
95 }; | 97 }; |
96 | 98 |
97 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ | 99 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_H_ |
OLD | NEW |