| 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/file_manager/fileapi_util.h" | 5 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| 6 | 6 |
| 7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "chrome/browser/chromeos/drive/file_system_util.h" | 9 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 10 #include "chrome/browser/chromeos/file_manager/app_id.h" | 10 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 scoped_refptr<storage::FileSystemContext> file_system_context, | 222 scoped_refptr<storage::FileSystemContext> file_system_context, |
| 223 const GURL& url, | 223 const GURL& url, |
| 224 const storage::FileSystemOperationRunner::StatusCallback& callback) { | 224 const storage::FileSystemOperationRunner::StatusCallback& callback) { |
| 225 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 225 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 226 | 226 |
| 227 storage::FileSystemURL file_system_url = file_system_context->CrackURL(url); | 227 storage::FileSystemURL file_system_url = file_system_context->CrackURL(url); |
| 228 file_system_context->operation_runner()->DirectoryExists( | 228 file_system_context->operation_runner()->DirectoryExists( |
| 229 file_system_url, callback); | 229 file_system_url, callback); |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Used by GetMetadataForPath |
| 233 void GetMetadataOnIOThread( |
| 234 scoped_refptr<storage::FileSystemContext> file_system_context, |
| 235 const GURL& url, |
| 236 const storage::FileSystemOperationRunner::GetMetadataCallback& callback) { |
| 237 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 238 const storage::FileSystemURL file_system_url = |
| 239 file_system_context->CrackURL(url); |
| 240 file_system_context->operation_runner()->GetMetadata(file_system_url, |
| 241 callback); |
| 242 } |
| 243 |
| 232 // Checks if the |file_path| points non-native location or not. | 244 // Checks if the |file_path| points non-native location or not. |
| 233 bool IsUnderNonNativeLocalPath(const storage::FileSystemContext& context, | 245 bool IsUnderNonNativeLocalPath(const storage::FileSystemContext& context, |
| 234 const base::FilePath& file_path) { | 246 const base::FilePath& file_path) { |
| 235 base::FilePath virtual_path; | 247 base::FilePath virtual_path; |
| 236 if (!context.external_backend()->GetVirtualPath(file_path, &virtual_path)) | 248 if (!context.external_backend()->GetVirtualPath(file_path, &virtual_path)) |
| 237 return false; | 249 return false; |
| 238 | 250 |
| 239 const storage::FileSystemURL url = context.CreateCrackedFileSystemURL( | 251 const storage::FileSystemURL url = context.CreateCrackedFileSystemURL( |
| 240 GURL(), storage::kFileSystemTypeExternal, virtual_path); | 252 GURL(), storage::kFileSystemTypeExternal, virtual_path); |
| 241 if (!url.is_valid()) | 253 if (!url.is_valid()) |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 file_system_context->external_backend(); | 566 file_system_context->external_backend(); |
| 555 DCHECK(backend); | 567 DCHECK(backend); |
| 556 backend->GrantFullAccessToExtension(kFileManagerAppId); | 568 backend->GrantFullAccessToExtension(kFileManagerAppId); |
| 557 | 569 |
| 558 BrowserThread::PostTask( | 570 BrowserThread::PostTask( |
| 559 BrowserThread::IO, FROM_HERE, | 571 BrowserThread::IO, FROM_HERE, |
| 560 base::Bind(&CheckIfDirectoryExistsOnIOThread, file_system_context, url, | 572 base::Bind(&CheckIfDirectoryExistsOnIOThread, file_system_context, url, |
| 561 google_apis::CreateRelayCallback(callback))); | 573 google_apis::CreateRelayCallback(callback))); |
| 562 } | 574 } |
| 563 | 575 |
| 576 void GetMetadataForPath( |
| 577 scoped_refptr<storage::FileSystemContext> file_system_context, |
| 578 const GURL& url, |
| 579 const storage::FileSystemOperationRunner::GetMetadataCallback& callback) { |
| 580 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 581 |
| 582 storage::ExternalFileSystemBackend* const backend = |
| 583 file_system_context->external_backend(); |
| 584 DCHECK(backend); |
| 585 backend->GrantFullAccessToExtension(kFileManagerAppId); |
| 586 |
| 587 BrowserThread::PostTask( |
| 588 BrowserThread::IO, FROM_HERE, |
| 589 base::Bind(&GetMetadataOnIOThread, file_system_context, url, |
| 590 google_apis::CreateRelayCallback(callback))); |
| 591 } |
| 592 |
| 564 storage::FileSystemURL CreateIsolatedURLFromVirtualPath( | 593 storage::FileSystemURL CreateIsolatedURLFromVirtualPath( |
| 565 const storage::FileSystemContext& context, | 594 const storage::FileSystemContext& context, |
| 566 const GURL& origin, | 595 const GURL& origin, |
| 567 const base::FilePath& virtual_path) { | 596 const base::FilePath& virtual_path) { |
| 568 const storage::FileSystemURL original_url = | 597 const storage::FileSystemURL original_url = |
| 569 context.CreateCrackedFileSystemURL( | 598 context.CreateCrackedFileSystemURL( |
| 570 origin, storage::kFileSystemTypeExternal, virtual_path); | 599 origin, storage::kFileSystemTypeExternal, virtual_path); |
| 571 | 600 |
| 572 std::string register_name; | 601 std::string register_name; |
| 573 const std::string isolated_file_system_id = | 602 const std::string isolated_file_system_id = |
| 574 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 603 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 575 original_url.type(), | 604 original_url.type(), |
| 576 original_url.filesystem_id(), | 605 original_url.filesystem_id(), |
| 577 original_url.path(), | 606 original_url.path(), |
| 578 ®ister_name); | 607 ®ister_name); |
| 579 const storage::FileSystemURL isolated_url = | 608 const storage::FileSystemURL isolated_url = |
| 580 context.CreateCrackedFileSystemURL( | 609 context.CreateCrackedFileSystemURL( |
| 581 origin, | 610 origin, |
| 582 storage::kFileSystemTypeIsolated, | 611 storage::kFileSystemTypeIsolated, |
| 583 base::FilePath(isolated_file_system_id).Append(register_name)); | 612 base::FilePath(isolated_file_system_id).Append(register_name)); |
| 584 return isolated_url; | 613 return isolated_url; |
| 585 } | 614 } |
| 586 | 615 |
| 587 } // namespace util | 616 } // namespace util |
| 588 } // namespace file_manager | 617 } // namespace file_manager |
| OLD | NEW |