OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_RENDERER_HOST_RENDERER_SECURITY_POLICY_H_ | 5 #ifndef CHROME_BROWSER_CHILD_PROCESS_SECURITY_POLICY_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_RENDERER_SECURITY_POLICY_H_ | 6 #define CHROME_BROWSER_CHILD_PROCESS_SECURITY_POLICY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/lock.h" | 14 #include "base/lock.h" |
15 #include "base/singleton.h" | 15 #include "base/singleton.h" |
16 | 16 |
17 class FilePath; | 17 class FilePath; |
18 class GURL; | 18 class GURL; |
19 | 19 |
20 // The RendererSecurityPolicy class is used to grant and revoke security | 20 // The ChildProcessSecurityPolicy class is used to grant and revoke security |
21 // capabilities for renderers. For example, it restricts whether a renderer | 21 // capabilities for renderers. For example, it restricts whether a renderer |
22 // is permmitted to loaded file:// URLs based on whether the renderer has ever | 22 // is permmitted to loaded file:// URLs based on whether the renderer has ever |
23 // been commanded to load file:// URLs by the browser. | 23 // been commanded to load file:// URLs by the browser. |
24 // | 24 // |
25 // RendererSecurityPolicy is a singleton that may be used on any thread. | 25 // ChildProcessSecurityPolicy is a singleton that may be used on any thread. |
26 // | 26 // |
27 class RendererSecurityPolicy { | 27 class ChildProcessSecurityPolicy { |
28 public: | 28 public: |
29 // Object can only be created through GetInstance() so the constructor is | 29 // Object can only be created through GetInstance() so the constructor is |
30 // private. | 30 // private. |
31 ~RendererSecurityPolicy(); | 31 ~ChildProcessSecurityPolicy(); |
32 | 32 |
33 // There is one global RendererSecurityPolicy object for the entire browser | 33 // There is one global ChildProcessSecurityPolicy object for the entire browse
r |
34 // processes. The object returned by this method may be accessed on any | 34 // processes. The object returned by this method may be accessed on any |
35 // thread. | 35 // thread. |
36 static RendererSecurityPolicy* GetInstance(); | 36 static ChildProcessSecurityPolicy* GetInstance(); |
37 | 37 |
38 // Web-safe schemes can be requested by any renderer. Once a web-safe scheme | 38 // Web-safe schemes can be requested by any renderer. Once a web-safe scheme |
39 // has been registered, any renderer processes can request URLs with that | 39 // has been registered, any renderer processes can request URLs with that |
40 // scheme. There is no mechanism for revoking web-safe schemes. | 40 // scheme. There is no mechanism for revoking web-safe schemes. |
41 void RegisterWebSafeScheme(const std::string& scheme); | 41 void RegisterWebSafeScheme(const std::string& scheme); |
42 | 42 |
43 // Returns true iff |scheme| has been registered as a web-safe scheme. | 43 // Returns true iff |scheme| has been registered as a web-safe scheme. |
44 bool IsWebSafeScheme(const std::string& scheme); | 44 bool IsWebSafeScheme(const std::string& scheme); |
45 | 45 |
46 // Pseudo schemes are treated differently than other schemes because they | 46 // Pseudo schemes are treated differently than other schemes because they |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // The browser should check this property before assuming the renderer is | 91 // The browser should check this property before assuming the renderer is |
92 // allowed to use DOMUIBindings. | 92 // allowed to use DOMUIBindings. |
93 bool HasDOMUIBindings(int renderer_id); | 93 bool HasDOMUIBindings(int renderer_id); |
94 | 94 |
95 private: | 95 private: |
96 class SecurityState; | 96 class SecurityState; |
97 | 97 |
98 typedef std::set<std::string> SchemeSet; | 98 typedef std::set<std::string> SchemeSet; |
99 typedef std::map<int, SecurityState*> SecurityStateMap; | 99 typedef std::map<int, SecurityState*> SecurityStateMap; |
100 | 100 |
101 // Obtain an instance of RendererSecurityPolicy via GetInstance(). | 101 // Obtain an instance of ChildProcessSecurityPolicy via GetInstance(). |
102 RendererSecurityPolicy(); | 102 ChildProcessSecurityPolicy(); |
103 friend struct DefaultSingletonTraits<RendererSecurityPolicy>; | 103 friend struct DefaultSingletonTraits<ChildProcessSecurityPolicy>; |
104 | 104 |
105 // You must acquire this lock before reading or writing any members of this | 105 // You must acquire this lock before reading or writing any members of this |
106 // class. You must not block while holding this lock. | 106 // class. You must not block while holding this lock. |
107 Lock lock_; | 107 Lock lock_; |
108 | 108 |
109 // These schemes are white-listed for all renderers. This set is protected | 109 // These schemes are white-listed for all renderers. This set is protected |
110 // by |lock_|. | 110 // by |lock_|. |
111 SchemeSet web_safe_schemes_; | 111 SchemeSet web_safe_schemes_; |
112 | 112 |
113 // These schemes do not actually represent retrievable URLs. For example, | 113 // These schemes do not actually represent retrievable URLs. For example, |
114 // the the URLs in the "about" scheme are aliases to other URLs. This set is | 114 // the the URLs in the "about" scheme are aliases to other URLs. This set is |
115 // protected by |lock_|. | 115 // protected by |lock_|. |
116 SchemeSet pseudo_schemes_; | 116 SchemeSet pseudo_schemes_; |
117 | 117 |
118 // This map holds a SecurityState for each renderer process. The key for the | 118 // This map holds a SecurityState for each renderer process. The key for the |
119 // map is the ID of the RenderProcessHost. The SecurityState objects are | 119 // map is the ID of the RenderProcessHost. The SecurityState objects are |
120 // owned by this object and are protected by |lock_|. References to them must | 120 // owned by this object and are protected by |lock_|. References to them must |
121 // not escape this class. | 121 // not escape this class. |
122 SecurityStateMap security_state_; | 122 SecurityStateMap security_state_; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(RendererSecurityPolicy); | 124 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicy); |
125 }; | 125 }; |
126 | 126 |
127 #endif // CHROME_BROWSER_RENDERER_HOST_RENDERER_SECURITY_POLICY_H_ | 127 #endif // CHROME_BROWSER_CHILD_PROCESS_SECURITY_POLICY_H_ |
OLD | NEW |