Chromium Code Reviews| 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 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 #include "extensions/browser/event_router.h" | 72 #include "extensions/browser/event_router.h" |
| 73 #include "extensions/browser/extension_registry.h" | 73 #include "extensions/browser/extension_registry.h" |
| 74 #include "extensions/common/constants.h" | 74 #include "extensions/common/constants.h" |
| 75 #include "url/url_constants.h" | 75 #include "url/url_constants.h" |
| 76 #endif | 76 #endif |
| 77 | 77 |
| 78 using apps::SavedFileEntry; | 78 using apps::SavedFileEntry; |
| 79 using apps::SavedFilesService; | 79 using apps::SavedFilesService; |
| 80 using storage::IsolatedContext; | 80 using storage::IsolatedContext; |
| 81 | 81 |
| 82 const char kInvalidCallingPage[] = "Invalid calling page. This function can't " | 82 const char kInvalidCallingPage[] = |
| 83 "Invalid calling page. This function can't " | |
|
Devlin
2017/06/13 20:32:45
nit: git cl format can't fix the wrapping. Mind d
michaelpg
2017/06/13 20:39:46
It won't fit on one line. Wrapping before "page" m
Devlin
2017/06/13 20:42:16
sure. I'm fine with either logical or stylistic.
| |
| 83 "be called from a background page."; | 84 "be called from a background page."; |
| 84 const char kUserCancelled[] = "User cancelled"; | 85 const char kUserCancelled[] = "User cancelled"; |
| 85 const char kWritableFileErrorFormat[] = "Error opening %s"; | 86 const char kWritableFileErrorFormat[] = "Error opening %s"; |
| 86 const char kRequiresFileSystemWriteError[] = | 87 const char kRequiresFileSystemWriteError[] = |
| 87 "Operation requires fileSystem.write permission"; | 88 "Operation requires fileSystem.write permission"; |
| 88 const char kRequiresFileSystemDirectoryError[] = | 89 const char kRequiresFileSystemDirectoryError[] = |
| 89 "Operation requires fileSystem.directory permission"; | 90 "Operation requires fileSystem.directory permission"; |
| 90 const char kMultipleUnsupportedError[] = | 91 const char kMultipleUnsupportedError[] = |
| 91 "acceptsMultiple: true is only supported for 'openFile'"; | 92 "acceptsMultiple: true is only supported for 'openFile'"; |
| 92 const char kUnknownIdError[] = "Unknown id"; | 93 const char kUnknownIdError[] = "Unknown id"; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 *description = l10n_util::GetStringUTF16(description_id); | 177 *description = l10n_util::GetStringUTF16(description_id); |
| 177 | 178 |
| 178 return true; | 179 return true; |
| 179 } | 180 } |
| 180 | 181 |
| 181 // Key for the path of the directory of the file last chosen by the user in | 182 // Key for the path of the directory of the file last chosen by the user in |
| 182 // response to a chrome.fileSystem.chooseEntry() call. | 183 // response to a chrome.fileSystem.chooseEntry() call. |
| 183 const char kLastChooseEntryDirectory[] = "last_choose_file_directory"; | 184 const char kLastChooseEntryDirectory[] = "last_choose_file_directory"; |
| 184 | 185 |
| 185 const int kGraylistedPaths[] = { | 186 const int kGraylistedPaths[] = { |
| 186 base::DIR_HOME, | 187 base::DIR_HOME, |
| 187 #if defined(OS_WIN) | 188 #if defined(OS_WIN) |
| 188 base::DIR_PROGRAM_FILES, | 189 base::DIR_PROGRAM_FILES, base::DIR_PROGRAM_FILESX86, base::DIR_WINDOWS, |
| 189 base::DIR_PROGRAM_FILESX86, | |
| 190 base::DIR_WINDOWS, | |
| 191 #endif | 190 #endif |
| 192 }; | 191 }; |
| 193 | 192 |
| 194 typedef base::Callback<void(std::unique_ptr<base::File::Info>)> | 193 typedef base::Callback<void(std::unique_ptr<base::File::Info>)> |
| 195 FileInfoOptCallback; | 194 FileInfoOptCallback; |
| 196 | 195 |
| 197 // Passes optional file info to the UI thread depending on |result| and |info|. | 196 // Passes optional file info to the UI thread depending on |result| and |info|. |
| 198 void PassFileInfoToUIThread(const FileInfoOptCallback& callback, | 197 void PassFileInfoToUIThread(const FileInfoOptCallback& callback, |
| 199 base::File::Error result, | 198 base::File::Error result, |
| 200 const base::File::Info& info) { | 199 const base::File::Info& info) { |
| 201 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 200 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 202 std::unique_ptr<base::File::Info> file_info( | 201 std::unique_ptr<base::File::Info> file_info( |
| 203 result == base::File::FILE_OK ? new base::File::Info(info) : NULL); | 202 result == base::File::FILE_OK ? new base::File::Info(info) : NULL); |
| 204 content::BrowserThread::PostTask( | 203 content::BrowserThread::PostTask( |
| 205 content::BrowserThread::UI, FROM_HERE, | 204 content::BrowserThread::UI, FROM_HERE, |
| 206 base::BindOnce(callback, base::Passed(&file_info))); | 205 base::BindOnce(callback, base::Passed(&file_info))); |
| 207 } | 206 } |
| 208 | 207 |
| 209 // Gets a WebContents instance handle for a platform app hosted in | 208 // Gets a WebContents instance handle for a platform app hosted in |
| 210 // |render_frame_host|. If not found, then returns NULL. | 209 // |render_frame_host|. If not found, then returns NULL. |
| 211 content::WebContents* GetWebContentsForRenderFrameHost( | 210 content::WebContents* GetWebContentsForRenderFrameHost( |
| 212 Profile* profile, | 211 Profile* profile, |
| 213 content::RenderFrameHost* render_frame_host) { | 212 content::RenderFrameHost* render_frame_host) { |
| 214 content::WebContents* web_contents = | 213 content::WebContents* web_contents = |
| 215 content::WebContents::FromRenderFrameHost(render_frame_host); | 214 content::WebContents::FromRenderFrameHost(render_frame_host); |
| 216 // Check if there is an app window associated with the web contents; if not, | 215 // Check if there is an app window associated with the web contents; if not, |
| 217 // return null. | 216 // return null. |
| 218 return AppWindowRegistry::Get(profile) | 217 return AppWindowRegistry::Get(profile)->GetAppWindowForWebContents( |
| 219 ->GetAppWindowForWebContents(web_contents) | 218 web_contents) |
| 220 ? web_contents | 219 ? web_contents |
| 221 : nullptr; | 220 : nullptr; |
| 222 } | 221 } |
| 223 | 222 |
| 224 #if defined(OS_CHROMEOS) | 223 #if defined(OS_CHROMEOS) |
| 225 // Fills a list of volumes mounted in the system. | 224 // Fills a list of volumes mounted in the system. |
| 226 void FillVolumeList(Profile* profile, | 225 void FillVolumeList(Profile* profile, |
| 227 std::vector<api::file_system::Volume>* result) { | 226 std::vector<api::file_system::Volume>* result) { |
| 228 file_manager::VolumeManager* const volume_manager = | 227 file_manager::VolumeManager* const volume_manager = |
| 229 file_manager::VolumeManager::Get(profile); | 228 file_manager::VolumeManager::Get(profile); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 241 #endif | 240 #endif |
| 242 | 241 |
| 243 } // namespace | 242 } // namespace |
| 244 | 243 |
| 245 namespace file_system_api { | 244 namespace file_system_api { |
| 246 | 245 |
| 247 base::FilePath GetLastChooseEntryDirectory(const ExtensionPrefs* prefs, | 246 base::FilePath GetLastChooseEntryDirectory(const ExtensionPrefs* prefs, |
| 248 const std::string& extension_id) { | 247 const std::string& extension_id) { |
| 249 base::FilePath path; | 248 base::FilePath path; |
| 250 std::string string_path; | 249 std::string string_path; |
| 251 if (prefs->ReadPrefAsString(extension_id, | 250 if (prefs->ReadPrefAsString(extension_id, kLastChooseEntryDirectory, |
| 252 kLastChooseEntryDirectory, | |
| 253 &string_path)) { | 251 &string_path)) { |
| 254 path = base::FilePath::FromUTF8Unsafe(string_path); | 252 path = base::FilePath::FromUTF8Unsafe(string_path); |
| 255 } | 253 } |
| 256 return path; | 254 return path; |
| 257 } | 255 } |
| 258 | 256 |
| 259 void SetLastChooseEntryDirectory(ExtensionPrefs* prefs, | 257 void SetLastChooseEntryDirectory(ExtensionPrefs* prefs, |
| 260 const std::string& extension_id, | 258 const std::string& extension_id, |
| 261 const base::FilePath& path) { | 259 const base::FilePath& path) { |
| 262 prefs->UpdateExtensionPref(extension_id, kLastChooseEntryDirectory, | 260 prefs->UpdateExtensionPref(extension_id, kLastChooseEntryDirectory, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 351 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 354 result->Set("entries", base::MakeUnique<base::ListValue>()); | 352 result->Set("entries", base::MakeUnique<base::ListValue>()); |
| 355 result->SetBoolean("multiple", multiple_); | 353 result->SetBoolean("multiple", multiple_); |
| 356 return result; | 354 return result; |
| 357 } | 355 } |
| 358 | 356 |
| 359 void FileSystemEntryFunction::AddEntryToResult(const base::FilePath& path, | 357 void FileSystemEntryFunction::AddEntryToResult(const base::FilePath& path, |
| 360 const std::string& id_override, | 358 const std::string& id_override, |
| 361 base::DictionaryValue* result) { | 359 base::DictionaryValue* result) { |
| 362 GrantedFileEntry file_entry = app_file_handler_util::CreateFileEntry( | 360 GrantedFileEntry file_entry = app_file_handler_util::CreateFileEntry( |
| 363 GetProfile(), | 361 GetProfile(), extension(), render_frame_host()->GetProcess()->GetID(), |
| 364 extension(), | 362 path, is_directory_); |
| 365 render_frame_host()->GetProcess()->GetID(), | |
| 366 path, | |
| 367 is_directory_); | |
| 368 base::ListValue* entries; | 363 base::ListValue* entries; |
| 369 bool success = result->GetList("entries", &entries); | 364 bool success = result->GetList("entries", &entries); |
| 370 DCHECK(success); | 365 DCHECK(success); |
| 371 | 366 |
| 372 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 367 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
| 373 entry->SetString("fileSystemId", file_entry.filesystem_id); | 368 entry->SetString("fileSystemId", file_entry.filesystem_id); |
| 374 entry->SetString("baseName", file_entry.registered_name); | 369 entry->SetString("baseName", file_entry.registered_name); |
| 375 if (id_override.empty()) | 370 if (id_override.empty()) |
| 376 entry->SetString("id", file_entry.id); | 371 entry->SetString("id", file_entry.id); |
| 377 else | 372 else |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 base::BindOnce(&FileSystemGetWritableEntryFunction::SetIsDirectoryAsync, | 404 base::BindOnce(&FileSystemGetWritableEntryFunction::SetIsDirectoryAsync, |
| 410 this), | 405 this), |
| 411 base::BindOnce( | 406 base::BindOnce( |
| 412 &FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse, | 407 &FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse, |
| 413 this)); | 408 this)); |
| 414 return true; | 409 return true; |
| 415 } | 410 } |
| 416 | 411 |
| 417 void FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse() { | 412 void FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse() { |
| 418 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 413 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 419 if (is_directory_ && | 414 if (is_directory_ && !extension_->permissions_data()->HasAPIPermission( |
| 420 !extension_->permissions_data()->HasAPIPermission( | 415 APIPermission::kFileSystemDirectory)) { |
| 421 APIPermission::kFileSystemDirectory)) { | |
| 422 error_ = kRequiresFileSystemDirectoryError; | 416 error_ = kRequiresFileSystemDirectoryError; |
| 423 SendResponse(false); | 417 SendResponse(false); |
| 424 } | 418 } |
| 425 std::vector<base::FilePath> paths; | 419 std::vector<base::FilePath> paths; |
| 426 paths.push_back(path_); | 420 paths.push_back(path_); |
| 427 PrepareFilesForWritableApp(paths); | 421 PrepareFilesForWritableApp(paths); |
| 428 } | 422 } |
| 429 | 423 |
| 430 void FileSystemGetWritableEntryFunction::SetIsDirectoryAsync() { | 424 void FileSystemGetWritableEntryFunction::SetIsDirectoryAsync() { |
| 431 if (base::DirectoryExists(path_)) { | 425 if (base::DirectoryExists(path_)) { |
| 432 is_directory_ = true; | 426 is_directory_ = true; |
| 433 } | 427 } |
| 434 } | 428 } |
| 435 | 429 |
| 436 ExtensionFunction::ResponseAction FileSystemIsWritableEntryFunction::Run() { | 430 ExtensionFunction::ResponseAction FileSystemIsWritableEntryFunction::Run() { |
| 437 std::string filesystem_name; | 431 std::string filesystem_name; |
| 438 std::string filesystem_path; | 432 std::string filesystem_path; |
| 439 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); | 433 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); |
| 440 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); | 434 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); |
| 441 | 435 |
| 442 std::string filesystem_id; | 436 std::string filesystem_id; |
| 443 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) | 437 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) |
| 444 return RespondNow(Error(app_file_handler_util::kInvalidParameters)); | 438 return RespondNow(Error(app_file_handler_util::kInvalidParameters)); |
| 445 | 439 |
| 446 content::ChildProcessSecurityPolicy* policy = | 440 content::ChildProcessSecurityPolicy* policy = |
| 447 content::ChildProcessSecurityPolicy::GetInstance(); | 441 content::ChildProcessSecurityPolicy::GetInstance(); |
| 448 int renderer_id = render_frame_host()->GetProcess()->GetID(); | 442 int renderer_id = render_frame_host()->GetProcess()->GetID(); |
| 449 bool is_writable = policy->CanReadWriteFileSystem(renderer_id, | 443 bool is_writable = policy->CanReadWriteFileSystem(renderer_id, filesystem_id); |
| 450 filesystem_id); | |
| 451 | 444 |
| 452 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_writable))); | 445 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_writable))); |
| 453 } | 446 } |
| 454 | 447 |
| 455 // Handles showing a dialog to the user to ask for the filename for a file to | 448 // Handles showing a dialog to the user to ask for the filename for a file to |
| 456 // save or open. | 449 // save or open. |
| 457 class FileSystemChooseEntryFunction::FilePicker | 450 class FileSystemChooseEntryFunction::FilePicker |
| 458 : public ui::SelectFileDialog::Listener { | 451 : public ui::SelectFileDialog::Listener { |
| 459 public: | 452 public: |
| 460 FilePicker(FileSystemChooseEntryFunction* function, | 453 FilePicker(FileSystemChooseEntryFunction* function, |
| 461 content::WebContents* web_contents, | 454 content::WebContents* web_contents, |
| 462 const base::FilePath& suggested_name, | 455 const base::FilePath& suggested_name, |
| 463 const ui::SelectFileDialog::FileTypeInfo& file_type_info, | 456 const ui::SelectFileDialog::FileTypeInfo& file_type_info, |
| 464 ui::SelectFileDialog::Type picker_type) | 457 ui::SelectFileDialog::Type picker_type) |
| 465 : function_(function) { | 458 : function_(function) { |
| 466 select_file_dialog_ = ui::SelectFileDialog::Create( | 459 select_file_dialog_ = ui::SelectFileDialog::Create( |
| 467 this, new ChromeSelectFilePolicy(web_contents)); | 460 this, new ChromeSelectFilePolicy(web_contents)); |
| 468 gfx::NativeWindow owning_window = web_contents ? | 461 gfx::NativeWindow owning_window = |
| 469 platform_util::GetTopLevel(web_contents->GetNativeView()) : | 462 web_contents ? platform_util::GetTopLevel(web_contents->GetNativeView()) |
| 470 NULL; | 463 : NULL; |
| 471 | 464 |
| 472 if (g_skip_picker_for_test) { | 465 if (g_skip_picker_for_test) { |
| 473 if (g_use_suggested_path_for_test) { | 466 if (g_use_suggested_path_for_test) { |
| 474 content::BrowserThread::PostTask( | 467 content::BrowserThread::PostTask( |
| 475 content::BrowserThread::UI, FROM_HERE, | 468 content::BrowserThread::UI, FROM_HERE, |
| 476 base::BindOnce( | 469 base::BindOnce( |
| 477 &FileSystemChooseEntryFunction::FilePicker::FileSelected, | 470 &FileSystemChooseEntryFunction::FilePicker::FileSelected, |
| 478 base::Unretained(this), suggested_name, 1, | 471 base::Unretained(this), suggested_name, 1, |
| 479 static_cast<void*>(NULL))); | 472 static_cast<void*>(NULL))); |
| 480 } else if (g_path_to_be_picked_for_test) { | 473 } else if (g_path_to_be_picked_for_test) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 494 } else { | 487 } else { |
| 495 content::BrowserThread::PostTask( | 488 content::BrowserThread::PostTask( |
| 496 content::BrowserThread::UI, FROM_HERE, | 489 content::BrowserThread::UI, FROM_HERE, |
| 497 base::BindOnce(&FileSystemChooseEntryFunction::FilePicker:: | 490 base::BindOnce(&FileSystemChooseEntryFunction::FilePicker:: |
| 498 FileSelectionCanceled, | 491 FileSelectionCanceled, |
| 499 base::Unretained(this), static_cast<void*>(NULL))); | 492 base::Unretained(this), static_cast<void*>(NULL))); |
| 500 } | 493 } |
| 501 return; | 494 return; |
| 502 } | 495 } |
| 503 | 496 |
| 504 select_file_dialog_->SelectFile(picker_type, | 497 select_file_dialog_->SelectFile( |
| 505 base::string16(), | 498 picker_type, base::string16(), suggested_name, &file_type_info, 0, |
| 506 suggested_name, | 499 base::FilePath::StringType(), owning_window, NULL); |
| 507 &file_type_info, | |
| 508 0, | |
| 509 base::FilePath::StringType(), | |
| 510 owning_window, | |
| 511 NULL); | |
| 512 } | 500 } |
| 513 | 501 |
| 514 ~FilePicker() override {} | 502 ~FilePicker() override {} |
| 515 | 503 |
| 516 private: | 504 private: |
| 517 // ui::SelectFileDialog::Listener implementation. | 505 // ui::SelectFileDialog::Listener implementation. |
| 518 void FileSelected(const base::FilePath& path, | 506 void FileSelected(const base::FilePath& path, |
| 519 int index, | 507 int index, |
| 520 void* params) override { | 508 void* params) override { |
| 521 std::vector<base::FilePath> paths; | 509 std::vector<base::FilePath> paths; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 if (!web_contents) { | 568 if (!web_contents) { |
| 581 error_ = kInvalidCallingPage; | 569 error_ = kInvalidCallingPage; |
| 582 SendResponse(false); | 570 SendResponse(false); |
| 583 return; | 571 return; |
| 584 } | 572 } |
| 585 | 573 |
| 586 // The file picker will hold a reference to this function instance, preventing | 574 // The file picker will hold a reference to this function instance, preventing |
| 587 // its destruction (and subsequent sending of the function response) until the | 575 // its destruction (and subsequent sending of the function response) until the |
| 588 // user has selected a file or cancelled the picker. At that point, the picker | 576 // user has selected a file or cancelled the picker. At that point, the picker |
| 589 // will delete itself, which will also free the function instance. | 577 // will delete itself, which will also free the function instance. |
| 590 new FilePicker( | 578 new FilePicker(this, web_contents, initial_path_, file_type_info, |
| 591 this, web_contents, initial_path_, file_type_info, picker_type); | 579 picker_type); |
| 592 } | 580 } |
| 593 | 581 |
| 594 // static | 582 // static |
| 595 void FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 583 void FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
| 596 base::FilePath* path) { | 584 base::FilePath* path) { |
| 597 g_skip_picker_for_test = true; | 585 g_skip_picker_for_test = true; |
| 598 g_use_suggested_path_for_test = false; | 586 g_use_suggested_path_for_test = false; |
| 599 g_path_to_be_picked_for_test = path; | 587 g_path_to_be_picked_for_test = path; |
| 600 g_paths_to_be_picked_for_test = NULL; | 588 g_paths_to_be_picked_for_test = NULL; |
| 601 } | 589 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 g_allow_directory_access_for_test = false; | 628 g_allow_directory_access_for_test = false; |
| 641 } | 629 } |
| 642 | 630 |
| 643 // static | 631 // static |
| 644 void FileSystemChooseEntryFunction::StopSkippingDirectoryConfirmationForTest() { | 632 void FileSystemChooseEntryFunction::StopSkippingDirectoryConfirmationForTest() { |
| 645 g_skip_directory_confirmation_for_test = false; | 633 g_skip_directory_confirmation_for_test = false; |
| 646 } | 634 } |
| 647 | 635 |
| 648 // static | 636 // static |
| 649 void FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( | 637 void FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
| 650 const std::string& name, const base::FilePath& path) { | 638 const std::string& name, |
| 639 const base::FilePath& path) { | |
| 651 // For testing on Chrome OS, where to deal with remote and local paths | 640 // For testing on Chrome OS, where to deal with remote and local paths |
| 652 // smoothly, all accessed paths need to be registered in the list of | 641 // smoothly, all accessed paths need to be registered in the list of |
| 653 // external mount points. | 642 // external mount points. |
| 654 storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 643 storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
| 655 name, | 644 name, storage::kFileSystemTypeNativeLocal, |
| 656 storage::kFileSystemTypeNativeLocal, | 645 storage::FileSystemMountOption(), path); |
| 657 storage::FileSystemMountOption(), | |
| 658 path); | |
| 659 } | 646 } |
| 660 | 647 |
| 661 void FileSystemChooseEntryFunction::FilesSelected( | 648 void FileSystemChooseEntryFunction::FilesSelected( |
| 662 const std::vector<base::FilePath>& paths) { | 649 const std::vector<base::FilePath>& paths) { |
| 663 DCHECK(!paths.empty()); | 650 DCHECK(!paths.empty()); |
| 664 base::FilePath last_choose_directory; | 651 base::FilePath last_choose_directory; |
| 665 if (is_directory_) { | 652 if (is_directory_) { |
| 666 last_choose_directory = paths[0]; | 653 last_choose_directory = paths[0]; |
| 667 } else { | 654 } else { |
| 668 last_choose_directory = paths[0].DirName(); | 655 last_choose_directory = paths[0].DirName(); |
| 669 } | 656 } |
| 670 file_system_api::SetLastChooseEntryDirectory( | 657 file_system_api::SetLastChooseEntryDirectory( |
| 671 ExtensionPrefs::Get(GetProfile()), | 658 ExtensionPrefs::Get(GetProfile()), extension()->id(), |
| 672 extension()->id(), | |
| 673 last_choose_directory); | 659 last_choose_directory); |
| 674 if (is_directory_) { | 660 if (is_directory_) { |
| 675 // Get the WebContents for the app window to be the parent window of the | 661 // Get the WebContents for the app window to be the parent window of the |
| 676 // confirmation dialog if necessary. | 662 // confirmation dialog if necessary. |
| 677 content::WebContents* const web_contents = | 663 content::WebContents* const web_contents = |
| 678 GetWebContentsForRenderFrameHost(GetProfile(), render_frame_host()); | 664 GetWebContentsForRenderFrameHost(GetProfile(), render_frame_host()); |
| 679 if (!web_contents) { | 665 if (!web_contents) { |
| 680 error_ = kInvalidCallingPage; | 666 error_ = kInvalidCallingPage; |
| 681 SendResponse(false); | 667 SendResponse(false); |
| 682 return; | 668 return; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 | 757 |
| 772 void FileSystemChooseEntryFunction::BuildFileTypeInfo( | 758 void FileSystemChooseEntryFunction::BuildFileTypeInfo( |
| 773 ui::SelectFileDialog::FileTypeInfo* file_type_info, | 759 ui::SelectFileDialog::FileTypeInfo* file_type_info, |
| 774 const base::FilePath::StringType& suggested_extension, | 760 const base::FilePath::StringType& suggested_extension, |
| 775 const AcceptOptions* accepts, | 761 const AcceptOptions* accepts, |
| 776 const bool* acceptsAllTypes) { | 762 const bool* acceptsAllTypes) { |
| 777 file_type_info->include_all_files = true; | 763 file_type_info->include_all_files = true; |
| 778 if (acceptsAllTypes) | 764 if (acceptsAllTypes) |
| 779 file_type_info->include_all_files = *acceptsAllTypes; | 765 file_type_info->include_all_files = *acceptsAllTypes; |
| 780 | 766 |
| 781 bool need_suggestion = !file_type_info->include_all_files && | 767 bool need_suggestion = |
| 782 !suggested_extension.empty(); | 768 !file_type_info->include_all_files && !suggested_extension.empty(); |
| 783 | 769 |
| 784 if (accepts) { | 770 if (accepts) { |
| 785 for (const file_system::AcceptOption& option : *accepts) { | 771 for (const file_system::AcceptOption& option : *accepts) { |
| 786 base::string16 description; | 772 base::string16 description; |
| 787 std::vector<base::FilePath::StringType> extensions; | 773 std::vector<base::FilePath::StringType> extensions; |
| 788 | 774 |
| 789 if (!GetFileTypesFromAcceptOption(option, &extensions, &description)) | 775 if (!GetFileTypesFromAcceptOption(option, &extensions, &description)) |
| 790 continue; // No extensions were found. | 776 continue; // No extensions were found. |
| 791 | 777 |
| 792 file_type_info->extensions.push_back(extensions); | 778 file_type_info->extensions.push_back(extensions); |
| 793 file_type_info->extension_description_overrides.push_back(description); | 779 file_type_info->extension_description_overrides.push_back(description); |
| 794 | 780 |
| 795 // If we still need to find suggested_extension, hunt for it inside the | 781 // If we still need to find suggested_extension, hunt for it inside the |
| 796 // extensions returned from GetFileTypesFromAcceptOption. | 782 // extensions returned from GetFileTypesFromAcceptOption. |
| 797 if (need_suggestion && std::find(extensions.begin(), | 783 if (need_suggestion && |
| 798 extensions.end(), suggested_extension) != extensions.end()) { | 784 std::find(extensions.begin(), extensions.end(), |
| 785 suggested_extension) != extensions.end()) { | |
| 799 need_suggestion = false; | 786 need_suggestion = false; |
| 800 } | 787 } |
| 801 } | 788 } |
| 802 } | 789 } |
| 803 | 790 |
| 804 // If there's nothing in our accepted extension list or we couldn't find the | 791 // If there's nothing in our accepted extension list or we couldn't find the |
| 805 // suggested extension required, then default to accepting all types. | 792 // suggested extension required, then default to accepting all types. |
| 806 if (file_type_info->extensions.empty() || need_suggestion) | 793 if (file_type_info->extensions.empty() || need_suggestion) |
| 807 file_type_info->include_all_files = true; | 794 file_type_info->include_all_files = true; |
| 808 } | 795 } |
| 809 | 796 |
| 810 void FileSystemChooseEntryFunction::BuildSuggestion( | 797 void FileSystemChooseEntryFunction::BuildSuggestion( |
| 811 const std::string *opt_name, | 798 const std::string* opt_name, |
| 812 base::FilePath* suggested_name, | 799 base::FilePath* suggested_name, |
| 813 base::FilePath::StringType* suggested_extension) { | 800 base::FilePath::StringType* suggested_extension) { |
| 814 if (opt_name) { | 801 if (opt_name) { |
| 815 *suggested_name = base::FilePath::FromUTF8Unsafe(*opt_name); | 802 *suggested_name = base::FilePath::FromUTF8Unsafe(*opt_name); |
| 816 | 803 |
| 817 // Don't allow any path components; shorten to the base name. This should | 804 // Don't allow any path components; shorten to the base name. This should |
| 818 // result in a relative path, but in some cases may not. Clear the | 805 // result in a relative path, but in some cases may not. Clear the |
| 819 // suggestion for safety if this is the case. | 806 // suggestion for safety if this is the case. |
| 820 *suggested_name = suggested_name->BaseName(); | 807 *suggested_name = suggested_name->BaseName(); |
| 821 if (suggested_name->IsAbsolute()) | 808 if (suggested_name->IsAbsolute()) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 888 } | 875 } |
| 889 if (multiple_) { | 876 if (multiple_) { |
| 890 error_ = kMultipleUnsupportedError; | 877 error_ = kMultipleUnsupportedError; |
| 891 return false; | 878 return false; |
| 892 } | 879 } |
| 893 picker_type = ui::SelectFileDialog::SELECT_FOLDER; | 880 picker_type = ui::SelectFileDialog::SELECT_FOLDER; |
| 894 } | 881 } |
| 895 | 882 |
| 896 base::FilePath::StringType suggested_extension; | 883 base::FilePath::StringType suggested_extension; |
| 897 BuildSuggestion(options->suggested_name.get(), &suggested_name, | 884 BuildSuggestion(options->suggested_name.get(), &suggested_name, |
| 898 &suggested_extension); | 885 &suggested_extension); |
| 899 | 886 |
| 900 BuildFileTypeInfo(&file_type_info, suggested_extension, | 887 BuildFileTypeInfo(&file_type_info, suggested_extension, |
| 901 options->accepts.get(), options->accepts_all_types.get()); | 888 options->accepts.get(), options->accepts_all_types.get()); |
| 902 } | 889 } |
| 903 | 890 |
| 904 file_type_info.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH; | 891 file_type_info.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH; |
| 905 | 892 |
| 906 base::FilePath previous_path = file_system_api::GetLastChooseEntryDirectory( | 893 base::FilePath previous_path = file_system_api::GetLastChooseEntryDirectory( |
| 907 ExtensionPrefs::Get(GetProfile()), extension()->id()); | 894 ExtensionPrefs::Get(GetProfile()), extension()->id()); |
| 908 | 895 |
| 909 if (previous_path.empty()) { | 896 if (previous_path.empty()) { |
| 910 SetInitialPathAndShowPicker(previous_path, suggested_name, file_type_info, | 897 SetInitialPathAndShowPicker(previous_path, suggested_name, file_type_info, |
| 911 picker_type, false); | 898 picker_type, false); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 952 | 939 |
| 953 std::string filesystem_id; | 940 std::string filesystem_id; |
| 954 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) | 941 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) |
| 955 return false; | 942 return false; |
| 956 | 943 |
| 957 const GURL site = util::GetSiteForExtensionId(extension_id(), GetProfile()); | 944 const GURL site = util::GetSiteForExtensionId(extension_id(), GetProfile()); |
| 958 storage::FileSystemContext* const context = | 945 storage::FileSystemContext* const context = |
| 959 content::BrowserContext::GetStoragePartitionForSite(GetProfile(), site) | 946 content::BrowserContext::GetStoragePartitionForSite(GetProfile(), site) |
| 960 ->GetFileSystemContext(); | 947 ->GetFileSystemContext(); |
| 961 const storage::FileSystemURL url = context->CreateCrackedFileSystemURL( | 948 const storage::FileSystemURL url = context->CreateCrackedFileSystemURL( |
| 962 site, | 949 site, storage::kFileSystemTypeIsolated, |
| 963 storage::kFileSystemTypeIsolated, | |
| 964 IsolatedContext::GetInstance() | 950 IsolatedContext::GetInstance() |
| 965 ->CreateVirtualRootPath(filesystem_id) | 951 ->CreateVirtualRootPath(filesystem_id) |
| 966 .Append(base::FilePath::FromUTF8Unsafe(filesystem_path))); | 952 .Append(base::FilePath::FromUTF8Unsafe(filesystem_path))); |
| 967 | 953 |
| 968 content::BrowserThread::PostTask( | 954 content::BrowserThread::PostTask( |
| 969 content::BrowserThread::IO, FROM_HERE, | 955 content::BrowserThread::IO, FROM_HERE, |
| 970 base::BindOnce( | 956 base::BindOnce( |
| 971 base::IgnoreResult( | 957 base::IgnoreResult( |
| 972 &storage::FileSystemOperationRunner::GetMetadata), | 958 &storage::FileSystemOperationRunner::GetMetadata), |
| 973 context->operation_runner()->AsWeakPtr(), url, | 959 context->operation_runner()->AsWeakPtr(), url, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 987 void FileSystemRetainEntryFunction::RetainFileEntry( | 973 void FileSystemRetainEntryFunction::RetainFileEntry( |
| 988 const std::string& entry_id, | 974 const std::string& entry_id, |
| 989 const base::FilePath& path, | 975 const base::FilePath& path, |
| 990 std::unique_ptr<base::File::Info> file_info) { | 976 std::unique_ptr<base::File::Info> file_info) { |
| 991 if (!file_info) { | 977 if (!file_info) { |
| 992 SendResponse(false); | 978 SendResponse(false); |
| 993 return; | 979 return; |
| 994 } | 980 } |
| 995 | 981 |
| 996 SavedFilesService* saved_files_service = SavedFilesService::Get(GetProfile()); | 982 SavedFilesService* saved_files_service = SavedFilesService::Get(GetProfile()); |
| 997 saved_files_service->RegisterFileEntry( | 983 saved_files_service->RegisterFileEntry(extension_->id(), entry_id, path, |
| 998 extension_->id(), entry_id, path, file_info->is_directory); | 984 file_info->is_directory); |
| 999 saved_files_service->EnqueueFileEntry(extension_->id(), entry_id); | 985 saved_files_service->EnqueueFileEntry(extension_->id(), entry_id); |
| 1000 SendResponse(true); | 986 SendResponse(true); |
| 1001 } | 987 } |
| 1002 | 988 |
| 1003 ExtensionFunction::ResponseAction FileSystemIsRestorableFunction::Run() { | 989 ExtensionFunction::ResponseAction FileSystemIsRestorableFunction::Run() { |
| 1004 std::string entry_id; | 990 std::string entry_id; |
| 1005 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &entry_id)); | 991 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &entry_id)); |
| 1006 return RespondNow(OneArgument(base::MakeUnique<base::Value>( | 992 return RespondNow(OneArgument(base::MakeUnique<base::Value>( |
| 1007 SavedFilesService::Get(Profile::FromBrowserContext(browser_context())) | 993 SavedFilesService::Get(Profile::FromBrowserContext(browser_context())) |
| 1008 ->IsRegistered(extension_->id(), entry_id)))); | 994 ->IsRegistered(extension_->id(), entry_id)))); |
| 1009 } | 995 } |
| 1010 | 996 |
| 1011 bool FileSystemRestoreEntryFunction::RunAsync() { | 997 bool FileSystemRestoreEntryFunction::RunAsync() { |
| 1012 std::string entry_id; | 998 std::string entry_id; |
| 1013 bool needs_new_entry; | 999 bool needs_new_entry; |
| 1014 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &entry_id)); | 1000 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &entry_id)); |
| 1015 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &needs_new_entry)); | 1001 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &needs_new_entry)); |
| 1016 const SavedFileEntry* file_entry = SavedFilesService::Get( | 1002 const SavedFileEntry* file_entry = |
| 1017 GetProfile())->GetFileEntry(extension_->id(), entry_id); | 1003 SavedFilesService::Get(GetProfile()) |
| 1004 ->GetFileEntry(extension_->id(), entry_id); | |
| 1018 if (!file_entry) { | 1005 if (!file_entry) { |
| 1019 error_ = kUnknownIdError; | 1006 error_ = kUnknownIdError; |
| 1020 return false; | 1007 return false; |
| 1021 } | 1008 } |
| 1022 | 1009 |
| 1023 SavedFilesService::Get(GetProfile()) | 1010 SavedFilesService::Get(GetProfile()) |
| 1024 ->EnqueueFileEntry(extension_->id(), entry_id); | 1011 ->EnqueueFileEntry(extension_->id(), entry_id); |
| 1025 | 1012 |
| 1026 // Only create a new file entry if the renderer requests one. | 1013 // Only create a new file entry if the renderer requests one. |
| 1027 // |needs_new_entry| will be false if the renderer already has an Entry for | 1014 // |needs_new_entry| will be false if the renderer already has an Entry for |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 return RespondNow(Error(kNotSupportedOnCurrentPlatformError)); | 1048 return RespondNow(Error(kNotSupportedOnCurrentPlatformError)); |
| 1062 } | 1049 } |
| 1063 | 1050 |
| 1064 ExtensionFunction::ResponseAction FileSystemGetVolumeListFunction::Run() { | 1051 ExtensionFunction::ResponseAction FileSystemGetVolumeListFunction::Run() { |
| 1065 NOTIMPLEMENTED(); | 1052 NOTIMPLEMENTED(); |
| 1066 return RespondNow(Error(kNotSupportedOnCurrentPlatformError)); | 1053 return RespondNow(Error(kNotSupportedOnCurrentPlatformError)); |
| 1067 } | 1054 } |
| 1068 #else | 1055 #else |
| 1069 | 1056 |
| 1070 FileSystemRequestFileSystemFunction::FileSystemRequestFileSystemFunction() | 1057 FileSystemRequestFileSystemFunction::FileSystemRequestFileSystemFunction() |
| 1071 : chrome_details_(this) { | 1058 : chrome_details_(this) {} |
| 1072 } | |
| 1073 | 1059 |
| 1074 FileSystemRequestFileSystemFunction::~FileSystemRequestFileSystemFunction() { | 1060 FileSystemRequestFileSystemFunction::~FileSystemRequestFileSystemFunction() {} |
| 1075 } | |
| 1076 | 1061 |
| 1077 ExtensionFunction::ResponseAction FileSystemRequestFileSystemFunction::Run() { | 1062 ExtensionFunction::ResponseAction FileSystemRequestFileSystemFunction::Run() { |
| 1078 using api::file_system::RequestFileSystem::Params; | 1063 using api::file_system::RequestFileSystem::Params; |
| 1079 const std::unique_ptr<Params> params(Params::Create(*args_)); | 1064 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 1080 EXTENSION_FUNCTION_VALIDATE(params); | 1065 EXTENSION_FUNCTION_VALIDATE(params); |
| 1081 | 1066 |
| 1082 // Only kiosk apps in kiosk sessions can use this API. | 1067 // Only kiosk apps in kiosk sessions can use this API. |
| 1083 // Additionally it is enabled for whitelisted component extensions and apps. | 1068 // Additionally it is enabled for whitelisted component extensions and apps. |
| 1084 file_system_api::ConsentProviderDelegate consent_provider_delegate( | 1069 file_system_api::ConsentProviderDelegate consent_provider_delegate( |
| 1085 chrome_details_.GetProfile(), render_frame_host()); | 1070 chrome_details_.GetProfile(), render_frame_host()); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1103 | 1088 |
| 1104 base::WeakPtr<file_manager::Volume> volume = | 1089 base::WeakPtr<file_manager::Volume> volume = |
| 1105 volume_manager->FindVolumeById(params->options.volume_id); | 1090 volume_manager->FindVolumeById(params->options.volume_id); |
| 1106 if (!volume.get()) | 1091 if (!volume.get()) |
| 1107 return RespondNow(Error(kVolumeNotFoundError)); | 1092 return RespondNow(Error(kVolumeNotFoundError)); |
| 1108 | 1093 |
| 1109 const GURL site = | 1094 const GURL site = |
| 1110 util::GetSiteForExtensionId(extension_id(), chrome_details_.GetProfile()); | 1095 util::GetSiteForExtensionId(extension_id(), chrome_details_.GetProfile()); |
| 1111 scoped_refptr<storage::FileSystemContext> file_system_context = | 1096 scoped_refptr<storage::FileSystemContext> file_system_context = |
| 1112 content::BrowserContext::GetStoragePartitionForSite( | 1097 content::BrowserContext::GetStoragePartitionForSite( |
| 1113 chrome_details_.GetProfile(), site)->GetFileSystemContext(); | 1098 chrome_details_.GetProfile(), site) |
| 1099 ->GetFileSystemContext(); | |
| 1114 storage::ExternalFileSystemBackend* const backend = | 1100 storage::ExternalFileSystemBackend* const backend = |
| 1115 file_system_context->external_backend(); | 1101 file_system_context->external_backend(); |
| 1116 DCHECK(backend); | 1102 DCHECK(backend); |
| 1117 | 1103 |
| 1118 base::FilePath virtual_path; | 1104 base::FilePath virtual_path; |
| 1119 if (!backend->GetVirtualPath(volume->mount_path(), &virtual_path)) | 1105 if (!backend->GetVirtualPath(volume->mount_path(), &virtual_path)) |
| 1120 return RespondNow(Error(kSecurityError)); | 1106 return RespondNow(Error(kSecurityError)); |
| 1121 | 1107 |
| 1122 if (writable && (volume->is_read_only())) | 1108 if (writable && (volume->is_read_only())) |
| 1123 return RespondNow(Error(kSecurityError)); | 1109 return RespondNow(Error(kSecurityError)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1157 | 1143 |
| 1158 if (!volume.get()) { | 1144 if (!volume.get()) { |
| 1159 Respond(Error(kVolumeNotFoundError)); | 1145 Respond(Error(kVolumeNotFoundError)); |
| 1160 return; | 1146 return; |
| 1161 } | 1147 } |
| 1162 | 1148 |
| 1163 const GURL site = | 1149 const GURL site = |
| 1164 util::GetSiteForExtensionId(extension_id(), chrome_details_.GetProfile()); | 1150 util::GetSiteForExtensionId(extension_id(), chrome_details_.GetProfile()); |
| 1165 scoped_refptr<storage::FileSystemContext> file_system_context = | 1151 scoped_refptr<storage::FileSystemContext> file_system_context = |
| 1166 content::BrowserContext::GetStoragePartitionForSite( | 1152 content::BrowserContext::GetStoragePartitionForSite( |
| 1167 chrome_details_.GetProfile(), site)->GetFileSystemContext(); | 1153 chrome_details_.GetProfile(), site) |
| 1154 ->GetFileSystemContext(); | |
| 1168 storage::ExternalFileSystemBackend* const backend = | 1155 storage::ExternalFileSystemBackend* const backend = |
| 1169 file_system_context->external_backend(); | 1156 file_system_context->external_backend(); |
| 1170 DCHECK(backend); | 1157 DCHECK(backend); |
| 1171 | 1158 |
| 1172 base::FilePath virtual_path; | 1159 base::FilePath virtual_path; |
| 1173 if (!backend->GetVirtualPath(volume->mount_path(), &virtual_path)) { | 1160 if (!backend->GetVirtualPath(volume->mount_path(), &virtual_path)) { |
| 1174 Respond(Error(kSecurityError)); | 1161 Respond(Error(kSecurityError)); |
| 1175 return; | 1162 return; |
| 1176 } | 1163 } |
| 1177 | 1164 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1226 } | 1213 } |
| 1227 | 1214 |
| 1228 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 1215 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 1229 dict->SetString("file_system_id", file_system_id); | 1216 dict->SetString("file_system_id", file_system_id); |
| 1230 dict->SetString("file_system_path", register_name); | 1217 dict->SetString("file_system_path", register_name); |
| 1231 | 1218 |
| 1232 Respond(OneArgument(std::move(dict))); | 1219 Respond(OneArgument(std::move(dict))); |
| 1233 } | 1220 } |
| 1234 | 1221 |
| 1235 FileSystemGetVolumeListFunction::FileSystemGetVolumeListFunction() | 1222 FileSystemGetVolumeListFunction::FileSystemGetVolumeListFunction() |
| 1236 : chrome_details_(this) { | 1223 : chrome_details_(this) {} |
| 1237 } | |
| 1238 | 1224 |
| 1239 FileSystemGetVolumeListFunction::~FileSystemGetVolumeListFunction() { | 1225 FileSystemGetVolumeListFunction::~FileSystemGetVolumeListFunction() {} |
| 1240 } | |
| 1241 | 1226 |
| 1242 ExtensionFunction::ResponseAction FileSystemGetVolumeListFunction::Run() { | 1227 ExtensionFunction::ResponseAction FileSystemGetVolumeListFunction::Run() { |
| 1243 // Only kiosk apps in kiosk sessions can use this API. | 1228 // Only kiosk apps in kiosk sessions can use this API. |
| 1244 // Additionally it is enabled for whitelisted component extensions and apps. | 1229 // Additionally it is enabled for whitelisted component extensions and apps. |
| 1245 file_system_api::ConsentProviderDelegate consent_provider_delegate( | 1230 file_system_api::ConsentProviderDelegate consent_provider_delegate( |
| 1246 chrome_details_.GetProfile(), render_frame_host()); | 1231 chrome_details_.GetProfile(), render_frame_host()); |
| 1247 file_system_api::ConsentProvider consent_provider(&consent_provider_delegate); | 1232 file_system_api::ConsentProvider consent_provider(&consent_provider_delegate); |
| 1248 | 1233 |
| 1249 if (!consent_provider.IsGrantable(*extension())) | 1234 if (!consent_provider.IsGrantable(*extension())) |
| 1250 return RespondNow(Error(kNotSupportedOnNonKioskSessionError)); | 1235 return RespondNow(Error(kNotSupportedOnNonKioskSessionError)); |
| 1251 std::vector<api::file_system::Volume> result_volume_list; | 1236 std::vector<api::file_system::Volume> result_volume_list; |
| 1252 FillVolumeList(chrome_details_.GetProfile(), &result_volume_list); | 1237 FillVolumeList(chrome_details_.GetProfile(), &result_volume_list); |
| 1253 | 1238 |
| 1254 return RespondNow(ArgumentList( | 1239 return RespondNow(ArgumentList( |
| 1255 api::file_system::GetVolumeList::Results::Create(result_volume_list))); | 1240 api::file_system::GetVolumeList::Results::Create(result_volume_list))); |
| 1256 } | 1241 } |
| 1257 #endif | 1242 #endif |
| 1258 | 1243 |
| 1259 } // namespace extensions | 1244 } // namespace extensions |
| OLD | NEW |