| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/fileapi/file_system_backend.h" | 5 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" | 10 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 std::string extension_id = url.origin().host(); | 160 std::string extension_id = url.origin().host(); |
| 161 // TODO(mtomasz): Temporarily whitelist TimeScapes. Remove this in M-31. | 161 // TODO(mtomasz): Temporarily whitelist TimeScapes. Remove this in M-31. |
| 162 // See: crbug.com/271946 | 162 // See: crbug.com/271946 |
| 163 if (extension_id == "mlbmkoenclnokonejhlfakkeabdlmpek" && | 163 if (extension_id == "mlbmkoenclnokonejhlfakkeabdlmpek" && |
| 164 url.type() == storage::kFileSystemTypeRestrictedNativeLocal) { | 164 url.type() == storage::kFileSystemTypeRestrictedNativeLocal) { |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 // Check first to make sure this extension has fileBrowserHander permissions. | 168 // Check first to make sure this extension has fileBrowserHander permissions. |
| 169 if (!special_storage_policy_ || | 169 if (!special_storage_policy_.get() || |
| 170 !special_storage_policy_->IsFileHandler(extension_id)) | 170 !special_storage_policy_->IsFileHandler(extension_id)) |
| 171 return false; | 171 return false; |
| 172 | 172 |
| 173 return file_access_permissions_->HasAccessPermission(extension_id, | 173 return file_access_permissions_->HasAccessPermission(extension_id, |
| 174 url.virtual_path()); | 174 url.virtual_path()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void FileSystemBackend::GrantFullAccessToExtension( | 177 void FileSystemBackend::GrantFullAccessToExtension( |
| 178 const std::string& extension_id) { | 178 const std::string& extension_id) { |
| 179 if (!special_storage_policy_) | 179 if (!special_storage_policy_.get()) |
| 180 return; | 180 return; |
| 181 if (!special_storage_policy_->IsFileHandler(extension_id)) { | 181 if (!special_storage_policy_->IsFileHandler(extension_id)) { |
| 182 NOTREACHED(); | 182 NOTREACHED(); |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 file_access_permissions_->GrantFullAccessPermission(extension_id); | 185 file_access_permissions_->GrantFullAccessPermission(extension_id); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void FileSystemBackend::GrantFileAccessToExtension( | 188 void FileSystemBackend::GrantFileAccessToExtension( |
| 189 const std::string& extension_id, const base::FilePath& virtual_path) { | 189 const std::string& extension_id, const base::FilePath& virtual_path) { |
| 190 if (!special_storage_policy_) | 190 if (!special_storage_policy_.get()) |
| 191 return; | 191 return; |
| 192 // All we care about here is access from extensions for now. | 192 // All we care about here is access from extensions for now. |
| 193 if (!special_storage_policy_->IsFileHandler(extension_id)) { | 193 if (!special_storage_policy_->IsFileHandler(extension_id)) { |
| 194 NOTREACHED(); | 194 NOTREACHED(); |
| 195 return; | 195 return; |
| 196 } | 196 } |
| 197 | 197 |
| 198 std::string id; | 198 std::string id; |
| 199 storage::FileSystemType type; | 199 storage::FileSystemType type; |
| 200 std::string cracked_id; | 200 std::string cracked_id; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 case storage::kFileSystemTypeRestrictedNativeLocal: | 410 case storage::kFileSystemTypeRestrictedNativeLocal: |
| 411 callback.Run(GURL()); | 411 callback.Run(GURL()); |
| 412 return; | 412 return; |
| 413 default: | 413 default: |
| 414 NOTREACHED(); | 414 NOTREACHED(); |
| 415 } | 415 } |
| 416 callback.Run(GURL()); | 416 callback.Run(GURL()); |
| 417 } | 417 } |
| 418 | 418 |
| 419 } // namespace chromeos | 419 } // namespace chromeos |
| OLD | NEW |