| 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_RENDERER_HOST_RENDERER_SECURITY_POLICY_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_RENDERER_SECURITY_POLICY_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDERER_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/gfx/native_widget_types.h" |
| 14 #include "base/lock.h" | 15 #include "base/lock.h" |
| 15 #include "base/singleton.h" | 16 #include "base/singleton.h" |
| 16 | 17 |
| 17 class FilePath; | 18 class FilePath; |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| 20 // The RendererSecurityPolicy class is used to grant and revoke security | 21 // The RendererSecurityPolicy class is used to grant and revoke security |
| 21 // capabilities for renderers. For example, it restricts whether a renderer | 22 // capabilities for renderers. For example, it restricts whether a renderer |
| 22 // is permmitted to loaded file:// URLs based on whether the renderer has ever | 23 // is permmitted to loaded file:// URLs based on whether the renderer has ever |
| 23 // been commanded to load file:// URLs by the browser. | 24 // been commanded to load file:// URLs by the browser. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 void GrantUploadFile(int renderer_id, const FilePath& file); | 67 void GrantUploadFile(int renderer_id, const FilePath& file); |
| 67 | 68 |
| 68 // Whenever the browser processes commands the renderer to run web inspector, | 69 // Whenever the browser processes commands the renderer to run web inspector, |
| 69 // it should call this method to grant the renderer process the capability to | 70 // it should call this method to grant the renderer process the capability to |
| 70 // run the inspector. | 71 // run the inspector. |
| 71 void GrantInspectElement(int renderer_id); | 72 void GrantInspectElement(int renderer_id); |
| 72 | 73 |
| 73 // Grant this renderer the ability to use DOM UI Bindings. | 74 // Grant this renderer the ability to use DOM UI Bindings. |
| 74 void GrantDOMUIBindings(int renderer_id); | 75 void GrantDOMUIBindings(int renderer_id); |
| 75 | 76 |
| 77 // Grant this renderer the ability to interact with this native view. |
| 78 void GrantNativeViewId(int renderer_id, gfx::NativeViewId view_id); |
| 79 |
| 76 // Before servicing a renderer's request for a URL, the browser should call | 80 // Before servicing a renderer's request for a URL, the browser should call |
| 77 // this method to determine whether the renderer has the capability to | 81 // this method to determine whether the renderer has the capability to |
| 78 // request the URL. | 82 // request the URL. |
| 79 bool CanRequestURL(int renderer_id, const GURL& url); | 83 bool CanRequestURL(int renderer_id, const GURL& url); |
| 80 | 84 |
| 81 // Before servicing a renderer's request to upload a file to the web, the | 85 // Before servicing a renderer's request to upload a file to the web, the |
| 82 // browser should call this method to determine whether the renderer has the | 86 // browser should call this method to determine whether the renderer has the |
| 83 // capability to upload the requested file. | 87 // capability to upload the requested file. |
| 84 bool CanUploadFile(int renderer_id, const FilePath& file); | 88 bool CanUploadFile(int renderer_id, const FilePath& file); |
| 85 | 89 |
| 86 // Returns true of the specified renderer_id has been granted DOMUIBindings. | 90 // Returns true if the specified renderer_id has been granted DOMUIBindings. |
| 87 // The browser should check this property before assuming the renderer is | 91 // The browser should check this property before assuming the renderer is |
| 88 // allowed to use DOMUIBindings. | 92 // allowed to use DOMUIBindings. |
| 89 bool HasDOMUIBindings(int renderer_id); | 93 bool HasDOMUIBindings(int renderer_id); |
| 90 | 94 |
| 95 // Returns true if the |renderer_id| can interact with |view_id|. |
| 96 bool HasNativeViewId(int renderer_id, gfx::NativeViewId view_id); |
| 97 |
| 91 private: | 98 private: |
| 92 class SecurityState; | 99 class SecurityState; |
| 93 | 100 |
| 94 typedef std::set<std::string> SchemeSet; | 101 typedef std::set<std::string> SchemeSet; |
| 95 typedef std::map<int, SecurityState*> SecurityStateMap; | 102 typedef std::map<int, SecurityState*> SecurityStateMap; |
| 96 | 103 |
| 97 // Obtain an instance of RendererSecurityPolicy via GetInstance(). | 104 // Obtain an instance of RendererSecurityPolicy via GetInstance(). |
| 98 RendererSecurityPolicy(); | 105 RendererSecurityPolicy(); |
| 99 friend struct DefaultSingletonTraits<RendererSecurityPolicy>; | 106 friend struct DefaultSingletonTraits<RendererSecurityPolicy>; |
| 100 | 107 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 114 // This map holds a SecurityState for each renderer process. The key for the | 121 // This map holds a SecurityState for each renderer process. The key for the |
| 115 // map is the ID of the RenderProcessHost. The SecurityState objects are | 122 // map is the ID of the RenderProcessHost. The SecurityState objects are |
| 116 // owned by this object and are protected by |lock_|. References to them must | 123 // owned by this object and are protected by |lock_|. References to them must |
| 117 // not escape this class. | 124 // not escape this class. |
| 118 SecurityStateMap security_state_; | 125 SecurityStateMap security_state_; |
| 119 | 126 |
| 120 DISALLOW_COPY_AND_ASSIGN(RendererSecurityPolicy); | 127 DISALLOW_COPY_AND_ASSIGN(RendererSecurityPolicy); |
| 121 }; | 128 }; |
| 122 | 129 |
| 123 #endif // CHROME_BROWSER_RENDERER_HOST_RENDERER_SECURITY_POLICY_H_ | 130 #endif // CHROME_BROWSER_RENDERER_HOST_RENDERER_SECURITY_POLICY_H_ |
| OLD | NEW |