| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 void ProfileInfoHandler::HandleGetProfileManagesSupervisedUsers( | 112 void ProfileInfoHandler::HandleGetProfileManagesSupervisedUsers( |
| 113 const base::ListValue* args) { | 113 const base::ListValue* args) { |
| 114 AllowJavascript(); | 114 AllowJavascript(); |
| 115 | 115 |
| 116 CHECK_EQ(1U, args->GetSize()); | 116 CHECK_EQ(1U, args->GetSize()); |
| 117 const base::Value* callback_id; | 117 const base::Value* callback_id; |
| 118 CHECK(args->Get(0, &callback_id)); | 118 CHECK(args->Get(0, &callback_id)); |
| 119 | 119 |
| 120 ResolveJavascriptCallback( | 120 ResolveJavascriptCallback( |
| 121 *callback_id, base::FundamentalValue(IsProfileManagingSupervisedUsers())); | 121 *callback_id, base::Value(IsProfileManagingSupervisedUsers())); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ProfileInfoHandler::PushProfileInfo() { | 124 void ProfileInfoHandler::PushProfileInfo() { |
| 125 CallJavascriptFunction("cr.webUIListenerCallback", | 125 CallJavascriptFunction("cr.webUIListenerCallback", |
| 126 base::StringValue(kProfileInfoChangedEventName), | 126 base::StringValue(kProfileInfoChangedEventName), |
| 127 *GetAccountNameAndIcon()); | 127 *GetAccountNameAndIcon()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void ProfileInfoHandler::PushProfileManagesSupervisedUsersStatus() { | 130 void ProfileInfoHandler::PushProfileManagesSupervisedUsersStatus() { |
| 131 CallJavascriptFunction( | 131 CallJavascriptFunction( |
| 132 "cr.webUIListenerCallback", | 132 "cr.webUIListenerCallback", |
| 133 base::StringValue(kProfileManagesSupervisedUsersChangedEventName), | 133 base::StringValue(kProfileManagesSupervisedUsersChangedEventName), |
| 134 base::FundamentalValue(IsProfileManagingSupervisedUsers())); | 134 base::Value(IsProfileManagingSupervisedUsers())); |
| 135 } | 135 } |
| 136 | 136 |
| 137 std::unique_ptr<base::DictionaryValue> | 137 std::unique_ptr<base::DictionaryValue> |
| 138 ProfileInfoHandler::GetAccountNameAndIcon() const { | 138 ProfileInfoHandler::GetAccountNameAndIcon() const { |
| 139 std::string name; | 139 std::string name; |
| 140 std::string icon_url; | 140 std::string icon_url; |
| 141 | 141 |
| 142 #if defined(OS_CHROMEOS) | 142 #if defined(OS_CHROMEOS) |
| 143 name = profile_->GetProfileUserName(); | 143 name = profile_->GetProfileUserName(); |
| 144 if (name.empty()) { | 144 if (name.empty()) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 response->SetString("name", name); | 177 response->SetString("name", name); |
| 178 response->SetString("iconUrl", icon_url); | 178 response->SetString("iconUrl", icon_url); |
| 179 return base::WrapUnique(response); | 179 return base::WrapUnique(response); |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { | 182 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { |
| 183 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); | 183 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace settings | 186 } // namespace settings |
| OLD | NEW |