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

Side by Side Diff: chrome/browser/ui/webui/settings/profile_info_handler.cc

Issue 1988463002: MD Settings: Convert C++ handlers to be JavaScript-lifecycle aware. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/webui/settings/profile_info_handler.h" 5 #include "chrome/browser/ui/webui/settings/profile_info_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 AllowJavascript(); 91 AllowJavascript();
92 92
93 CHECK_EQ(1U, args->GetSize()); 93 CHECK_EQ(1U, args->GetSize());
94 const base::Value* callback_id; 94 const base::Value* callback_id;
95 CHECK(args->Get(0, &callback_id)); 95 CHECK(args->Get(0, &callback_id));
96 96
97 ResolveJavascriptCallback(*callback_id, *GetAccountNameAndIcon()); 97 ResolveJavascriptCallback(*callback_id, *GetAccountNameAndIcon());
98 } 98 }
99 99
100 void ProfileInfoHandler::PushProfileInfo() { 100 void ProfileInfoHandler::PushProfileInfo() {
101 web_ui()->CallJavascriptFunction( 101 CallJavascriptFunction("cr.webUIListenerCallback",
102 "cr.webUIListenerCallback", 102 base::StringValue(kProfileInfoChangedEventName),
103 base::StringValue(kProfileInfoChangedEventName), 103 *GetAccountNameAndIcon());
104 *GetAccountNameAndIcon());
105 } 104 }
106 105
107 std::unique_ptr<base::DictionaryValue> 106 std::unique_ptr<base::DictionaryValue>
108 ProfileInfoHandler::GetAccountNameAndIcon() const { 107 ProfileInfoHandler::GetAccountNameAndIcon() const {
109 std::string name; 108 std::string name;
110 std::string icon_url; 109 std::string icon_url;
111 110
112 #if defined(OS_CHROMEOS) 111 #if defined(OS_CHROMEOS)
113 name = profile_->GetProfileUserName(); 112 name = profile_->GetProfileUserName();
114 if (name.empty()) { 113 if (name.empty()) {
(...skipping 28 matching lines...) Expand all
143 } 142 }
144 #endif // defined(OS_CHROMEOS) 143 #endif // defined(OS_CHROMEOS)
145 144
146 base::DictionaryValue* response = new base::DictionaryValue(); 145 base::DictionaryValue* response = new base::DictionaryValue();
147 response->SetString("name", name); 146 response->SetString("name", name);
148 response->SetString("iconUrl", icon_url); 147 response->SetString("iconUrl", icon_url);
149 return base::WrapUnique(response); 148 return base::WrapUnique(response);
150 } 149 }
151 150
152 } // namespace settings 151 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698