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

Side by Side Diff: content/browser/child_process_security_policy_impl.h

Issue 2830743004: Extracting and unittesting PrepareDropDataForChildProcess function. (Closed)
Patch Set: Fixing build on Windows + adding a bit more test verifications. Created 3 years, 8 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
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 CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
6 #define CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 6 #define CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "content/public/browser/child_process_security_policy.h" 19 #include "content/public/browser/child_process_security_policy.h"
20 #include "content/public/common/resource_type.h" 20 #include "content/public/common/resource_type.h"
21 #include "storage/common/fileapi/file_system_types.h" 21 #include "storage/common/fileapi/file_system_types.h"
22 22
23 class GURL; 23 class GURL;
24 24
25 namespace base { 25 namespace base {
26 class FilePath; 26 class FilePath;
27 } 27 }
28 28
29 namespace storage { 29 namespace storage {
30 class FileSystemContext;
30 class FileSystemURL; 31 class FileSystemURL;
31 } 32 }
32 33
33 namespace content { 34 namespace content {
34 35
36 struct DropData;
37
35 class CONTENT_EXPORT ChildProcessSecurityPolicyImpl 38 class CONTENT_EXPORT ChildProcessSecurityPolicyImpl
36 : NON_EXPORTED_BASE(public ChildProcessSecurityPolicy) { 39 : NON_EXPORTED_BASE(public ChildProcessSecurityPolicy) {
37 public: 40 public:
38 // Object can only be created through GetInstance() so the constructor is 41 // Object can only be created through GetInstance() so the constructor is
39 // private. 42 // private.
40 ~ChildProcessSecurityPolicyImpl() override; 43 ~ChildProcessSecurityPolicyImpl() override;
41 44
42 static ChildProcessSecurityPolicyImpl* GetInstance(); 45 static ChildProcessSecurityPolicyImpl* GetInstance();
43 46
44 // ChildProcessSecurityPolicy implementation. 47 // ChildProcessSecurityPolicy implementation.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 166
164 // Register FileSystem type and permission policy which should be used 167 // Register FileSystem type and permission policy which should be used
165 // for the type. The |policy| must be a bitwise-or'd value of 168 // for the type. The |policy| must be a bitwise-or'd value of
166 // storage::FilePermissionPolicy. 169 // storage::FilePermissionPolicy.
167 void RegisterFileSystemPermissionPolicy(storage::FileSystemType type, 170 void RegisterFileSystemPermissionPolicy(storage::FileSystemType type,
168 int policy); 171 int policy);
169 172
170 // Returns true if sending system exclusive messages is allowed. 173 // Returns true if sending system exclusive messages is allowed.
171 bool CanSendMidiSysExMessage(int child_id); 174 bool CanSendMidiSysExMessage(int child_id);
172 175
176 // Grants |child_id| access to the data in |drop_data| (mutating |drop_data|
177 // if needed - e.g. putting in isolated filesystem entries if needed).
178 //
179 // At a high-level, this method:
180 // 1. Grants permissions to URL (if any)
181 // 2. Grants permissions to filenames (via IsolatedContest)
182 // 3. Grants permissions to file system files (via IsolatedContest).
183 void GrantFileAccessFromDropData(
184 int child_id,
185 const storage::FileSystemContext* file_system_context,
186 DropData* drop_data);
187
173 private: 188 private:
174 friend class ChildProcessSecurityPolicyInProcessBrowserTest; 189 friend class ChildProcessSecurityPolicyInProcessBrowserTest;
175 friend class ChildProcessSecurityPolicyTest; 190 friend class ChildProcessSecurityPolicyTest;
176 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, 191 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest,
177 NoLeak); 192 NoLeak);
178 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); 193 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions);
179 194
180 class SecurityState; 195 class SecurityState;
181 196
182 typedef std::set<std::string> SchemeSet; 197 typedef std::set<std::string> SchemeSet;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 WorkerToMainProcessMap worker_map_; 274 WorkerToMainProcessMap worker_map_;
260 275
261 FileSystemPermissionPolicyMap file_system_policy_map_; 276 FileSystemPermissionPolicyMap file_system_policy_map_;
262 277
263 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); 278 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl);
264 }; 279 };
265 280
266 } // namespace content 281 } // namespace content
267 282
268 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 283 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698