| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 #include "content/browser/site_instance_impl.h" | 18 #include "content/browser/site_instance_impl.h" |
| 18 #include "content/common/site_isolation_policy.h" | 19 #include "content/common/site_isolation_policy.h" |
| 19 #include "content/public/browser/child_process_data.h" | 20 #include "content/public/browser/child_process_data.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/common/bindings_policy.h" | 23 #include "content/public/common/bindings_policy.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 bool CanAccessDataForOrigin(const GURL& gurl) { | 231 bool CanAccessDataForOrigin(const GURL& gurl) { |
| 231 if (origin_lock_.is_empty()) | 232 if (origin_lock_.is_empty()) |
| 232 return true; | 233 return true; |
| 233 // 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 |
| 234 // apps URLs. Currently, hosted apps cannot set cookies in this mode. | 235 // apps URLs. Currently, hosted apps cannot set cookies in this mode. |
| 235 // See http://crbug.com/160576. | 236 // See http://crbug.com/160576. |
| 236 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); | 237 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); |
| 237 return origin_lock_ == site_gurl; | 238 return origin_lock_ == site_gurl; |
| 238 } | 239 } |
| 239 | 240 |
| 241 // TODO(nick): Remove this once we understand http://crbug.com/600441 |
| 242 GURL GetOriginLock() { |
| 243 return origin_lock_; |
| 244 } |
| 245 |
| 240 void LockToOrigin(const GURL& gurl) { | 246 void LockToOrigin(const GURL& gurl) { |
| 241 origin_lock_ = gurl; | 247 origin_lock_ = gurl; |
| 242 } | 248 } |
| 243 | 249 |
| 244 bool has_web_ui_bindings() const { | 250 bool has_web_ui_bindings() const { |
| 245 return enabled_bindings_ & BINDINGS_POLICY_WEB_UI; | 251 return enabled_bindings_ & BINDINGS_POLICY_WEB_UI; |
| 246 } | 252 } |
| 247 | 253 |
| 248 bool can_read_raw_cookies() const { | 254 bool can_read_raw_cookies() const { |
| 249 return can_read_raw_cookies_; | 255 return can_read_raw_cookies_; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 | 821 |
| 816 bool ChildProcessSecurityPolicyImpl::CanAccessDataForOrigin(int child_id, | 822 bool ChildProcessSecurityPolicyImpl::CanAccessDataForOrigin(int child_id, |
| 817 const GURL& gurl) { | 823 const GURL& gurl) { |
| 818 base::AutoLock lock(lock_); | 824 base::AutoLock lock(lock_); |
| 819 SecurityStateMap::iterator state = security_state_.find(child_id); | 825 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 820 if (state == security_state_.end()) | 826 if (state == security_state_.end()) |
| 821 return false; | 827 return false; |
| 822 return state->second->CanAccessDataForOrigin(gurl); | 828 return state->second->CanAccessDataForOrigin(gurl); |
| 823 } | 829 } |
| 824 | 830 |
| 831 // TODO(nick): Remove this once we understand http://crbug.com/600441 |
| 832 std::unique_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 base::WrapUnique(new base::debug::ScopedCrashKey( |
| 837 "security_policy_origin_lock", |
| 838 state == security_state_.end() |
| 839 ? "not-found" |
| 840 : state->second->GetOriginLock().possibly_invalid_spec())); |
| 841 } |
| 842 |
| 825 void ChildProcessSecurityPolicyImpl::LockToOrigin(int child_id, | 843 void ChildProcessSecurityPolicyImpl::LockToOrigin(int child_id, |
| 826 const GURL& gurl) { | 844 const GURL& gurl) { |
| 827 // "gurl" can be currently empty in some cases, such as file://blah. | 845 // "gurl" can be currently empty in some cases, such as file://blah. |
| 828 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); | 846 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); |
| 829 base::AutoLock lock(lock_); | 847 base::AutoLock lock(lock_); |
| 830 SecurityStateMap::iterator state = security_state_.find(child_id); | 848 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 831 DCHECK(state != security_state_.end()); | 849 DCHECK(state != security_state_.end()); |
| 832 state->second->LockToOrigin(gurl); | 850 state->second->LockToOrigin(gurl); |
| 833 } | 851 } |
| 834 | 852 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 base::AutoLock lock(lock_); | 885 base::AutoLock lock(lock_); |
| 868 | 886 |
| 869 SecurityStateMap::iterator state = security_state_.find(child_id); | 887 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 870 if (state == security_state_.end()) | 888 if (state == security_state_.end()) |
| 871 return false; | 889 return false; |
| 872 | 890 |
| 873 return state->second->can_send_midi_sysex(); | 891 return state->second->can_send_midi_sysex(); |
| 874 } | 892 } |
| 875 | 893 |
| 876 } // namespace content | 894 } // namespace content |
| OLD | NEW |