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