| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 156 } |
| 157 | 157 |
| 158 void GrantReadRawCookies() { | 158 void GrantReadRawCookies() { |
| 159 can_read_raw_cookies_ = true; | 159 can_read_raw_cookies_ = true; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void RevokeReadRawCookies() { | 162 void RevokeReadRawCookies() { |
| 163 can_read_raw_cookies_ = false; | 163 can_read_raw_cookies_ = false; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void GrantPermissionForMIDISysEx() { | 166 void GrantPermissionForMidiSysEx() { |
| 167 can_send_midi_sysex_ = true; | 167 can_send_midi_sysex_ = true; |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Determine whether permission has been granted to request |url|. | 170 // Determine whether permission has been granted to request |url|. |
| 171 bool CanRequestURL(const GURL& url) { | 171 bool CanRequestURL(const GURL& url) { |
| 172 // Having permission to a scheme implies permssion to all of its URLs. | 172 // Having permission to a scheme implies permssion to all of its URLs. |
| 173 SchemeMap::const_iterator judgment(scheme_policy_.find(url.scheme())); | 173 SchemeMap::const_iterator judgment(scheme_policy_.find(url.scheme())); |
| 174 if (judgment != scheme_policy_.end()) | 174 if (judgment != scheme_policy_.end()) |
| 175 return judgment->second; | 175 return judgment->second; |
| 176 | 176 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 void ChildProcessSecurityPolicyImpl::GrantCopyIntoFileSystem( | 507 void ChildProcessSecurityPolicyImpl::GrantCopyIntoFileSystem( |
| 508 int child_id, const std::string& filesystem_id) { | 508 int child_id, const std::string& filesystem_id) { |
| 509 GrantPermissionsForFileSystem(child_id, filesystem_id, COPY_INTO_FILE_GRANT); | 509 GrantPermissionsForFileSystem(child_id, filesystem_id, COPY_INTO_FILE_GRANT); |
| 510 } | 510 } |
| 511 | 511 |
| 512 void ChildProcessSecurityPolicyImpl::GrantDeleteFromFileSystem( | 512 void ChildProcessSecurityPolicyImpl::GrantDeleteFromFileSystem( |
| 513 int child_id, const std::string& filesystem_id) { | 513 int child_id, const std::string& filesystem_id) { |
| 514 GrantPermissionsForFileSystem(child_id, filesystem_id, DELETE_FILE_GRANT); | 514 GrantPermissionsForFileSystem(child_id, filesystem_id, DELETE_FILE_GRANT); |
| 515 } | 515 } |
| 516 | 516 |
| 517 void ChildProcessSecurityPolicyImpl::GrantSendMIDISysExMessage(int child_id) { | 517 void ChildProcessSecurityPolicyImpl::GrantSendMidiSysExMessage(int child_id) { |
| 518 base::AutoLock lock(lock_); | 518 base::AutoLock lock(lock_); |
| 519 | 519 |
| 520 SecurityStateMap::iterator state = security_state_.find(child_id); | 520 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 521 if (state == security_state_.end()) | 521 if (state == security_state_.end()) |
| 522 return; | 522 return; |
| 523 | 523 |
| 524 state->second->GrantPermissionForMIDISysEx(); | 524 state->second->GrantPermissionForMidiSysEx(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 void ChildProcessSecurityPolicyImpl::GrantScheme(int child_id, | 527 void ChildProcessSecurityPolicyImpl::GrantScheme(int child_id, |
| 528 const std::string& scheme) { | 528 const std::string& scheme) { |
| 529 base::AutoLock lock(lock_); | 529 base::AutoLock lock(lock_); |
| 530 | 530 |
| 531 SecurityStateMap::iterator state = security_state_.find(child_id); | 531 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 532 if (state == security_state_.end()) | 532 if (state == security_state_.end()) |
| 533 return; | 533 return; |
| 534 | 534 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); | 864 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); |
| 865 } | 865 } |
| 866 | 866 |
| 867 void ChildProcessSecurityPolicyImpl::RegisterFileSystemPermissionPolicy( | 867 void ChildProcessSecurityPolicyImpl::RegisterFileSystemPermissionPolicy( |
| 868 fileapi::FileSystemType type, | 868 fileapi::FileSystemType type, |
| 869 int policy) { | 869 int policy) { |
| 870 base::AutoLock lock(lock_); | 870 base::AutoLock lock(lock_); |
| 871 file_system_policy_map_[type] = policy; | 871 file_system_policy_map_[type] = policy; |
| 872 } | 872 } |
| 873 | 873 |
| 874 bool ChildProcessSecurityPolicyImpl::CanSendMIDISysExMessage(int child_id) { | 874 bool ChildProcessSecurityPolicyImpl::CanSendMidiSysExMessage(int child_id) { |
| 875 base::AutoLock lock(lock_); | 875 base::AutoLock lock(lock_); |
| 876 | 876 |
| 877 SecurityStateMap::iterator state = security_state_.find(child_id); | 877 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 878 if (state == security_state_.end()) | 878 if (state == security_state_.end()) |
| 879 return false; | 879 return false; |
| 880 | 880 |
| 881 return state->second->can_send_midi_sysex(); | 881 return state->second->can_send_midi_sysex(); |
| 882 } | 882 } |
| 883 | 883 |
| 884 } // namespace content | 884 } // namespace content |
| OLD | NEW |