Commit 296b8eb8 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Upgrade chrome/browser/ui/webui from deprecated Value-conversion API

Bug: 1086733
Change-Id: I60b07c0a7fa573c4999c31f49a1c8973bb5ad601
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2235217Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776265}
parent 971aef9d
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/value_conversions.h"
#include "base/values.h"
#include "chrome/browser/download/download_crx_util.h" #include "chrome/browser/download/download_crx_util.h"
#include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_query.h" #include "chrome/browser/download/download_query.h"
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/value_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/gaia_info_update_service.h" #include "chrome/browser/profiles/gaia_info_update_service.h"
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/value_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_entry.h"
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/value_conversions.h" #include "base/util/values/values_util.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -314,13 +314,15 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( ...@@ -314,13 +314,15 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser(
if (!args->Get(0, &profile_path_value)) if (!args->Get(0, &profile_path_value))
return; return;
base::FilePath profile_path; base::Optional<base::FilePath> profile_path =
if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) util::ValueToFilePath(*profile_path_value);
if (!profile_path)
return; return;
ProfileAttributesEntry* entry; ProfileAttributesEntry* entry;
if (!g_browser_process->profile_manager()->GetProfileAttributesStorage(). if (!g_browser_process->profile_manager()
GetProfileAttributesWithPath(profile_path, &entry)) { ->GetProfileAttributesStorage()
.GetProfileAttributesWithPath(*profile_path, &entry)) {
return; return;
} }
...@@ -332,7 +334,7 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( ...@@ -332,7 +334,7 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser(
if (!args->GetString(2, &password)) if (!args->GetString(2, &password))
return; return;
authenticating_profile_path_ = profile_path; authenticating_profile_path_ = *profile_path;
email_address_ = base::UTF16ToUTF8(email_address); email_address_ = base::UTF16ToUTF8(email_address);
// Only try to validate locally or check the password change detection // Only try to validate locally or check the password change detection
...@@ -371,7 +373,7 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( ...@@ -371,7 +373,7 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser(
RecordAuthenticatedLaunchUserEvent( RecordAuthenticatedLaunchUserEvent(
AuthenticatedLaunchUserEvent::GAIA_REAUTH_DIALOG); AuthenticatedLaunchUserEvent::GAIA_REAUTH_DIALOG);
UserManagerProfileDialog::ShowUnlockDialogWithProfilePath( UserManagerProfileDialog::ShowUnlockDialogWithProfilePath(
browser_context, email_address_, profile_path); browser_context, email_address_, *profile_path);
} else if (entry->IsSigninRequired() && entry->IsSupervised()) { } else if (entry->IsSigninRequired() && entry->IsSupervised()) {
// Supervised profile will only be locked when force-sign-in is enabled // Supervised profile will only be locked when force-sign-in is enabled
// and it shouldn't be unlocked. Display the error message directly via // and it shouldn't be unlocked. Display the error message directly via
...@@ -401,7 +403,7 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( ...@@ -401,7 +403,7 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser(
RecordAuthenticatedLaunchUserEvent( RecordAuthenticatedLaunchUserEvent(
AuthenticatedLaunchUserEvent::FORCED_PRIMARY_SIGNIN_DIALOG); AuthenticatedLaunchUserEvent::FORCED_PRIMARY_SIGNIN_DIALOG);
UserManagerProfileDialog::ShowForceSigninDialog(browser_context, UserManagerProfileDialog::ShowForceSigninDialog(browser_context,
profile_path); *profile_path);
} }
} }
...@@ -413,8 +415,9 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) { ...@@ -413,8 +415,9 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) {
return; return;
} }
base::FilePath profile_path; base::Optional<base::FilePath> profile_path =
if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) { util::ValueToFilePath(*profile_path_value);
if (!profile_path) {
NOTREACHED(); NOTREACHED();
return; return;
} }
...@@ -432,7 +435,7 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) { ...@@ -432,7 +435,7 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) {
// The callback is run if the only profile has been deleted, and a new // The callback is run if the only profile has been deleted, and a new
// profile has been created to replace it. // profile has been created to replace it.
webui::DeleteProfileAtPath(profile_path, webui::DeleteProfileAtPath(*profile_path,
ProfileMetrics::DELETE_PROFILE_USER_MANAGER); ProfileMetrics::DELETE_PROFILE_USER_MANAGER);
} }
...@@ -466,13 +469,15 @@ void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { ...@@ -466,13 +469,15 @@ void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
if (!args->Get(0, &profile_path_value)) if (!args->Get(0, &profile_path_value))
return; return;
base::FilePath profile_path; base::Optional<base::FilePath> profile_path =
if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) util::ValueToFilePath(*profile_path_value);
if (!profile_path)
return; return;
ProfileAttributesEntry* entry; ProfileAttributesEntry* entry;
if (!g_browser_process->profile_manager()->GetProfileAttributesStorage(). if (!g_browser_process->profile_manager()
GetProfileAttributesWithPath(profile_path, &entry)) { ->GetProfileAttributesStorage()
.GetProfileAttributesWithPath(*profile_path, &entry)) {
NOTREACHED(); NOTREACHED();
return; return;
} }
...@@ -486,7 +491,7 @@ void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { ...@@ -486,7 +491,7 @@ void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
return; return;
profiles::SwitchToProfile( profiles::SwitchToProfile(
profile_path, false, /* reuse any existing windows */ *profile_path, false, /* reuse any existing windows */
base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
...@@ -499,20 +504,20 @@ void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats( ...@@ -499,20 +504,20 @@ void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats(
return; return;
base::Time start_time = base::Time::Now(); base::Time start_time = base::Time::Now();
base::FilePath profile_path; base::Optional<base::FilePath> profile_path =
util::ValueToFilePath(*profile_path_value);
if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) if (!profile_path)
return; return;
base::Value return_profile_path(profile_path.value()); base::Value return_profile_path(profile_path->value());
Profile* profile = g_browser_process->profile_manager()-> Profile* profile =
GetProfileByPath(profile_path); g_browser_process->profile_manager()->GetProfileByPath(*profile_path);
if (profile) { if (profile) {
GatherStatistics(start_time, profile); GatherStatistics(start_time, profile);
} else { } else {
g_browser_process->profile_manager()->LoadProfileByPath( g_browser_process->profile_manager()->LoadProfileByPath(
profile_path, false, *profile_path, false,
base::BindOnce(&UserManagerScreenHandler::GatherStatistics, base::BindOnce(&UserManagerScreenHandler::GatherStatistics,
weak_ptr_factory_.GetWeakPtr(), start_time)); weak_ptr_factory_.GetWeakPtr(), start_time));
} }
...@@ -796,8 +801,7 @@ void UserManagerScreenHandler::SendUserList() { ...@@ -796,8 +801,7 @@ void UserManagerScreenHandler::SendUserList() {
profile_value->SetString(kKeyEmailAddress, entry->GetUserName()); profile_value->SetString(kKeyEmailAddress, entry->GetUserName());
profile_value->SetString(kKeyDisplayName, profile_value->SetString(kKeyDisplayName,
profiles::GetAvatarNameForProfile(profile_path)); profiles::GetAvatarNameForProfile(profile_path));
profile_value->SetKey(kKeyProfilePath, profile_value->SetKey(kKeyProfilePath, util::FilePathToValue(profile_path));
base::CreateFilePathValue(profile_path));
profile_value->SetBoolean(kKeyPublicAccount, false); profile_value->SetBoolean(kKeyPublicAccount, false);
profile_value->SetBoolean(kKeyLegacySupervisedUser, profile_value->SetBoolean(kKeyLegacySupervisedUser,
entry->IsLegacySupervised()); entry->IsLegacySupervised());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment