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

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: Merge with trunk Created 5 years, 10 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 storage::FileSystemURL file_system_url = file_system_context->CrackURL(url);
mtomasz 2015/03/06 07:05:49 nit: Can be const.
asanka 2015/03/06 21:09:40 Done.
239 file_system_context->operation_runner()->GetMetadata(file_system_url,
240 callback);
241 }
242
232 // Checks if the |file_path| points non-native location or not. 243 // Checks if the |file_path| points non-native location or not.
233 bool IsUnderNonNativeLocalPath(const storage::FileSystemContext& context, 244 bool IsUnderNonNativeLocalPath(const storage::FileSystemContext& context,
234 const base::FilePath& file_path) { 245 const base::FilePath& file_path) {
235 base::FilePath virtual_path; 246 base::FilePath virtual_path;
236 if (!context.external_backend()->GetVirtualPath(file_path, &virtual_path)) 247 if (!context.external_backend()->GetVirtualPath(file_path, &virtual_path))
237 return false; 248 return false;
238 249
239 const storage::FileSystemURL url = context.CreateCrackedFileSystemURL( 250 const storage::FileSystemURL url = context.CreateCrackedFileSystemURL(
240 GURL(), storage::kFileSystemTypeExternal, virtual_path); 251 GURL(), storage::kFileSystemTypeExternal, virtual_path);
241 if (!url.is_valid()) 252 if (!url.is_valid())
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 561
551 // Check the existence of directory using file system API implementation on 562 // Check the existence of directory using file system API implementation on
552 // behalf of the file manager app. We need to grant access beforehand. 563 // behalf of the file manager app. We need to grant access beforehand.
553 storage::ExternalFileSystemBackend* backend = 564 storage::ExternalFileSystemBackend* backend =
554 file_system_context->external_backend(); 565 file_system_context->external_backend();
555 DCHECK(backend); 566 DCHECK(backend);
556 backend->GrantFullAccessToExtension(kFileManagerAppId); 567 backend->GrantFullAccessToExtension(kFileManagerAppId);
557 568
558 BrowserThread::PostTask( 569 BrowserThread::PostTask(
559 BrowserThread::IO, FROM_HERE, 570 BrowserThread::IO, FROM_HERE,
560 base::Bind(&CheckIfDirectoryExistsOnIOThread, 571 base::Bind(&CheckIfDirectoryExistsOnIOThread, file_system_context, url,
561 file_system_context,
562 url,
563 google_apis::CreateRelayCallback(callback))); 572 google_apis::CreateRelayCallback(callback)));
564 } 573 }
565 574
575 void GetMetadataForPath(
576 scoped_refptr<storage::FileSystemContext> file_system_context,
577 const GURL& url,
578 const storage::FileSystemOperationRunner::GetMetadataCallback& callback) {
579 DCHECK_CURRENTLY_ON(BrowserThread::UI);
580
581 storage::ExternalFileSystemBackend* backend =
mtomasz 2015/03/06 07:05:49 nit: Can be const.
asanka 2015/03/06 21:09:40 The GrantFullAccessToExtension() call requires |ba
mtomasz 2015/03/07 00:01:12 I meant: storage::ExternalFileSystemBackend* const
asanka 2015/03/07 00:37:00 Ah. Got it and done.
582 file_system_context->external_backend();
583 DCHECK(backend);
584 backend->GrantFullAccessToExtension(kFileManagerAppId);
585
586 BrowserThread::PostTask(
587 BrowserThread::IO, FROM_HERE,
588 base::Bind(&GetMetadataOnIOThread, file_system_context, url,
589 google_apis::CreateRelayCallback(callback)));
590 }
591
566 storage::FileSystemURL CreateIsolatedURLFromVirtualPath( 592 storage::FileSystemURL CreateIsolatedURLFromVirtualPath(
567 const storage::FileSystemContext& context, 593 const storage::FileSystemContext& context,
568 const GURL& origin, 594 const GURL& origin,
569 const base::FilePath& virtual_path) { 595 const base::FilePath& virtual_path) {
570 const storage::FileSystemURL original_url = 596 const storage::FileSystemURL original_url =
571 context.CreateCrackedFileSystemURL( 597 context.CreateCrackedFileSystemURL(
572 origin, storage::kFileSystemTypeExternal, virtual_path); 598 origin, storage::kFileSystemTypeExternal, virtual_path);
573 599
574 std::string register_name; 600 std::string register_name;
575 const std::string isolated_file_system_id = 601 const std::string isolated_file_system_id =
576 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath( 602 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath(
577 original_url.type(), 603 original_url.type(),
578 original_url.filesystem_id(), 604 original_url.filesystem_id(),
579 original_url.path(), 605 original_url.path(),
580 &register_name); 606 &register_name);
581 const storage::FileSystemURL isolated_url = 607 const storage::FileSystemURL isolated_url =
582 context.CreateCrackedFileSystemURL( 608 context.CreateCrackedFileSystemURL(
583 origin, 609 origin,
584 storage::kFileSystemTypeIsolated, 610 storage::kFileSystemTypeIsolated,
585 base::FilePath(isolated_file_system_id).Append(register_name)); 611 base::FilePath(isolated_file_system_id).Append(register_name));
586 return isolated_url; 612 return isolated_url;
587 } 613 }
588 614
589 } // namespace util 615 } // namespace util
590 } // namespace file_manager 616 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698