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> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ptr_util.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chromeos/drive/file_system_util.h" | 18 #include "chrome/browser/chromeos/drive/file_system_util.h" |
18 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 19 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
19 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 20 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
20 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 21 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
21 #include "chrome/browser/chromeos/file_manager/zip_file_creator.h" | 22 #include "chrome/browser/chromeos/file_manager/zip_file_creator.h" |
22 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" | 23 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 result.allow_redeem_offers = true; | 179 result.allow_redeem_offers = true; |
179 if (!chromeos::CrosSettings::Get()->GetBoolean( | 180 if (!chromeos::CrosSettings::Get()->GetBoolean( |
180 chromeos::kAllowRedeemChromeOsRegistrationOffers, | 181 chromeos::kAllowRedeemChromeOsRegistrationOffers, |
181 &result.allow_redeem_offers)) { | 182 &result.allow_redeem_offers)) { |
182 result.allow_redeem_offers = true; | 183 result.allow_redeem_offers = true; |
183 } | 184 } |
184 result.timezone = | 185 result.timezone = |
185 UTF16ToUTF8(chromeos::system::TimezoneSettings::GetInstance() | 186 UTF16ToUTF8(chromeos::system::TimezoneSettings::GetInstance() |
186 ->GetCurrentTimezoneID()); | 187 ->GetCurrentTimezoneID()); |
187 | 188 |
188 SetResult(result.ToValue().release()); | 189 SetResult(result.ToValue()); |
189 | 190 |
190 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); | 191 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); |
191 if (logger) | 192 if (logger) |
192 logger->Log(logging::LOG_INFO, "%s succeeded.", name()); | 193 logger->Log(logging::LOG_INFO, "%s succeeded.", name()); |
193 return true; | 194 return true; |
194 } | 195 } |
195 | 196 |
196 bool FileManagerPrivateSetPreferencesFunction::RunSync() { | 197 bool FileManagerPrivateSetPreferencesFunction::RunSync() { |
197 using extensions::api::file_manager_private::SetPreferences::Params; | 198 using extensions::api::file_manager_private::SetPreferences::Params; |
198 const std::unique_ptr<Params> params(Params::Create(*args_)); | 199 const std::unique_ptr<Params> params(Params::Create(*args_)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 271 |
271 (new file_manager::ZipFileCreator( | 272 (new file_manager::ZipFileCreator( |
272 base::Bind(&FileManagerPrivateInternalZipSelectionFunction::OnZipDone, | 273 base::Bind(&FileManagerPrivateInternalZipSelectionFunction::OnZipDone, |
273 this), | 274 this), |
274 src_dir, src_relative_paths, dest_file)) | 275 src_dir, src_relative_paths, dest_file)) |
275 ->Start(); | 276 ->Start(); |
276 return true; | 277 return true; |
277 } | 278 } |
278 | 279 |
279 void FileManagerPrivateInternalZipSelectionFunction::OnZipDone(bool success) { | 280 void FileManagerPrivateInternalZipSelectionFunction::OnZipDone(bool success) { |
280 SetResult(new base::FundamentalValue(success)); | 281 SetResult(base::MakeUnique<base::FundamentalValue>(success)); |
281 SendResponse(true); | 282 SendResponse(true); |
282 } | 283 } |
283 | 284 |
284 bool FileManagerPrivateZoomFunction::RunSync() { | 285 bool FileManagerPrivateZoomFunction::RunSync() { |
285 using extensions::api::file_manager_private::Zoom::Params; | 286 using extensions::api::file_manager_private::Zoom::Params; |
286 const std::unique_ptr<Params> params(Params::Create(*args_)); | 287 const std::unique_ptr<Params> params(Params::Create(*args_)); |
287 EXTENSION_FUNCTION_VALIDATE(params); | 288 EXTENSION_FUNCTION_VALIDATE(params); |
288 | 289 |
289 content::PageZoom zoom_type; | 290 content::PageZoom zoom_type; |
290 switch (params->operation) { | 291 switch (params->operation) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 void FileManagerPrivateRequestWebStoreAccessTokenFunction::OnAccessTokenFetched( | 352 void FileManagerPrivateRequestWebStoreAccessTokenFunction::OnAccessTokenFetched( |
352 google_apis::DriveApiErrorCode code, | 353 google_apis::DriveApiErrorCode code, |
353 const std::string& access_token) { | 354 const std::string& access_token) { |
354 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); | 355 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); |
355 | 356 |
356 if (code == google_apis::HTTP_SUCCESS) { | 357 if (code == google_apis::HTTP_SUCCESS) { |
357 DCHECK(auth_service_->HasAccessToken()); | 358 DCHECK(auth_service_->HasAccessToken()); |
358 DCHECK(access_token == auth_service_->access_token()); | 359 DCHECK(access_token == auth_service_->access_token()); |
359 if (logger) | 360 if (logger) |
360 logger->Log(logging::LOG_INFO, "CWS OAuth token fetch succeeded."); | 361 logger->Log(logging::LOG_INFO, "CWS OAuth token fetch succeeded."); |
361 SetResult(new base::StringValue(access_token)); | 362 SetResult(base::MakeUnique<base::StringValue>(access_token)); |
362 SendResponse(true); | 363 SendResponse(true); |
363 } else { | 364 } else { |
364 if (logger) { | 365 if (logger) { |
365 logger->Log(logging::LOG_ERROR, | 366 logger->Log(logging::LOG_ERROR, |
366 "CWS OAuth token fetch failed. (DriveApiErrorCode: %s)", | 367 "CWS OAuth token fetch failed. (DriveApiErrorCode: %s)", |
367 google_apis::DriveApiErrorCodeToString(code).c_str()); | 368 google_apis::DriveApiErrorCodeToString(code).c_str()); |
368 } | 369 } |
369 SetResult(base::Value::CreateNullValue()); | 370 SetResult(base::Value::CreateNullValue()); |
370 SendResponse(false); | 371 SendResponse(false); |
371 } | 372 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 app_file_handler_util::GetMimeTypeForLocalPath( | 453 app_file_handler_util::GetMimeTypeForLocalPath( |
453 GetProfile(), file_system_url.path(), | 454 GetProfile(), file_system_url.path(), |
454 base::Bind(&FileManagerPrivateInternalGetMimeTypeFunction::OnGetMimeType, | 455 base::Bind(&FileManagerPrivateInternalGetMimeTypeFunction::OnGetMimeType, |
455 this)); | 456 this)); |
456 | 457 |
457 return true; | 458 return true; |
458 } | 459 } |
459 | 460 |
460 void FileManagerPrivateInternalGetMimeTypeFunction::OnGetMimeType( | 461 void FileManagerPrivateInternalGetMimeTypeFunction::OnGetMimeType( |
461 const std::string& mimeType) { | 462 const std::string& mimeType) { |
462 SetResult(new base::StringValue(mimeType)); | 463 SetResult(base::MakeUnique<base::StringValue>(mimeType)); |
463 SendResponse(true); | 464 SendResponse(true); |
464 } | 465 } |
465 | 466 |
466 ExtensionFunction::ResponseAction | 467 ExtensionFunction::ResponseAction |
467 FileManagerPrivateIsPiexLoaderEnabledFunction::Run() { | 468 FileManagerPrivateIsPiexLoaderEnabledFunction::Run() { |
468 #if defined(OFFICIAL_BUILD) | 469 #if defined(OFFICIAL_BUILD) |
469 return RespondNow(OneArgument(new base::FundamentalValue(true))); | 470 return RespondNow(OneArgument(new base::FundamentalValue(true))); |
470 #else | 471 #else |
471 return RespondNow(OneArgument(new base::FundamentalValue(false))); | 472 return RespondNow(OneArgument(new base::FundamentalValue(false))); |
472 #endif | 473 #endif |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 base::File::Error result) { | 686 base::File::Error result) { |
686 if (result != base::File::FILE_OK) { | 687 if (result != base::File::FILE_OK) { |
687 Respond(Error("Failed to execute the action.")); | 688 Respond(Error("Failed to execute the action.")); |
688 return; | 689 return; |
689 } | 690 } |
690 | 691 |
691 Respond(NoArguments()); | 692 Respond(NoArguments()); |
692 } | 693 } |
693 | 694 |
694 } // namespace extensions | 695 } // namespace extensions |
OLD | NEW |