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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 if (origin_lock_.is_empty()) | 218 if (origin_lock_.is_empty()) |
219 return true; | 219 return true; |
220 | 220 |
221 // TODO(creis): We must pass the valid browser_context to convert hosted | 221 // TODO(creis): We must pass the valid browser_context to convert hosted |
222 // apps URLs. Currently, hosted apps cannot be loaded in this mode. | 222 // apps URLs. Currently, hosted apps cannot be loaded in this mode. |
223 // See http://crbug.com/160576. | 223 // See http://crbug.com/160576. |
224 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); | 224 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); |
225 return origin_lock_ == site_gurl; | 225 return origin_lock_ == site_gurl; |
226 } | 226 } |
227 | 227 |
228 bool CanAccessCookiesForOrigin(const GURL& gurl) { | 228 bool CanAccessDataForOrigin(const GURL& gurl) { |
229 if (origin_lock_.is_empty()) | 229 if (origin_lock_.is_empty()) |
230 return true; | 230 return true; |
231 // TODO(creis): We must pass the valid browser_context to convert hosted | 231 // TODO(creis): We must pass the valid browser_context to convert hosted |
232 // apps URLs. Currently, hosted apps cannot set cookies in this mode. | 232 // apps URLs. Currently, hosted apps cannot set cookies in this mode. |
233 // See http://crbug.com/160576. | 233 // See http://crbug.com/160576. |
234 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); | 234 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); |
235 return origin_lock_ == site_gurl; | 235 return origin_lock_ == site_gurl; |
236 } | 236 } |
237 | 237 |
238 void LockToOrigin(const GURL& gurl) { | 238 void LockToOrigin(const GURL& gurl) { |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 } | 786 } |
787 | 787 |
788 bool ChildProcessSecurityPolicyImpl::ChildProcessHasPermissionsForFile( | 788 bool ChildProcessSecurityPolicyImpl::ChildProcessHasPermissionsForFile( |
789 int child_id, const base::FilePath& file, int permissions) { | 789 int child_id, const base::FilePath& file, int permissions) { |
790 SecurityStateMap::iterator state = security_state_.find(child_id); | 790 SecurityStateMap::iterator state = security_state_.find(child_id); |
791 if (state == security_state_.end()) | 791 if (state == security_state_.end()) |
792 return false; | 792 return false; |
793 return state->second->HasPermissionsForFile(file, permissions); | 793 return state->second->HasPermissionsForFile(file, permissions); |
794 } | 794 } |
795 | 795 |
796 bool ChildProcessSecurityPolicyImpl::CanAccessCookiesForOrigin( | 796 bool ChildProcessSecurityPolicyImpl::CanAccessDataForOrigin(int child_id, |
797 int child_id, const GURL& gurl) { | 797 const GURL& gurl) { |
798 base::AutoLock lock(lock_); | 798 base::AutoLock lock(lock_); |
799 SecurityStateMap::iterator state = security_state_.find(child_id); | 799 SecurityStateMap::iterator state = security_state_.find(child_id); |
800 if (state == security_state_.end()) | 800 if (state == security_state_.end()) |
801 return false; | 801 return false; |
802 return state->second->CanAccessCookiesForOrigin(gurl); | 802 return state->second->CanAccessDataForOrigin(gurl); |
803 } | 803 } |
804 | 804 |
805 void ChildProcessSecurityPolicyImpl::LockToOrigin(int child_id, | 805 void ChildProcessSecurityPolicyImpl::LockToOrigin(int child_id, |
806 const GURL& gurl) { | 806 const GURL& gurl) { |
807 // "gurl" can be currently empty in some cases, such as file://blah. | 807 // "gurl" can be currently empty in some cases, such as file://blah. |
808 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); | 808 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); |
809 base::AutoLock lock(lock_); | 809 base::AutoLock lock(lock_); |
810 SecurityStateMap::iterator state = security_state_.find(child_id); | 810 SecurityStateMap::iterator state = security_state_.find(child_id); |
811 DCHECK(state != security_state_.end()); | 811 DCHECK(state != security_state_.end()); |
812 state->second->LockToOrigin(gurl); | 812 state->second->LockToOrigin(gurl); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 base::AutoLock lock(lock_); | 847 base::AutoLock lock(lock_); |
848 | 848 |
849 SecurityStateMap::iterator state = security_state_.find(child_id); | 849 SecurityStateMap::iterator state = security_state_.find(child_id); |
850 if (state == security_state_.end()) | 850 if (state == security_state_.end()) |
851 return false; | 851 return false; |
852 | 852 |
853 return state->second->can_send_midi_sysex(); | 853 return state->second->can_send_midi_sysex(); |
854 } | 854 } |
855 | 855 |
856 } // namespace content | 856 } // namespace content |
OLD | NEW |