| OLD | NEW |
| 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/extensions/file_manager/private_api_misc.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_misc.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 SetResult(result.ToValue().release()); | 188 SetResult(result.ToValue().release()); |
| 189 | 189 |
| 190 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); | 190 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); |
| 191 if (logger) | 191 if (logger) |
| 192 logger->Log(logging::LOG_INFO, "%s succeeded.", name()); | 192 logger->Log(logging::LOG_INFO, "%s succeeded.", name()); |
| 193 return true; | 193 return true; |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool FileManagerPrivateSetPreferencesFunction::RunSync() { | 196 bool FileManagerPrivateSetPreferencesFunction::RunSync() { |
| 197 using extensions::api::file_manager_private::SetPreferences::Params; | 197 using extensions::api::file_manager_private::SetPreferences::Params; |
| 198 const scoped_ptr<Params> params(Params::Create(*args_)); | 198 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 199 EXTENSION_FUNCTION_VALIDATE(params); | 199 EXTENSION_FUNCTION_VALIDATE(params); |
| 200 | 200 |
| 201 PrefService* const service = GetProfile()->GetPrefs(); | 201 PrefService* const service = GetProfile()->GetPrefs(); |
| 202 | 202 |
| 203 if (params->change_info.cellular_disabled) | 203 if (params->change_info.cellular_disabled) |
| 204 service->SetBoolean(drive::prefs::kDisableDriveOverCellular, | 204 service->SetBoolean(drive::prefs::kDisableDriveOverCellular, |
| 205 *params->change_info.cellular_disabled); | 205 *params->change_info.cellular_disabled); |
| 206 | 206 |
| 207 if (params->change_info.hosted_files_disabled) | 207 if (params->change_info.hosted_files_disabled) |
| 208 service->SetBoolean(drive::prefs::kDisableDriveHostedFiles, | 208 service->SetBoolean(drive::prefs::kDisableDriveHostedFiles, |
| 209 *params->change_info.hosted_files_disabled); | 209 *params->change_info.hosted_files_disabled); |
| 210 | 210 |
| 211 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); | 211 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); |
| 212 if (logger) | 212 if (logger) |
| 213 logger->Log(logging::LOG_INFO, "%s succeeded.", name()); | 213 logger->Log(logging::LOG_INFO, "%s succeeded.", name()); |
| 214 return true; | 214 return true; |
| 215 } | 215 } |
| 216 | 216 |
| 217 FileManagerPrivateInternalZipSelectionFunction:: | 217 FileManagerPrivateInternalZipSelectionFunction:: |
| 218 FileManagerPrivateInternalZipSelectionFunction() {} | 218 FileManagerPrivateInternalZipSelectionFunction() {} |
| 219 | 219 |
| 220 FileManagerPrivateInternalZipSelectionFunction:: | 220 FileManagerPrivateInternalZipSelectionFunction:: |
| 221 ~FileManagerPrivateInternalZipSelectionFunction() {} | 221 ~FileManagerPrivateInternalZipSelectionFunction() {} |
| 222 | 222 |
| 223 bool FileManagerPrivateInternalZipSelectionFunction::RunAsync() { | 223 bool FileManagerPrivateInternalZipSelectionFunction::RunAsync() { |
| 224 using extensions::api::file_manager_private_internal::ZipSelection::Params; | 224 using extensions::api::file_manager_private_internal::ZipSelection::Params; |
| 225 const scoped_ptr<Params> params(Params::Create(*args_)); | 225 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 226 EXTENSION_FUNCTION_VALIDATE(params); | 226 EXTENSION_FUNCTION_VALIDATE(params); |
| 227 | 227 |
| 228 // First param is the parent directory URL. | 228 // First param is the parent directory URL. |
| 229 if (params->parent_url.empty()) | 229 if (params->parent_url.empty()) |
| 230 return false; | 230 return false; |
| 231 | 231 |
| 232 base::FilePath src_dir = file_manager::util::GetLocalPathFromURL( | 232 base::FilePath src_dir = file_manager::util::GetLocalPathFromURL( |
| 233 render_frame_host(), GetProfile(), GURL(params->parent_url)); | 233 render_frame_host(), GetProfile(), GURL(params->parent_url)); |
| 234 if (src_dir.empty()) | 234 if (src_dir.empty()) |
| 235 return false; | 235 return false; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 return true; | 276 return true; |
| 277 } | 277 } |
| 278 | 278 |
| 279 void FileManagerPrivateInternalZipSelectionFunction::OnZipDone(bool success) { | 279 void FileManagerPrivateInternalZipSelectionFunction::OnZipDone(bool success) { |
| 280 SetResult(new base::FundamentalValue(success)); | 280 SetResult(new base::FundamentalValue(success)); |
| 281 SendResponse(true); | 281 SendResponse(true); |
| 282 } | 282 } |
| 283 | 283 |
| 284 bool FileManagerPrivateZoomFunction::RunSync() { | 284 bool FileManagerPrivateZoomFunction::RunSync() { |
| 285 using extensions::api::file_manager_private::Zoom::Params; | 285 using extensions::api::file_manager_private::Zoom::Params; |
| 286 const scoped_ptr<Params> params(Params::Create(*args_)); | 286 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 287 EXTENSION_FUNCTION_VALIDATE(params); | 287 EXTENSION_FUNCTION_VALIDATE(params); |
| 288 | 288 |
| 289 content::PageZoom zoom_type; | 289 content::PageZoom zoom_type; |
| 290 switch (params->operation) { | 290 switch (params->operation) { |
| 291 case api::file_manager_private::ZOOM_OPERATION_TYPE_IN: | 291 case api::file_manager_private::ZOOM_OPERATION_TYPE_IN: |
| 292 zoom_type = content::PAGE_ZOOM_IN; | 292 zoom_type = content::PAGE_ZOOM_IN; |
| 293 break; | 293 break; |
| 294 case api::file_manager_private::ZOOM_OPERATION_TYPE_OUT: | 294 case api::file_manager_private::ZOOM_OPERATION_TYPE_OUT: |
| 295 zoom_type = content::PAGE_ZOOM_OUT; | 295 zoom_type = content::PAGE_ZOOM_OUT; |
| 296 break; | 296 break; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 results_ = api::file_manager_private::GetProfiles::Results::Create( | 389 results_ = api::file_manager_private::GetProfiles::Results::Create( |
| 390 profiles, current_profile_id.GetUserEmail(), | 390 profiles, current_profile_id.GetUserEmail(), |
| 391 display_profile_id.is_valid() ? display_profile_id.GetUserEmail() | 391 display_profile_id.is_valid() ? display_profile_id.GetUserEmail() |
| 392 : current_profile_id.GetUserEmail()); | 392 : current_profile_id.GetUserEmail()); |
| 393 return true; | 393 return true; |
| 394 } | 394 } |
| 395 | 395 |
| 396 bool FileManagerPrivateOpenInspectorFunction::RunSync() { | 396 bool FileManagerPrivateOpenInspectorFunction::RunSync() { |
| 397 using extensions::api::file_manager_private::OpenInspector::Params; | 397 using extensions::api::file_manager_private::OpenInspector::Params; |
| 398 const scoped_ptr<Params> params(Params::Create(*args_)); | 398 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 399 EXTENSION_FUNCTION_VALIDATE(params); | 399 EXTENSION_FUNCTION_VALIDATE(params); |
| 400 | 400 |
| 401 switch (params->type) { | 401 switch (params->type) { |
| 402 case extensions::api::file_manager_private::INSPECTION_TYPE_NORMAL: | 402 case extensions::api::file_manager_private::INSPECTION_TYPE_NORMAL: |
| 403 // Open inspector for foreground page. | 403 // Open inspector for foreground page. |
| 404 DevToolsWindow::OpenDevToolsWindow(GetSenderWebContents()); | 404 DevToolsWindow::OpenDevToolsWindow(GetSenderWebContents()); |
| 405 break; | 405 break; |
| 406 case extensions::api::file_manager_private::INSPECTION_TYPE_CONSOLE: | 406 case extensions::api::file_manager_private::INSPECTION_TYPE_CONSOLE: |
| 407 // Open inspector for foreground page and bring focus to the console. | 407 // Open inspector for foreground page and bring focus to the console. |
| 408 DevToolsWindow::OpenDevToolsWindow(GetSenderWebContents(), | 408 DevToolsWindow::OpenDevToolsWindow(GetSenderWebContents(), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 431 FileManagerPrivateInternalGetMimeTypeFunction:: | 431 FileManagerPrivateInternalGetMimeTypeFunction:: |
| 432 FileManagerPrivateInternalGetMimeTypeFunction() { | 432 FileManagerPrivateInternalGetMimeTypeFunction() { |
| 433 } | 433 } |
| 434 | 434 |
| 435 FileManagerPrivateInternalGetMimeTypeFunction:: | 435 FileManagerPrivateInternalGetMimeTypeFunction:: |
| 436 ~FileManagerPrivateInternalGetMimeTypeFunction() { | 436 ~FileManagerPrivateInternalGetMimeTypeFunction() { |
| 437 } | 437 } |
| 438 | 438 |
| 439 bool FileManagerPrivateInternalGetMimeTypeFunction::RunAsync() { | 439 bool FileManagerPrivateInternalGetMimeTypeFunction::RunAsync() { |
| 440 using extensions::api::file_manager_private_internal::GetMimeType::Params; | 440 using extensions::api::file_manager_private_internal::GetMimeType::Params; |
| 441 const scoped_ptr<Params> params(Params::Create(*args_)); | 441 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 442 EXTENSION_FUNCTION_VALIDATE(params); | 442 EXTENSION_FUNCTION_VALIDATE(params); |
| 443 | 443 |
| 444 // Convert file url to local path. | 444 // Convert file url to local path. |
| 445 const scoped_refptr<storage::FileSystemContext> file_system_context = | 445 const scoped_refptr<storage::FileSystemContext> file_system_context = |
| 446 file_manager::util::GetFileSystemContextForRenderFrameHost( | 446 file_manager::util::GetFileSystemContextForRenderFrameHost( |
| 447 GetProfile(), render_frame_host()); | 447 GetProfile(), render_frame_host()); |
| 448 | 448 |
| 449 storage::FileSystemURL file_system_url( | 449 storage::FileSystemURL file_system_url( |
| 450 file_system_context->CrackURL(GURL(params->url))); | 450 file_system_context->CrackURL(GURL(params->url))); |
| 451 | 451 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 } | 517 } |
| 518 | 518 |
| 519 FileManagerPrivateAddProvidedFileSystemFunction:: | 519 FileManagerPrivateAddProvidedFileSystemFunction:: |
| 520 FileManagerPrivateAddProvidedFileSystemFunction() | 520 FileManagerPrivateAddProvidedFileSystemFunction() |
| 521 : chrome_details_(this) { | 521 : chrome_details_(this) { |
| 522 } | 522 } |
| 523 | 523 |
| 524 ExtensionFunction::ResponseAction | 524 ExtensionFunction::ResponseAction |
| 525 FileManagerPrivateAddProvidedFileSystemFunction::Run() { | 525 FileManagerPrivateAddProvidedFileSystemFunction::Run() { |
| 526 using extensions::api::file_manager_private::AddProvidedFileSystem::Params; | 526 using extensions::api::file_manager_private::AddProvidedFileSystem::Params; |
| 527 const scoped_ptr<Params> params(Params::Create(*args_)); | 527 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 528 EXTENSION_FUNCTION_VALIDATE(params); | 528 EXTENSION_FUNCTION_VALIDATE(params); |
| 529 | 529 |
| 530 using chromeos::file_system_provider::Service; | 530 using chromeos::file_system_provider::Service; |
| 531 using chromeos::file_system_provider::ProvidingExtensionInfo; | 531 using chromeos::file_system_provider::ProvidingExtensionInfo; |
| 532 Service* const service = Service::Get(chrome_details_.GetProfile()); | 532 Service* const service = Service::Get(chrome_details_.GetProfile()); |
| 533 | 533 |
| 534 if (!service->RequestMount(params->extension_id)) | 534 if (!service->RequestMount(params->extension_id)) |
| 535 return RespondNow(Error("Failed to request a new mount.")); | 535 return RespondNow(Error("Failed to request a new mount.")); |
| 536 | 536 |
| 537 return RespondNow(NoArguments()); | 537 return RespondNow(NoArguments()); |
| 538 } | 538 } |
| 539 | 539 |
| 540 FileManagerPrivateConfigureVolumeFunction:: | 540 FileManagerPrivateConfigureVolumeFunction:: |
| 541 FileManagerPrivateConfigureVolumeFunction() | 541 FileManagerPrivateConfigureVolumeFunction() |
| 542 : chrome_details_(this) { | 542 : chrome_details_(this) { |
| 543 } | 543 } |
| 544 | 544 |
| 545 ExtensionFunction::ResponseAction | 545 ExtensionFunction::ResponseAction |
| 546 FileManagerPrivateConfigureVolumeFunction::Run() { | 546 FileManagerPrivateConfigureVolumeFunction::Run() { |
| 547 using extensions::api::file_manager_private::ConfigureVolume::Params; | 547 using extensions::api::file_manager_private::ConfigureVolume::Params; |
| 548 const scoped_ptr<Params> params(Params::Create(*args_)); | 548 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 549 EXTENSION_FUNCTION_VALIDATE(params); | 549 EXTENSION_FUNCTION_VALIDATE(params); |
| 550 | 550 |
| 551 using file_manager::VolumeManager; | 551 using file_manager::VolumeManager; |
| 552 using file_manager::Volume; | 552 using file_manager::Volume; |
| 553 VolumeManager* const volume_manager = | 553 VolumeManager* const volume_manager = |
| 554 VolumeManager::Get(chrome_details_.GetProfile()); | 554 VolumeManager::Get(chrome_details_.GetProfile()); |
| 555 base::WeakPtr<Volume> volume = | 555 base::WeakPtr<Volume> volume = |
| 556 volume_manager->FindVolumeById(params->volume_id); | 556 volume_manager->FindVolumeById(params->volume_id); |
| 557 if (!volume.get()) | 557 if (!volume.get()) |
| 558 return RespondNow(Error("Volume not found.")); | 558 return RespondNow(Error("Volume not found.")); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 } | 592 } |
| 593 | 593 |
| 594 FileManagerPrivateInternalGetCustomActionsFunction:: | 594 FileManagerPrivateInternalGetCustomActionsFunction:: |
| 595 FileManagerPrivateInternalGetCustomActionsFunction() | 595 FileManagerPrivateInternalGetCustomActionsFunction() |
| 596 : chrome_details_(this) {} | 596 : chrome_details_(this) {} |
| 597 | 597 |
| 598 ExtensionFunction::ResponseAction | 598 ExtensionFunction::ResponseAction |
| 599 FileManagerPrivateInternalGetCustomActionsFunction::Run() { | 599 FileManagerPrivateInternalGetCustomActionsFunction::Run() { |
| 600 using extensions::api::file_manager_private_internal::GetCustomActions:: | 600 using extensions::api::file_manager_private_internal::GetCustomActions:: |
| 601 Params; | 601 Params; |
| 602 const scoped_ptr<Params> params(Params::Create(*args_)); | 602 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 603 EXTENSION_FUNCTION_VALIDATE(params); | 603 EXTENSION_FUNCTION_VALIDATE(params); |
| 604 | 604 |
| 605 const scoped_refptr<storage::FileSystemContext> file_system_context = | 605 const scoped_refptr<storage::FileSystemContext> file_system_context = |
| 606 file_manager::util::GetFileSystemContextForRenderFrameHost( | 606 file_manager::util::GetFileSystemContextForRenderFrameHost( |
| 607 chrome_details_.GetProfile(), render_frame_host()); | 607 chrome_details_.GetProfile(), render_frame_host()); |
| 608 | 608 |
| 609 std::vector<base::FilePath> paths; | 609 std::vector<base::FilePath> paths; |
| 610 chromeos::file_system_provider::ProvidedFileSystemInterface* file_system = | 610 chromeos::file_system_provider::ProvidedFileSystemInterface* file_system = |
| 611 nullptr; | 611 nullptr; |
| 612 std::string error; | 612 std::string error; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 } | 648 } |
| 649 | 649 |
| 650 FileManagerPrivateInternalExecuteCustomActionFunction:: | 650 FileManagerPrivateInternalExecuteCustomActionFunction:: |
| 651 FileManagerPrivateInternalExecuteCustomActionFunction() | 651 FileManagerPrivateInternalExecuteCustomActionFunction() |
| 652 : chrome_details_(this) {} | 652 : chrome_details_(this) {} |
| 653 | 653 |
| 654 ExtensionFunction::ResponseAction | 654 ExtensionFunction::ResponseAction |
| 655 FileManagerPrivateInternalExecuteCustomActionFunction::Run() { | 655 FileManagerPrivateInternalExecuteCustomActionFunction::Run() { |
| 656 using extensions::api::file_manager_private_internal::ExecuteCustomAction:: | 656 using extensions::api::file_manager_private_internal::ExecuteCustomAction:: |
| 657 Params; | 657 Params; |
| 658 const scoped_ptr<Params> params(Params::Create(*args_)); | 658 const std::unique_ptr<Params> params(Params::Create(*args_)); |
| 659 EXTENSION_FUNCTION_VALIDATE(params); | 659 EXTENSION_FUNCTION_VALIDATE(params); |
| 660 | 660 |
| 661 const scoped_refptr<storage::FileSystemContext> file_system_context = | 661 const scoped_refptr<storage::FileSystemContext> file_system_context = |
| 662 file_manager::util::GetFileSystemContextForRenderFrameHost( | 662 file_manager::util::GetFileSystemContextForRenderFrameHost( |
| 663 chrome_details_.GetProfile(), render_frame_host()); | 663 chrome_details_.GetProfile(), render_frame_host()); |
| 664 | 664 |
| 665 std::vector<base::FilePath> paths; | 665 std::vector<base::FilePath> paths; |
| 666 chromeos::file_system_provider::ProvidedFileSystemInterface* file_system = | 666 chromeos::file_system_provider::ProvidedFileSystemInterface* file_system = |
| 667 nullptr; | 667 nullptr; |
| 668 std::string error; | 668 std::string error; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 685 base::File::Error result) { | 685 base::File::Error result) { |
| 686 if (result != base::File::FILE_OK) { | 686 if (result != base::File::FILE_OK) { |
| 687 Respond(Error("Failed to execute the action.")); | 687 Respond(Error("Failed to execute the action.")); |
| 688 return; | 688 return; |
| 689 } | 689 } |
| 690 | 690 |
| 691 Respond(NoArguments()); | 691 Respond(NoArguments()); |
| 692 } | 692 } |
| 693 | 693 |
| 694 } // namespace extensions | 694 } // namespace extensions |
| OLD | NEW |