Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: chrome/browser/ui/webui/chrome_web_ui_data_source.h

Issue 12049052: Move core url data manager classes to content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // temporary forwarding header
6 #define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ 6 #include "content/browser/webui/web_ui_data_source.h"
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "base/values.h"
15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
16 #include "content/public/browser/url_data_source.h"
17 #include "content/public/browser/web_ui_data_source.h"
18
19 // A data source that can help with implementing the common operations
20 // needed by the chrome WEBUI settings/history/downloads pages.
21 // DO NOT DERIVE FROM THIS CLASS! http://crbug.com/169170
22 class ChromeWebUIDataSource : public URLDataSourceImpl,
23 public content::WebUIDataSource {
24 public:
25 static content::WebUIDataSource* Create(const std::string& source_name);
26
27 // content::WebUIDataSource implementation:
28 virtual void AddString(const std::string& name,
29 const string16& value) OVERRIDE;
30 virtual void AddString(const std::string& name,
31 const std::string& value) OVERRIDE;
32 virtual void AddLocalizedString(const std::string& name, int ids) OVERRIDE;
33 virtual void AddLocalizedStrings(
34 const DictionaryValue& localized_strings) OVERRIDE;
35 virtual void AddBoolean(const std::string& name, bool value) OVERRIDE;
36 virtual void SetJsonPath(const std::string& path) OVERRIDE;
37 virtual void SetUseJsonJSFormatV2() OVERRIDE;
38 virtual void AddResourcePath(const std::string &path,
39 int resource_id) OVERRIDE;
40 virtual void SetDefaultResource(int resource_id) OVERRIDE;
41 virtual void SetRequestFilter(
42 const content::WebUIDataSource::HandleRequestCallback& callback) OVERRIDE;
43 virtual void DisableContentSecurityPolicy() OVERRIDE;
44 virtual void OverrideContentSecurityPolicyObjectSrc(
45 const std::string& data) OVERRIDE;
46 virtual void OverrideContentSecurityPolicyFrameSrc(
47 const std::string& data) OVERRIDE;
48 virtual void DisableDenyXFrameOptions() OVERRIDE;
49
50 protected:
51 virtual ~ChromeWebUIDataSource();
52
53 // Completes a request by sending our dictionary of localized strings.
54 void SendLocalizedStringsAsJSON(
55 const content::URLDataSource::GotDataCallback& callback);
56
57 // Completes a request by sending the file specified by |idr|.
58 void SendFromResourceBundle(
59 const content::URLDataSource::GotDataCallback& callback, int idr);
60
61 private:
62 class InternalDataSource;
63 friend class InternalDataSource;
64 friend class MockChromeWebUIDataSource;
65
66 explicit ChromeWebUIDataSource(const std::string& source_name);
67
68 // Methods that match content::URLDataSource which are called by
69 // InternalDataSource.
70 std::string GetSource();
71 std::string GetMimeType(const std::string& path) const;
72 void StartDataRequest(
73 const std::string& path,
74 bool is_incognito,
75 const content::URLDataSource::GotDataCallback& callback);
76
77 // The name of this source.
78 // E.g., for favicons, this could be "favicon", which results in paths for
79 // specific resources like "favicon/34" getting sent to this source.
80 std::string source_name_;
81 int default_resource_;
82 bool json_js_format_v2_;
83 std::string json_path_;
84 std::map<std::string, int> path_to_idr_map_;
85 DictionaryValue localized_strings_;
86 content::WebUIDataSource::HandleRequestCallback filter_callback_;
87 bool add_csp_;
88 bool object_src_set_;
89 std::string object_src_;
90 bool frame_src_set_;
91 std::string frame_src_;
92 bool deny_xframe_options_;
93
94 DISALLOW_COPY_AND_ASSIGN(ChromeWebUIDataSource);
95 };
96
97 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chrome_url_data_manager_factory.cc ('k') | chrome/browser/ui/webui/chrome_web_ui_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698