Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/chromeos/file_manager/fileapi_util.cc

Issue 352393002: Be explicit about target type in platform_util::OpenItem() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Catch up with changes to JSONStringValueSerializer and address CrOS comment Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 562
551 // Check the existence of directory using file system API implementation on 563 // Check the existence of directory using file system API implementation on
552 // behalf of the file manager app. We need to grant access beforehand. 564 // behalf of the file manager app. We need to grant access beforehand.
553 storage::ExternalFileSystemBackend* backend = 565 storage::ExternalFileSystemBackend* backend =
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, 572 base::Bind(&CheckIfDirectoryExistsOnIOThread, file_system_context, url,
561 file_system_context,
562 url,
563 google_apis::CreateRelayCallback(callback))); 573 google_apis::CreateRelayCallback(callback)));
564 } 574 }
565 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
566 storage::FileSystemURL CreateIsolatedURLFromVirtualPath( 593 storage::FileSystemURL CreateIsolatedURLFromVirtualPath(
567 const storage::FileSystemContext& context, 594 const storage::FileSystemContext& context,
568 const GURL& origin, 595 const GURL& origin,
569 const base::FilePath& virtual_path) { 596 const base::FilePath& virtual_path) {
570 const storage::FileSystemURL original_url = 597 const storage::FileSystemURL original_url =
571 context.CreateCrackedFileSystemURL( 598 context.CreateCrackedFileSystemURL(
572 origin, storage::kFileSystemTypeExternal, virtual_path); 599 origin, storage::kFileSystemTypeExternal, virtual_path);
573 600
574 std::string register_name; 601 std::string register_name;
575 const std::string isolated_file_system_id = 602 const std::string isolated_file_system_id =
576 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath( 603 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath(
577 original_url.type(), 604 original_url.type(),
578 original_url.filesystem_id(), 605 original_url.filesystem_id(),
579 original_url.path(), 606 original_url.path(),
580 &register_name); 607 &register_name);
581 const storage::FileSystemURL isolated_url = 608 const storage::FileSystemURL isolated_url =
582 context.CreateCrackedFileSystemURL( 609 context.CreateCrackedFileSystemURL(
583 origin, 610 origin,
584 storage::kFileSystemTypeIsolated, 611 storage::kFileSystemTypeIsolated,
585 base::FilePath(isolated_file_system_id).Append(register_name)); 612 base::FilePath(isolated_file_system_id).Append(register_name));
586 return isolated_url; 613 return isolated_url;
587 } 614 }
588 615
589 } // namespace util 616 } // namespace util
590 } // namespace file_manager 617 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/fileapi_util.h ('k') | chrome/browser/chromeos/file_manager/open_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698