Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1918)

Unified Diff: components/proximity_auth/webui/proximity_auth_webui_handler.cc

Issue 1912433002: Convert //components/proximity_auth from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/proximity_auth/webui/proximity_auth_webui_handler.cc
diff --git a/components/proximity_auth/webui/proximity_auth_webui_handler.cc b/components/proximity_auth/webui/proximity_auth_webui_handler.cc
index 80ab97ee5596947764948a97d5c368f58f9bbeb1..b35457c8d440e84962dc478553aac19c7ed26aa2 100644
--- a/components/proximity_auth/webui/proximity_auth_webui_handler.cc
+++ b/components/proximity_auth/webui/proximity_auth_webui_handler.cc
@@ -10,6 +10,7 @@
#include "base/base64url.h"
#include "base/bind.h"
#include "base/i18n/time_formatting.h"
+#include "base/memory/ptr_util.h"
#include "base/thread_task_runner_handle.h"
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
@@ -51,9 +52,10 @@ const char kSyncStateOperationInProgress[] = "operationInProgress";
// Converts |log_message| to a raw dictionary value used as a JSON argument to
// JavaScript functions.
-scoped_ptr<base::DictionaryValue> LogMessageToDictionary(
+std::unique_ptr<base::DictionaryValue> LogMessageToDictionary(
const LogBuffer::LogMessage& log_message) {
- scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> dictionary(
+ new base::DictionaryValue());
dictionary->SetString(kLogMessageTextKey, log_message.text);
dictionary->SetString(
kLogMessageTimeKey,
@@ -82,12 +84,13 @@ const char kExternalDeviceConnecting[] = "connecting";
const char kIneligibleDeviceReasons[] = "ineligibilityReasons";
// Creates a SyncState JSON object that can be passed to the WebUI.
-scoped_ptr<base::DictionaryValue> CreateSyncStateDictionary(
+std::unique_ptr<base::DictionaryValue> CreateSyncStateDictionary(
double last_success_time,
double next_refresh_time,
bool is_recovering_from_failure,
bool is_enrollment_in_progress) {
- scoped_ptr<base::DictionaryValue> sync_state(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> sync_state(
+ new base::DictionaryValue());
sync_state->SetDouble(kSyncStateLastSuccessTime, last_success_time);
sync_state->SetDouble(kSyncStateNextRefreshTime, next_refresh_time);
sync_state->SetBoolean(kSyncStateRecoveringFromFailure,
@@ -160,7 +163,7 @@ void ProximityAuthWebUIHandler::RegisterMessages() {
void ProximityAuthWebUIHandler::OnLogMessageAdded(
const LogBuffer::LogMessage& log_message) {
- scoped_ptr<base::DictionaryValue> dictionary =
+ std::unique_ptr<base::DictionaryValue> dictionary =
LogMessageToDictionary(log_message);
web_ui()->CallJavascriptFunction("LogBufferInterface.onLogMessageAdded",
*dictionary);
@@ -177,7 +180,7 @@ void ProximityAuthWebUIHandler::OnEnrollmentStarted() {
}
void ProximityAuthWebUIHandler::OnEnrollmentFinished(bool success) {
- scoped_ptr<base::DictionaryValue> enrollment_state =
+ std::unique_ptr<base::DictionaryValue> enrollment_state =
GetEnrollmentStateDictionary();
PA_LOG(INFO) << "Enrollment attempt completed with success=" << success
<< ":\n" << *enrollment_state;
@@ -194,7 +197,7 @@ void ProximityAuthWebUIHandler::OnSyncStarted() {
void ProximityAuthWebUIHandler::OnSyncFinished(
CryptAuthDeviceManager::SyncResult sync_result,
CryptAuthDeviceManager::DeviceChangeResult device_change_result) {
- scoped_ptr<base::DictionaryValue> device_sync_state =
+ std::unique_ptr<base::DictionaryValue> device_sync_state =
GetDeviceSyncStateDictionary();
PA_LOG(INFO) << "Device sync completed with result="
<< static_cast<int>(sync_result) << ":\n" << *device_sync_state;
@@ -203,7 +206,7 @@ void ProximityAuthWebUIHandler::OnSyncFinished(
if (device_change_result ==
CryptAuthDeviceManager::DeviceChangeResult::CHANGED) {
- scoped_ptr<base::ListValue> unlock_keys = GetUnlockKeysList();
+ std::unique_ptr<base::ListValue> unlock_keys = GetUnlockKeysList();
PA_LOG(INFO) << "New unlock keys obtained after device sync:\n"
<< *unlock_keys;
web_ui()->CallJavascriptFunction("LocalStateInterface.onUnlockKeysChanged",
@@ -404,11 +407,11 @@ void ProximityAuthWebUIHandler::OnReachablePhonesFound(
}
void ProximityAuthWebUIHandler::GetLocalState(const base::ListValue* args) {
- scoped_ptr<base::DictionaryValue> enrollment_state =
+ std::unique_ptr<base::DictionaryValue> enrollment_state =
GetEnrollmentStateDictionary();
- scoped_ptr<base::DictionaryValue> device_sync_state =
+ std::unique_ptr<base::DictionaryValue> device_sync_state =
GetDeviceSyncStateDictionary();
- scoped_ptr<base::ListValue> unlock_keys = GetUnlockKeysList();
+ std::unique_ptr<base::ListValue> unlock_keys = GetUnlockKeysList();
PA_LOG(INFO) << "==== Got Local State ====\n"
<< "Enrollment State: \n" << *enrollment_state
@@ -419,12 +422,12 @@ void ProximityAuthWebUIHandler::GetLocalState(const base::ListValue* args) {
*unlock_keys);
}
-scoped_ptr<base::DictionaryValue>
+std::unique_ptr<base::DictionaryValue>
ProximityAuthWebUIHandler::GetEnrollmentStateDictionary() {
CryptAuthEnrollmentManager* enrollment_manager =
proximity_auth_client_->GetCryptAuthEnrollmentManager();
if (!enrollment_manager)
- return make_scoped_ptr(new base::DictionaryValue());
+ return base::WrapUnique(new base::DictionaryValue());
return CreateSyncStateDictionary(
enrollment_manager->GetLastEnrollmentTime().ToJsTime(),
@@ -433,12 +436,12 @@ ProximityAuthWebUIHandler::GetEnrollmentStateDictionary() {
enrollment_manager->IsEnrollmentInProgress());
}
-scoped_ptr<base::DictionaryValue>
+std::unique_ptr<base::DictionaryValue>
ProximityAuthWebUIHandler::GetDeviceSyncStateDictionary() {
CryptAuthDeviceManager* device_manager =
proximity_auth_client_->GetCryptAuthDeviceManager();
if (!device_manager)
- return make_scoped_ptr(new base::DictionaryValue());
+ return base::WrapUnique(new base::DictionaryValue());
return CreateSyncStateDictionary(
device_manager->GetLastSyncTime().ToJsTime(),
@@ -447,8 +450,9 @@ ProximityAuthWebUIHandler::GetDeviceSyncStateDictionary() {
device_manager->IsSyncInProgress());
}
-scoped_ptr<base::ListValue> ProximityAuthWebUIHandler::GetUnlockKeysList() {
- scoped_ptr<base::ListValue> unlock_keys(new base::ListValue());
+std::unique_ptr<base::ListValue>
+ProximityAuthWebUIHandler::GetUnlockKeysList() {
+ std::unique_ptr<base::ListValue> unlock_keys(new base::ListValue());
CryptAuthDeviceManager* device_manager =
proximity_auth_client_->GetCryptAuthDeviceManager();
if (!device_manager)
@@ -475,7 +479,7 @@ void ProximityAuthWebUIHandler::OnRemoteDevicesLoaded(
life_cycle_->Start();
}
-scoped_ptr<base::DictionaryValue>
+std::unique_ptr<base::DictionaryValue>
ProximityAuthWebUIHandler::ExternalDeviceInfoToDictionary(
const cryptauth::ExternalDeviceInfo& device_info) {
std::string base64_public_key;
@@ -484,7 +488,8 @@ ProximityAuthWebUIHandler::ExternalDeviceInfoToDictionary(
&base64_public_key);
// Set the fields in the ExternalDeviceInfo proto.
- scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> dictionary(
+ new base::DictionaryValue());
dictionary->SetString(kExternalDevicePublicKey, base64_public_key);
dictionary->SetString(kExternalDeviceFriendlyName,
device_info.friendly_device_name());
@@ -527,7 +532,7 @@ ProximityAuthWebUIHandler::ExternalDeviceInfoToDictionary(
// Fill the remote status dictionary.
if (last_remote_status_update_) {
- scoped_ptr<base::DictionaryValue> status_dictionary(
+ std::unique_ptr<base::DictionaryValue> status_dictionary(
new base::DictionaryValue());
status_dictionary->SetInteger("userPresent",
last_remote_status_update_->user_presence);
@@ -542,15 +547,15 @@ ProximityAuthWebUIHandler::ExternalDeviceInfoToDictionary(
return dictionary;
}
-scoped_ptr<base::DictionaryValue>
+std::unique_ptr<base::DictionaryValue>
ProximityAuthWebUIHandler::IneligibleDeviceToDictionary(
const cryptauth::IneligibleDevice& ineligible_device) {
- scoped_ptr<base::ListValue> ineligibility_reasons(new base::ListValue());
+ std::unique_ptr<base::ListValue> ineligibility_reasons(new base::ListValue());
for (const std::string& reason : ineligible_device.reasons()) {
ineligibility_reasons->AppendString(reason);
}
- scoped_ptr<base::DictionaryValue> device_dictionary =
+ std::unique_ptr<base::DictionaryValue> device_dictionary =
ExternalDeviceInfoToDictionary(ineligible_device.device());
device_dictionary->Set(kIneligibleDeviceReasons,
std::move(ineligibility_reasons));
@@ -601,7 +606,7 @@ void ProximityAuthWebUIHandler::OnRemoteStatusUpdate(
<< static_cast<int>(status_update.trust_agent_state);
last_remote_status_update_.reset(new RemoteStatusUpdate(status_update));
- scoped_ptr<base::ListValue> unlock_keys = GetUnlockKeysList();
+ std::unique_ptr<base::ListValue> unlock_keys = GetUnlockKeysList();
web_ui()->CallJavascriptFunction("LocalStateInterface.onUnlockKeysChanged",
*unlock_keys);
}
« no previous file with comments | « components/proximity_auth/webui/proximity_auth_webui_handler.h ('k') | components/proximity_auth/webui/reachable_phone_flow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698