| 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 // The file contains the implementation of | 5 // The file contains the implementation of |
| 6 // fileBrowserHandlerInternal.selectFile extension function. | 6 // fileBrowserHandlerInternal.selectFile extension function. |
| 7 // When invoked, the function does the following: | 7 // When invoked, the function does the following: |
| 8 // - Verifies that the extension function was invoked as a result of user | 8 // - Verifies that the extension function was invoked as a result of user |
| 9 // gesture. | 9 // gesture. |
| 10 // - Display 'save as' dialog using FileSelectorImpl which waits for the user | 10 // - Display 'save as' dialog using FileSelectorImpl which waits for the user |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 // ensure that the target extension can access only this FS entry and | 376 // ensure that the target extension can access only this FS entry and |
| 377 // prevent from traversing FS hierarchy upward. | 377 // prevent from traversing FS hierarchy upward. |
| 378 external_provider->GrantFileAccessToExtension(extension_id(), virtual_path_); | 378 external_provider->GrantFileAccessToExtension(extension_id(), virtual_path_); |
| 379 | 379 |
| 380 // Add read write permissions for the selected file's virtual path to the list | 380 // Add read write permissions for the selected file's virtual path to the list |
| 381 // of permissions that have to be granted. | 381 // of permissions that have to be granted. |
| 382 permissions_to_grant_.push_back(std::make_pair( | 382 permissions_to_grant_.push_back(std::make_pair( |
| 383 full_path_, | 383 full_path_, |
| 384 file_handler_util::GetReadWritePermissions())); | 384 file_handler_util::GetReadWritePermissions())); |
| 385 | 385 |
| 386 if (!gdata::util::IsUnderDriveMountPoint(full_path_)) { | 386 if (!drive::util::IsUnderDriveMountPoint(full_path_)) { |
| 387 // If the file is not on drive, we have to only grant permission for the | 387 // If the file is not on drive, we have to only grant permission for the |
| 388 // file's virtual path. | 388 // file's virtual path. |
| 389 OnGotPermissionsToGrant(); | 389 OnGotPermissionsToGrant(); |
| 390 return; | 390 return; |
| 391 } | 391 } |
| 392 | 392 |
| 393 // For drive files, we also have to grant permissions for drive cache paths | 393 // For drive files, we also have to grant permissions for drive cache paths |
| 394 // under which the selected path could be kept. | 394 // under which the selected path could be kept. |
| 395 scoped_ptr<std::vector<FilePath> > gdata_paths(new std::vector<FilePath>()); | 395 scoped_ptr<std::vector<FilePath> > gdata_paths(new std::vector<FilePath>()); |
| 396 gdata_paths->push_back(virtual_path_); | 396 gdata_paths->push_back(virtual_path_); |
| 397 | 397 |
| 398 gdata::util::InsertDriveCachePathsPermissions( | 398 drive::util::InsertDriveCachePathsPermissions( |
| 399 profile(), | 399 profile(), |
| 400 gdata_paths.Pass(), | 400 gdata_paths.Pass(), |
| 401 &permissions_to_grant_, | 401 &permissions_to_grant_, |
| 402 base::Bind(&FileHandlerSelectFileFunction::OnGotPermissionsToGrant, | 402 base::Bind(&FileHandlerSelectFileFunction::OnGotPermissionsToGrant, |
| 403 this)); | 403 this)); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void FileHandlerSelectFileFunction::OnGotPermissionsToGrant() { | 406 void FileHandlerSelectFileFunction::OnGotPermissionsToGrant() { |
| 407 // At this point all needed permissions should be collected, so let's grant | 407 // At this point all needed permissions should be collected, so let's grant |
| 408 // them. | 408 // them. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 427 result->entry.reset(new FileEntryInfo()); | 427 result->entry.reset(new FileEntryInfo()); |
| 428 result->entry->file_system_name = file_system_name_; | 428 result->entry->file_system_name = file_system_name_; |
| 429 result->entry->file_system_root = file_system_root_.spec(); | 429 result->entry->file_system_root = file_system_root_.spec(); |
| 430 result->entry->file_full_path = "/" + virtual_path_.value(); | 430 result->entry->file_full_path = "/" + virtual_path_.value(); |
| 431 result->entry->file_is_directory = false; | 431 result->entry->file_is_directory = false; |
| 432 } | 432 } |
| 433 | 433 |
| 434 results_ = SelectFile::Results::Create(*result); | 434 results_ = SelectFile::Results::Create(*result); |
| 435 SendResponse(true); | 435 SendResponse(true); |
| 436 } | 436 } |
| OLD | NEW |