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/chromeos/extensions/file_manager/file_browser_private_a
pi.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a
pi.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 registry->RegisterFunction<SelectFileFunction>(); | 566 registry->RegisterFunction<SelectFileFunction>(); |
567 registry->RegisterFunction<SelectFilesFunction>(); | 567 registry->RegisterFunction<SelectFilesFunction>(); |
568 registry->RegisterFunction<AddMountFunction>(); | 568 registry->RegisterFunction<AddMountFunction>(); |
569 registry->RegisterFunction<RemoveMountFunction>(); | 569 registry->RegisterFunction<RemoveMountFunction>(); |
570 registry->RegisterFunction<GetMountPointsFunction>(); | 570 registry->RegisterFunction<GetMountPointsFunction>(); |
571 registry->RegisterFunction<GetSizeStatsFunction>(); | 571 registry->RegisterFunction<GetSizeStatsFunction>(); |
572 registry->RegisterFunction<FormatDeviceFunction>(); | 572 registry->RegisterFunction<FormatDeviceFunction>(); |
573 registry->RegisterFunction<ViewFilesFunction>(); | 573 registry->RegisterFunction<ViewFilesFunction>(); |
574 registry->RegisterFunction<GetDriveEntryPropertiesFunction>(); | 574 registry->RegisterFunction<GetDriveEntryPropertiesFunction>(); |
575 registry->RegisterFunction<PinDriveFileFunction>(); | 575 registry->RegisterFunction<PinDriveFileFunction>(); |
576 registry->RegisterFunction<GetFileLocationsFunction>(); | |
577 registry->RegisterFunction<GetDriveFilesFunction>(); | 576 registry->RegisterFunction<GetDriveFilesFunction>(); |
578 registry->RegisterFunction<CancelFileTransfersFunction>(); | 577 registry->RegisterFunction<CancelFileTransfersFunction>(); |
579 registry->RegisterFunction<TransferFileFunction>(); | 578 registry->RegisterFunction<TransferFileFunction>(); |
580 registry->RegisterFunction<GetPreferencesFunction>(); | 579 registry->RegisterFunction<GetPreferencesFunction>(); |
581 registry->RegisterFunction<SetPreferencesFunction>(); | 580 registry->RegisterFunction<SetPreferencesFunction>(); |
582 registry->RegisterFunction<SearchDriveFunction>(); | 581 registry->RegisterFunction<SearchDriveFunction>(); |
583 registry->RegisterFunction<SearchDriveMetadataFunction>(); | 582 registry->RegisterFunction<SearchDriveMetadataFunction>(); |
584 registry->RegisterFunction<ClearDriveCacheFunction>(); | 583 registry->RegisterFunction<ClearDriveCacheFunction>(); |
585 registry->RegisterFunction<ReloadDriveFunction>(); | 584 registry->RegisterFunction<ReloadDriveFunction>(); |
586 registry->RegisterFunction<GetDriveConnectionStateFunction>(); | 585 registry->RegisterFunction<GetDriveConnectionStateFunction>(); |
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2466 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2468 | 2467 |
2469 if (error == drive::FILE_ERROR_OK) { | 2468 if (error == drive::FILE_ERROR_OK) { |
2470 SendResponse(true); | 2469 SendResponse(true); |
2471 } else { | 2470 } else { |
2472 error_ = drive::FileErrorToString(error); | 2471 error_ = drive::FileErrorToString(error); |
2473 SendResponse(false); | 2472 SendResponse(false); |
2474 } | 2473 } |
2475 } | 2474 } |
2476 | 2475 |
2477 GetFileLocationsFunction::GetFileLocationsFunction() { | |
2478 } | |
2479 | |
2480 GetFileLocationsFunction::~GetFileLocationsFunction() { | |
2481 } | |
2482 | |
2483 bool GetFileLocationsFunction::RunImpl() { | |
2484 ListValue* file_urls_as_strings = NULL; | |
2485 if (!args_->GetList(0, &file_urls_as_strings)) | |
2486 return false; | |
2487 | |
2488 content::SiteInstance* site_instance = render_view_host()->GetSiteInstance(); | |
2489 scoped_refptr<fileapi::FileSystemContext> file_system_context = | |
2490 BrowserContext::GetStoragePartition(profile(), site_instance)-> | |
2491 GetFileSystemContext(); | |
2492 | |
2493 // Convert the list of strings to a list of GURLs. | |
2494 scoped_ptr<ListValue> locations(new ListValue); | |
2495 for (size_t i = 0; i < file_urls_as_strings->GetSize(); ++i) { | |
2496 std::string file_url_as_string; | |
2497 if (!file_urls_as_strings->GetString(i, &file_url_as_string)) | |
2498 return false; | |
2499 | |
2500 fileapi::FileSystemURL url( | |
2501 file_system_context->CrackURL(GURL(file_url_as_string))); | |
2502 if (url.type() == fileapi::kFileSystemTypeDrive) | |
2503 locations->Append(new base::StringValue("drive")); | |
2504 else | |
2505 locations->Append(new base::StringValue("local")); | |
2506 } | |
2507 | |
2508 SetResult(locations.release()); | |
2509 SendResponse(true); | |
2510 return true; | |
2511 } | |
2512 | |
2513 GetDriveFilesFunction::GetDriveFilesFunction() | 2476 GetDriveFilesFunction::GetDriveFilesFunction() |
2514 : local_paths_(NULL) { | 2477 : local_paths_(NULL) { |
2515 } | 2478 } |
2516 | 2479 |
2517 GetDriveFilesFunction::~GetDriveFilesFunction() { | 2480 GetDriveFilesFunction::~GetDriveFilesFunction() { |
2518 } | 2481 } |
2519 | 2482 |
2520 bool GetDriveFilesFunction::RunImpl() { | 2483 bool GetDriveFilesFunction::RunImpl() { |
2521 ListValue* file_urls_as_strings = NULL; | 2484 ListValue* file_urls_as_strings = NULL; |
2522 if (!args_->GetList(0, &file_urls_as_strings)) | 2485 if (!args_->GetList(0, &file_urls_as_strings)) |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3148 OpenNewWindowFunction::OpenNewWindowFunction() {} | 3111 OpenNewWindowFunction::OpenNewWindowFunction() {} |
3149 | 3112 |
3150 OpenNewWindowFunction::~OpenNewWindowFunction() {} | 3113 OpenNewWindowFunction::~OpenNewWindowFunction() {} |
3151 | 3114 |
3152 bool OpenNewWindowFunction::RunImpl() { | 3115 bool OpenNewWindowFunction::RunImpl() { |
3153 std::string url; | 3116 std::string url; |
3154 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); | 3117 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
3155 file_manager_util::OpenNewWindow(profile_, GURL(url)); | 3118 file_manager_util::OpenNewWindow(profile_, GURL(url)); |
3156 return true; | 3119 return true; |
3157 } | 3120 } |
OLD | NEW |