| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 bool HasPermissionsForFileSystem(const std::string& filesystem_id, | 129 bool HasPermissionsForFileSystem(const std::string& filesystem_id, |
| 130 int permissions) { | 130 int permissions) { |
| 131 FileSystemMap::const_iterator it = | 131 FileSystemMap::const_iterator it = |
| 132 filesystem_permissions_.find(filesystem_id); | 132 filesystem_permissions_.find(filesystem_id); |
| 133 if (it == filesystem_permissions_.end()) | 133 if (it == filesystem_permissions_.end()) |
| 134 return false; | 134 return false; |
| 135 return (it->second & permissions) == permissions; | 135 return (it->second & permissions) == permissions; |
| 136 } | 136 } |
| 137 | 137 |
| 138 #if defined(OS_ANDROID) |
| 139 // Determine if the certain permissions have been granted to a content URI. |
| 140 bool HasPermissionsForContentUri(const base::FilePath& file, |
| 141 int permissions) { |
| 142 DCHECK(!file.empty()); |
| 143 DCHECK(file.IsContentUri()); |
| 144 if (!permissions) |
| 145 return false; |
| 146 base::FilePath file_path = file.StripTrailingSeparators(); |
| 147 FileMap::const_iterator it = file_permissions_.find(file_path); |
| 148 if (it != file_permissions_.end()) |
| 149 return (it->second & permissions) == permissions; |
| 150 return false; |
| 151 } |
| 152 #endif |
| 153 |
| 138 void GrantBindings(int bindings) { | 154 void GrantBindings(int bindings) { |
| 139 enabled_bindings_ |= bindings; | 155 enabled_bindings_ |= bindings; |
| 140 } | 156 } |
| 141 | 157 |
| 142 void GrantReadRawCookies() { | 158 void GrantReadRawCookies() { |
| 143 can_read_raw_cookies_ = true; | 159 can_read_raw_cookies_ = true; |
| 144 } | 160 } |
| 145 | 161 |
| 146 void RevokeReadRawCookies() { | 162 void RevokeReadRawCookies() { |
| 147 can_read_raw_cookies_ = false; | 163 can_read_raw_cookies_ = false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 164 base::FilePath path; | 180 base::FilePath path; |
| 165 if (net::FileURLToFilePath(url, &path)) | 181 if (net::FileURLToFilePath(url, &path)) |
| 166 return ContainsKey(request_file_set_, path); | 182 return ContainsKey(request_file_set_, path); |
| 167 } | 183 } |
| 168 | 184 |
| 169 return false; // Unmentioned schemes are disallowed. | 185 return false; // Unmentioned schemes are disallowed. |
| 170 } | 186 } |
| 171 | 187 |
| 172 // Determine if the certain permissions have been granted to a file. | 188 // Determine if the certain permissions have been granted to a file. |
| 173 bool HasPermissionsForFile(const base::FilePath& file, int permissions) { | 189 bool HasPermissionsForFile(const base::FilePath& file, int permissions) { |
| 190 #if defined(OS_ANDROID) |
| 191 if (file.IsContentUri()) |
| 192 return HasPermissionsForContentUri(file, permissions); |
| 193 #endif |
| 174 if (!permissions || file.empty() || !file.IsAbsolute()) | 194 if (!permissions || file.empty() || !file.IsAbsolute()) |
| 175 return false; | 195 return false; |
| 176 base::FilePath current_path = file.StripTrailingSeparators(); | 196 base::FilePath current_path = file.StripTrailingSeparators(); |
| 177 base::FilePath last_path; | 197 base::FilePath last_path; |
| 178 int skip = 0; | 198 int skip = 0; |
| 179 while (current_path != last_path) { | 199 while (current_path != last_path) { |
| 180 base::FilePath base_name = current_path.BaseName(); | 200 base::FilePath base_name = current_path.BaseName(); |
| 181 if (base_name.value() == base::FilePath::kParentDirectory) { | 201 if (base_name.value() == base::FilePath::kParentDirectory) { |
| 182 ++skip; | 202 ++skip; |
| 183 } else if (skip > 0) { | 203 } else if (skip > 0) { |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 base::AutoLock lock(lock_); | 875 base::AutoLock lock(lock_); |
| 856 | 876 |
| 857 SecurityStateMap::iterator state = security_state_.find(child_id); | 877 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 858 if (state == security_state_.end()) | 878 if (state == security_state_.end()) |
| 859 return false; | 879 return false; |
| 860 | 880 |
| 861 return state->second->can_send_midi_sysex(); | 881 return state->second->can_send_midi_sysex(); |
| 862 } | 882 } |
| 863 | 883 |
| 864 } // namespace content | 884 } // namespace content |
| OLD | NEW |