| 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/file_path.h" | 8 #include "base/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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 FilePath path; | 139 FilePath path; |
| 140 if (net::FileURLToFilePath(url, &path)) | 140 if (net::FileURLToFilePath(url, &path)) |
| 141 return request_file_set_.find(path) != request_file_set_.end(); | 141 return request_file_set_.find(path) != request_file_set_.end(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 return false; // Unmentioned schemes are disallowed. | 144 return false; // Unmentioned schemes are disallowed. |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Determine if the certain permissions have been granted to a file. | 147 // Determine if the certain permissions have been granted to a file. |
| 148 bool HasPermissionsForFile(const FilePath& file, int permissions) { | 148 bool HasPermissionsForFile(const FilePath& file, int permissions) { |
| 149 if (!permissions || file.empty() || !file.IsAbsolute()) |
| 150 return false; |
| 149 FilePath current_path = file.StripTrailingSeparators(); | 151 FilePath current_path = file.StripTrailingSeparators(); |
| 150 FilePath last_path; | 152 FilePath last_path; |
| 151 int skip = 0; | 153 int skip = 0; |
| 152 while (current_path != last_path) { | 154 while (current_path != last_path) { |
| 153 FilePath base_name = current_path.BaseName(); | 155 FilePath base_name = current_path.BaseName(); |
| 154 if (base_name.value() == FilePath::kParentDirectory) { | 156 if (base_name.value() == FilePath::kParentDirectory) { |
| 155 ++skip; | 157 ++skip; |
| 156 } else if (skip > 0) { | 158 } else if (skip > 0) { |
| 157 if (base_name.value() != FilePath::kCurrentDirectory) | 159 if (base_name.value() != FilePath::kCurrentDirectory) |
| 158 --skip; | 160 --skip; |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 int permission) { | 700 int permission) { |
| 699 base::AutoLock lock(lock_); | 701 base::AutoLock lock(lock_); |
| 700 | 702 |
| 701 SecurityStateMap::iterator state = security_state_.find(child_id); | 703 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 702 if (state == security_state_.end()) | 704 if (state == security_state_.end()) |
| 703 return false; | 705 return false; |
| 704 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); | 706 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); |
| 705 } | 707 } |
| 706 | 708 |
| 707 } // namespace content | 709 } // namespace content |
| OLD | NEW |