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

Side by Side Diff: content/public/browser/web_ui_data_source.h

Issue 1457623004: Serve mojo WebUI resources from the same origin as the WebUI itself. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years 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
« no previous file with comments | « content/browser/webui/web_ui_mojo_browsertest.cc ('k') | content/renderer/mojo_context_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
34 // Adds a WebUI data source to |browser_context|. 28 // Adds a WebUI data source to |browser_context|.
35 CONTENT_EXPORT static void Add(BrowserContext* browser_context, 29 CONTENT_EXPORT static void Add(BrowserContext* browser_context,
36 WebUIDataSource* source); 30 WebUIDataSource* source);
37 31
38 // Adds a string keyed to its name to our dictionary. 32 // Adds a string keyed to its name to our dictionary.
39 virtual void AddString(const std::string& name, 33 virtual void AddString(const std::string& name,
40 const base::string16& value) = 0; 34 const base::string16& value) = 0;
41 35
42 // Adds a string keyed to its name to our dictionary. 36 // Adds a string keyed to its name to our dictionary.
43 virtual void AddString(const std::string& name, const std::string& value) = 0; 37 virtual void AddString(const std::string& name, const std::string& value) = 0;
(...skipping 26 matching lines...) Expand all
70 // Used by SetRequestFilter. The string parameter is the path of the request. 64 // Used by SetRequestFilter. The string parameter is the path of the request.
71 // If the callee doesn't want to handle the data, false is returned. Otherwise 65 // If the callee doesn't want to handle the data, false is returned. Otherwise
72 // true is returned and the GotDataCallback parameter is called either then or 66 // true is returned and the GotDataCallback parameter is called either then or
73 // asynchronously with the response. 67 // asynchronously with the response.
74 typedef base::Callback<bool(const std::string&, const GotDataCallback&)> 68 typedef base::Callback<bool(const std::string&, const GotDataCallback&)>
75 HandleRequestCallback; 69 HandleRequestCallback;
76 70
77 // Allows a caller to add a filter for URL requests. 71 // Allows a caller to add a filter for URL requests.
78 virtual void SetRequestFilter(const HandleRequestCallback& callback) = 0; 72 virtual void SetRequestFilter(const HandleRequestCallback& callback) = 0;
79 73
74 // Adds the necessary resources for mojo bindings.
75 virtual void AddMojoResources() = 0;
76
80 // The following map to methods on URLDataSource. See the documentation there. 77 // The following map to methods on URLDataSource. See the documentation there.
81 // NOTE: it's not acceptable to call DisableContentSecurityPolicy for new 78 // NOTE: it's not acceptable to call DisableContentSecurityPolicy for new
82 // pages, see URLDataSource::ShouldAddContentSecurityPolicy and talk to 79 // pages, see URLDataSource::ShouldAddContentSecurityPolicy and talk to
83 // tsepez. 80 // tsepez.
84 81
85 // Currently only used by embedders for WebUIs with multiple instances. 82 // Currently only used by embedders for WebUIs with multiple instances.
86 virtual void DisableReplaceExistingSource() = 0; 83 virtual void DisableReplaceExistingSource() = 0;
87 virtual void DisableContentSecurityPolicy() = 0; 84 virtual void DisableContentSecurityPolicy() = 0;
88 virtual void OverrideContentSecurityPolicyObjectSrc( 85 virtual void OverrideContentSecurityPolicyObjectSrc(
89 const std::string& data) = 0; 86 const std::string& data) = 0;
90 virtual void OverrideContentSecurityPolicyFrameSrc( 87 virtual void OverrideContentSecurityPolicyFrameSrc(
91 const std::string& data) = 0; 88 const std::string& data) = 0;
92 virtual void DisableDenyXFrameOptions() = 0; 89 virtual void DisableDenyXFrameOptions() = 0;
93 }; 90 };
94 91
95 } // namespace content 92 } // namespace content
96 93
97 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ 94 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « content/browser/webui/web_ui_mojo_browsertest.cc ('k') | content/renderer/mojo_context_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698