Chromium Code Reviews| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 bool CanAccessDataForOrigin(const GURL& gurl) { | 231 bool CanAccessDataForOrigin(const GURL& gurl) { |
| 232 if (origin_lock_.is_empty()) | 232 if (origin_lock_.is_empty()) |
| 233 return true; | 233 return true; |
| 234 // TODO(creis): We must pass the valid browser_context to convert hosted | 234 // TODO(creis): We must pass the valid browser_context to convert hosted |
| 235 // apps URLs. Currently, hosted apps cannot set cookies in this mode. | 235 // apps URLs. Currently, hosted apps cannot set cookies in this mode. |
| 236 // See http://crbug.com/160576. | 236 // See http://crbug.com/160576. |
| 237 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); | 237 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); |
| 238 return origin_lock_ == site_gurl; | 238 return origin_lock_ == site_gurl; |
| 239 } | 239 } |
| 240 | 240 |
| 241 // TODO(nick): Remove this once we understand http://crbug.com/600441 | |
| 242 GURL GetOriginLock() { | |
| 243 return origin_lock_; | |
| 244 } | |
| 245 | |
| 241 void LockToOrigin(const GURL& gurl) { | 246 void LockToOrigin(const GURL& gurl) { |
| 242 origin_lock_ = gurl; | 247 origin_lock_ = gurl; |
| 243 } | 248 } |
| 244 | 249 |
| 245 bool has_web_ui_bindings() const { | 250 bool has_web_ui_bindings() const { |
| 246 return enabled_bindings_ & BINDINGS_POLICY_WEB_UI; | 251 return enabled_bindings_ & BINDINGS_POLICY_WEB_UI; |
| 247 } | 252 } |
| 248 | 253 |
| 249 bool can_read_raw_cookies() const { | 254 bool can_read_raw_cookies() const { |
| 250 return can_read_raw_cookies_; | 255 return can_read_raw_cookies_; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 | 821 |
| 817 bool ChildProcessSecurityPolicyImpl::CanAccessDataForOrigin(int child_id, | 822 bool ChildProcessSecurityPolicyImpl::CanAccessDataForOrigin(int child_id, |
| 818 const GURL& gurl) { | 823 const GURL& gurl) { |
| 819 base::AutoLock lock(lock_); | 824 base::AutoLock lock(lock_); |
| 820 SecurityStateMap::iterator state = security_state_.find(child_id); | 825 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 821 if (state == security_state_.end()) | 826 if (state == security_state_.end()) |
| 822 return false; | 827 return false; |
| 823 return state->second->CanAccessDataForOrigin(gurl); | 828 return state->second->CanAccessDataForOrigin(gurl); |
| 824 } | 829 } |
| 825 | 830 |
| 831 // TODO(nick): Remove this once we understand http://crbug.com/600441 | |
| 832 scoped_ptr<base::debug::ScopedCrashKey> | |
| 833 ChildProcessSecurityPolicyImpl::GetOriginLockCrashKey(int child_id) { | |
| 834 base::AutoLock lock(lock_); | |
| 835 SecurityStateMap::iterator state = security_state_.find(child_id); | |
| 836 return make_scoped_ptr(new base::debug::ScopedCrashKey( | |
| 837 "policy_origin_lock", state == security_state_.end() | |
|
Avi (use Gerrit)
2016/04/05 01:41:23
The key constant in the crash keys file is "securi
ncarter (slow)
2016/05/03 00:16:01
Done. Good catch, thanks!
| |
| 838 ? "not-found" | |
| 839 : state->second->GetOriginLock().spec())); | |
| 840 } | |
| 841 | |
| 826 void ChildProcessSecurityPolicyImpl::LockToOrigin(int child_id, | 842 void ChildProcessSecurityPolicyImpl::LockToOrigin(int child_id, |
| 827 const GURL& gurl) { | 843 const GURL& gurl) { |
| 828 // "gurl" can be currently empty in some cases, such as file://blah. | 844 // "gurl" can be currently empty in some cases, such as file://blah. |
| 829 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); | 845 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); |
| 830 base::AutoLock lock(lock_); | 846 base::AutoLock lock(lock_); |
| 831 SecurityStateMap::iterator state = security_state_.find(child_id); | 847 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 832 DCHECK(state != security_state_.end()); | 848 DCHECK(state != security_state_.end()); |
| 833 state->second->LockToOrigin(gurl); | 849 state->second->LockToOrigin(gurl); |
| 834 } | 850 } |
| 835 | 851 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 868 base::AutoLock lock(lock_); | 884 base::AutoLock lock(lock_); |
| 869 | 885 |
| 870 SecurityStateMap::iterator state = security_state_.find(child_id); | 886 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 871 if (state == security_state_.end()) | 887 if (state == security_state_.end()) |
| 872 return false; | 888 return false; |
| 873 | 889 |
| 874 return state->second->can_send_midi_sysex(); | 890 return state->second->can_send_midi_sysex(); |
| 875 } | 891 } |
| 876 | 892 |
| 877 } // namespace content | 893 } // namespace content |
| OLD | NEW |