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

Unified Diff: chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc

Issue 1871653002: Settings People Revamp: Update ManageProfileHandler to use Promises. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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: chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
diff --git a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
index 8a957cdb92e8df2c4fdd9b42787379124012b060..bb6d8e03eb6214d287a5edd6a0f6f5be39d1d840 100644
--- a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
@@ -72,7 +72,9 @@ void ManageProfileHandler::RegisterMessages() {
void ManageProfileHandler::OnProfileAvatarChanged(
const base::FilePath& profile_path) {
// This is necessary to send the potentially updated GAIA photo.
- SendAvailableIcons();
+ web_ui()->CallJavascriptFunction("cr.webUIListenerCallback",
+ base::StringValue("available-icons-changed"),
+ *GetAvailableIcons());
}
void ManageProfileHandler::HandleGetAvailableIcons(
@@ -86,11 +88,14 @@ void ManageProfileHandler::HandleGetAvailableIcons(
profiles::UpdateGaiaProfileInfoIfNeeded(profile_);
- SendAvailableIcons();
+ CHECK_EQ(1U, args->GetSize());
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+ ResolveJavascriptCallback(*callback_id, *GetAvailableIcons());
}
-void ManageProfileHandler::SendAvailableIcons() {
- base::ListValue image_url_list;
+scoped_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() {
+ scoped_ptr<base::ListValue> image_url_list(new base::ListValue());
// First add the GAIA picture if it is available.
ProfileAttributesEntry* entry;
@@ -100,19 +105,17 @@ void ManageProfileHandler::SendAvailableIcons() {
if (icon) {
gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true);
gaia_picture_url_ = webui::GetBitmapDataUrl(icon2.AsBitmap());
- image_url_list.AppendString(gaia_picture_url_);
+ image_url_list->AppendString(gaia_picture_url_);
}
}
// Next add the default avatar icons and names.
for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount(); i++) {
std::string url = profiles::GetDefaultAvatarIconUrl(i);
- image_url_list.AppendString(url);
+ image_url_list->AppendString(url);
}
- web_ui()->CallJavascriptFunction("cr.webUIListenerCallback",
- base::StringValue("available-icons-changed"),
- image_url_list);
+ return image_url_list;
}
void ManageProfileHandler::HandleSetProfileIconAndName(

Powered by Google App Engine
This is Rietveld 408576698