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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 external_provider->GetVirtualPath(full_path_, &virtual_path_); | 375 external_provider->GetVirtualPath(full_path_, &virtual_path_); |
376 DCHECK(!virtual_path_.empty()); | 376 DCHECK(!virtual_path_.empty()); |
377 | 377 |
378 // Grant access to this particular file to target extension. This will | 378 // Grant access to this particular file to target extension. This will |
379 // ensure that the target extension can access only this FS entry and | 379 // ensure that the target extension can access only this FS entry and |
380 // prevent from traversing FS hierarchy upward. | 380 // prevent from traversing FS hierarchy upward. |
381 external_provider->GrantFileAccessToExtension(extension_id(), virtual_path_); | 381 external_provider->GrantFileAccessToExtension(extension_id(), virtual_path_); |
382 | 382 |
383 // Grant access to the selected file to target extensions render view process. | 383 // Grant access to the selected file to target extensions render view process. |
384 content::ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 384 content::ChildProcessSecurityPolicy::GetInstance()->GrantCreateReadWriteFile( |
385 render_view_host()->GetProcess()->GetID(), | 385 render_view_host()->GetProcess()->GetID(), full_path_); |
386 full_path_, | |
387 file_handler_util::GetReadWritePermissions()); | |
388 } | 386 } |
389 | 387 |
390 void FileBrowserHandlerInternalSelectFileFunction::Respond(bool success) { | 388 void FileBrowserHandlerInternalSelectFileFunction::Respond(bool success) { |
391 scoped_ptr<SelectFile::Results::Result> result( | 389 scoped_ptr<SelectFile::Results::Result> result( |
392 new SelectFile::Results::Result()); | 390 new SelectFile::Results::Result()); |
393 result->success = success; | 391 result->success = success; |
394 | 392 |
395 // If the file was selected, add 'entry' object which will be later used to | 393 // If the file was selected, add 'entry' object which will be later used to |
396 // create a FileEntry instance for the selected file. | 394 // create a FileEntry instance for the selected file. |
397 if (success) { | 395 if (success) { |
398 result->entry.reset(new FileEntryInfo()); | 396 result->entry.reset(new FileEntryInfo()); |
399 result->entry->file_system_name = file_system_name_; | 397 result->entry->file_system_name = file_system_name_; |
400 result->entry->file_system_root = file_system_root_.spec(); | 398 result->entry->file_system_root = file_system_root_.spec(); |
401 result->entry->file_full_path = "/" + virtual_path_.AsUTF8Unsafe(); | 399 result->entry->file_full_path = "/" + virtual_path_.AsUTF8Unsafe(); |
402 result->entry->file_is_directory = false; | 400 result->entry->file_is_directory = false; |
403 } | 401 } |
404 | 402 |
405 results_ = SelectFile::Results::Create(*result); | 403 results_ = SelectFile::Results::Create(*result); |
406 SendResponse(true); | 404 SendResponse(true); |
407 } | 405 } |
OLD | NEW |