| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/options/supervised_user_import_handler.h" | 5 #include "chrome/browser/ui/webui/options/supervised_user_import_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 const base::FilePath& profile_path) { | 160 const base::FilePath& profile_path) { |
| 161 if (ProfileIsLegacySupervised(profile_path)) | 161 if (ProfileIsLegacySupervised(profile_path)) |
| 162 FetchSupervisedUsers(); | 162 FetchSupervisedUsers(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void SupervisedUserImportHandler::OnSupervisedUsersChanged() { | 165 void SupervisedUserImportHandler::OnSupervisedUsersChanged() { |
| 166 FetchSupervisedUsers(); | 166 FetchSupervisedUsers(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void SupervisedUserImportHandler::FetchSupervisedUsers() { | 169 void SupervisedUserImportHandler::FetchSupervisedUsers() { |
| 170 web_ui()->CallJavascriptFunction( | 170 web_ui()->CallJavascriptFunctionUnsafe( |
| 171 "options.SupervisedUserListData.resetPromise"); | 171 "options.SupervisedUserListData.resetPromise"); |
| 172 RequestSupervisedUserImportUpdate(NULL); | 172 RequestSupervisedUserImportUpdate(NULL); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void SupervisedUserImportHandler::RequestSupervisedUserImportUpdate( | 175 void SupervisedUserImportHandler::RequestSupervisedUserImportUpdate( |
| 176 const base::ListValue* /* args */) { | 176 const base::ListValue* /* args */) { |
| 177 if (Profile::FromWebUI(web_ui())->IsSupervised()) | 177 if (Profile::FromWebUI(web_ui())->IsSupervised()) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 if (!IsAccountConnected() || HasAuthError()) { | 180 if (!IsAccountConnected() || HasAuthError()) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 supervised_user_icon : | 248 supervised_user_icon : |
| 249 profiles::GetDefaultAvatarIconUrl(avatar_index); | 249 profiles::GetDefaultAvatarIconUrl(avatar_index); |
| 250 supervised_user->SetString("iconURL", avatar_url); | 250 supervised_user->SetString("iconURL", avatar_url); |
| 251 bool on_current_device = | 251 bool on_current_device = |
| 252 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); | 252 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); |
| 253 supervised_user->SetBoolean("onCurrentDevice", on_current_device); | 253 supervised_user->SetBoolean("onCurrentDevice", on_current_device); |
| 254 | 254 |
| 255 supervised_users.Append(supervised_user); | 255 supervised_users.Append(supervised_user); |
| 256 } | 256 } |
| 257 | 257 |
| 258 web_ui()->CallJavascriptFunction( | 258 web_ui()->CallJavascriptFunctionUnsafe( |
| 259 "options.SupervisedUserListData.receiveExistingSupervisedUsers", | 259 "options.SupervisedUserListData.receiveExistingSupervisedUsers", |
| 260 supervised_users); | 260 supervised_users); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void SupervisedUserImportHandler::ClearSupervisedUsersAndShowError() { | 263 void SupervisedUserImportHandler::ClearSupervisedUsersAndShowError() { |
| 264 web_ui()->CallJavascriptFunction( | 264 web_ui()->CallJavascriptFunctionUnsafe( |
| 265 "options.SupervisedUserListData.onSigninError"); | 265 "options.SupervisedUserListData.onSigninError"); |
| 266 } | 266 } |
| 267 | 267 |
| 268 bool SupervisedUserImportHandler::IsAccountConnected() const { | 268 bool SupervisedUserImportHandler::IsAccountConnected() const { |
| 269 Profile* profile = Profile::FromWebUI(web_ui()); | 269 Profile* profile = Profile::FromWebUI(web_ui()); |
| 270 SigninManagerBase* signin_manager = | 270 SigninManagerBase* signin_manager = |
| 271 SigninManagerFactory::GetForProfile(profile); | 271 SigninManagerFactory::GetForProfile(profile); |
| 272 return signin_manager && signin_manager->IsAuthenticated(); | 272 return signin_manager && signin_manager->IsAuthenticated(); |
| 273 } | 273 } |
| 274 | 274 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 292 const std::string& key) { | 292 const std::string& key) { |
| 293 if (key == supervised_users::kChromeAvatarIndex) | 293 if (key == supervised_users::kChromeAvatarIndex) |
| 294 FetchSupervisedUsers(); | 294 FetchSupervisedUsers(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 void SupervisedUserImportHandler::OnErrorChanged() { | 297 void SupervisedUserImportHandler::OnErrorChanged() { |
| 298 FetchSupervisedUsers(); | 298 FetchSupervisedUsers(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace options | 301 } // namespace options |
| OLD | NEW |