OLD | NEW |
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 #include "content/browser/child_process_security_policy_impl.h" | 5 #include "content/browser/child_process_security_policy_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 bool CanAccessDataForOrigin(const GURL& site_url) { | 261 bool CanAccessDataForOrigin(const GURL& site_url) { |
262 if (origin_lock_.is_empty()) | 262 if (origin_lock_.is_empty()) |
263 return true; | 263 return true; |
264 return origin_lock_ == site_url; | 264 return origin_lock_ == site_url; |
265 } | 265 } |
266 | 266 |
267 void LockToOrigin(const GURL& gurl) { | 267 void LockToOrigin(const GURL& gurl) { |
268 origin_lock_ = gurl; | 268 origin_lock_ = gurl; |
269 } | 269 } |
270 | 270 |
| 271 bool HasOriginLock() { return !origin_lock_.is_empty(); } |
| 272 |
| 273 bool IsLockedToOrigin(const GURL& gurl) { return origin_lock_ == gurl; } |
| 274 |
271 bool has_web_ui_bindings() const { | 275 bool has_web_ui_bindings() const { |
272 return enabled_bindings_ & BINDINGS_POLICY_WEB_UI; | 276 return enabled_bindings_ & BINDINGS_POLICY_WEB_UI; |
273 } | 277 } |
274 | 278 |
275 bool can_read_raw_cookies() const { | 279 bool can_read_raw_cookies() const { |
276 return can_read_raw_cookies_; | 280 return can_read_raw_cookies_; |
277 } | 281 } |
278 | 282 |
279 bool can_send_midi_sysex() const { | 283 bool can_send_midi_sysex() const { |
280 return can_send_midi_sysex_; | 284 return can_send_midi_sysex_; |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 void ChildProcessSecurityPolicyImpl::LockToOrigin(int child_id, | 1022 void ChildProcessSecurityPolicyImpl::LockToOrigin(int child_id, |
1019 const GURL& gurl) { | 1023 const GURL& gurl) { |
1020 // "gurl" can be currently empty in some cases, such as file://blah. | 1024 // "gurl" can be currently empty in some cases, such as file://blah. |
1021 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); | 1025 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); |
1022 base::AutoLock lock(lock_); | 1026 base::AutoLock lock(lock_); |
1023 SecurityStateMap::iterator state = security_state_.find(child_id); | 1027 SecurityStateMap::iterator state = security_state_.find(child_id); |
1024 DCHECK(state != security_state_.end()); | 1028 DCHECK(state != security_state_.end()); |
1025 state->second->LockToOrigin(gurl); | 1029 state->second->LockToOrigin(gurl); |
1026 } | 1030 } |
1027 | 1031 |
| 1032 bool ChildProcessSecurityPolicyImpl::HasOriginLock(int child_id) { |
| 1033 base::AutoLock lock(lock_); |
| 1034 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 1035 if (state == security_state_.end()) |
| 1036 return false; |
| 1037 return state->second->HasOriginLock(); |
| 1038 } |
| 1039 |
| 1040 bool ChildProcessSecurityPolicyImpl::IsLockedToOrigin(int child_id, |
| 1041 const GURL& site_url) { |
| 1042 base::AutoLock lock(lock_); |
| 1043 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 1044 if (state == security_state_.end()) |
| 1045 return false; |
| 1046 return state->second->IsLockedToOrigin(site_url); |
| 1047 } |
| 1048 |
1028 void ChildProcessSecurityPolicyImpl::GrantPermissionsForFileSystem( | 1049 void ChildProcessSecurityPolicyImpl::GrantPermissionsForFileSystem( |
1029 int child_id, | 1050 int child_id, |
1030 const std::string& filesystem_id, | 1051 const std::string& filesystem_id, |
1031 int permission) { | 1052 int permission) { |
1032 base::AutoLock lock(lock_); | 1053 base::AutoLock lock(lock_); |
1033 | 1054 |
1034 SecurityStateMap::iterator state = security_state_.find(child_id); | 1055 SecurityStateMap::iterator state = security_state_.find(child_id); |
1035 if (state == security_state_.end()) | 1056 if (state == security_state_.end()) |
1036 return; | 1057 return; |
1037 state->second->GrantPermissionsForFileSystem(filesystem_id, permission); | 1058 state->second->GrantPermissionsForFileSystem(filesystem_id, permission); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 } | 1109 } |
1089 } | 1110 } |
1090 | 1111 |
1091 bool ChildProcessSecurityPolicyImpl::IsIsolatedOrigin( | 1112 bool ChildProcessSecurityPolicyImpl::IsIsolatedOrigin( |
1092 const url::Origin& origin) { | 1113 const url::Origin& origin) { |
1093 base::AutoLock lock(lock_); | 1114 base::AutoLock lock(lock_); |
1094 return isolated_origins_.find(origin) != isolated_origins_.end(); | 1115 return isolated_origins_.find(origin) != isolated_origins_.end(); |
1095 } | 1116 } |
1096 | 1117 |
1097 } // namespace content | 1118 } // namespace content |
OLD | NEW |