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