Index: chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc |
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc |
index 95900de4ff5606b13871cdf37eeb42767457ecd8..21c32ca5616f601277ca951c70c468d84da386be 100644 |
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc |
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc |
@@ -5,6 +5,7 @@ |
#include "chrome/browser/chromeos/extensions/file_manager/private_api_drive.h" |
#include <map> |
+#include <memory> |
#include <set> |
#include <utility> |
@@ -769,11 +770,11 @@ void FileManagerPrivateSearchDriveFunction::OnEntryDefinitionList( |
entries->Append(entry); |
} |
- base::DictionaryValue* result = new base::DictionaryValue(); |
+ std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
result->Set("entries", entries); |
result->SetString("nextFeed", next_link.spec()); |
- SetResult(result); |
+ SetResult(std::move(result)); |
SendResponse(true); |
} |
@@ -854,7 +855,7 @@ void FileManagerPrivateSearchDriveMetadataFunction::OnEntryDefinitionList( |
std::unique_ptr<drive::MetadataSearchResultVector> search_result_info_list, |
std::unique_ptr<EntryDefinitionList> entry_definition_list) { |
DCHECK_EQ(search_result_info_list->size(), entry_definition_list->size()); |
- base::ListValue* results_list = new base::ListValue(); |
+ std::unique_ptr<base::ListValue> results_list(new base::ListValue()); |
// Convert Drive files to something File API stack can understand. See |
// file_browser_handler_custom_bindings.cc and |
@@ -882,7 +883,7 @@ void FileManagerPrivateSearchDriveMetadataFunction::OnEntryDefinitionList( |
results_list->Append(result_dict); |
} |
- SetResult(results_list); |
+ SetResult(std::move(results_list)); |
SendResponse(true); |
} |
@@ -933,7 +934,7 @@ bool FileManagerPrivateRequestAccessTokenFunction::RunAsync() { |
if (!drive_service) { |
// DriveService is not available. |
- SetResult(new base::StringValue("")); |
+ SetResult(base::MakeUnique<base::StringValue>(std::string())); |
SendResponse(true); |
return true; |
} |
@@ -953,7 +954,7 @@ bool FileManagerPrivateRequestAccessTokenFunction::RunAsync() { |
void FileManagerPrivateRequestAccessTokenFunction::OnAccessTokenFetched( |
google_apis::DriveApiErrorCode code, |
const std::string& access_token) { |
- SetResult(new base::StringValue(access_token)); |
+ SetResult(base::MakeUnique<base::StringValue>(access_token)); |
SendResponse(true); |
} |
@@ -992,7 +993,7 @@ void FileManagerPrivateInternalGetShareUrlFunction::OnGetShareUrl( |
return; |
} |
- SetResult(new base::StringValue(share_url.spec())); |
+ SetResult(base::MakeUnique<base::StringValue>(share_url.spec())); |
SendResponse(true); |
} |
@@ -1068,7 +1069,8 @@ bool FileManagerPrivateInternalGetDownloadUrlFunction::RunAsync() { |
if (!file_system) { |
// |file_system| is NULL if Drive is disabled or not mounted. |
SetError("Drive is disabled or not mounted."); |
- SetResult(new base::StringValue("")); // Intentionally returns a blank. |
+ // Intentionally returns a blank. |
+ SetResult(base::MakeUnique<base::StringValue>(std::string())); |
return false; |
} |
@@ -1076,7 +1078,8 @@ bool FileManagerPrivateInternalGetDownloadUrlFunction::RunAsync() { |
render_frame_host(), GetProfile(), GURL(params->url)); |
if (!drive::util::IsUnderDriveMountPoint(path)) { |
SetError("The given file is not in Drive."); |
- SetResult(new base::StringValue("")); // Intentionally returns a blank. |
+ // Intentionally returns a blank. |
+ SetResult(base::MakeUnique<base::StringValue>(std::string())); |
return false; |
} |
base::FilePath file_path = drive::util::ExtractDrivePath(path); |
@@ -1096,7 +1099,8 @@ void FileManagerPrivateInternalGetDownloadUrlFunction::OnGetResourceEntry( |
if (error != drive::FILE_ERROR_OK) { |
SetError("Download Url for this item is not available."); |
- SetResult(new base::StringValue("")); // Intentionally returns a blank. |
+ // Intentionally returns a blank. |
+ SetResult(base::MakeUnique<base::StringValue>(std::string())); |
SendResponse(false); |
return; |
} |
@@ -1129,14 +1133,15 @@ void FileManagerPrivateInternalGetDownloadUrlFunction::OnTokenFetched( |
const std::string& access_token) { |
if (code != google_apis::HTTP_SUCCESS) { |
SetError("Not able to fetch the token."); |
- SetResult(new base::StringValue("")); // Intentionally returns a blank. |
+ // Intentionally returns a blank. |
+ SetResult(base::MakeUnique<base::StringValue>(std::string())); |
SendResponse(false); |
return; |
} |
const std::string url = |
download_url_.Resolve("?alt=media&access_token=" + access_token).spec(); |
- SetResult(new base::StringValue(url)); |
+ SetResult(base::MakeUnique<base::StringValue>(url)); |
SendResponse(true); |
} |