| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 #endif | 178 #endif |
| 179 web_ui()->RegisterMessageCallback("addProfileShortcut", | 179 web_ui()->RegisterMessageCallback("addProfileShortcut", |
| 180 base::Bind(&ManageProfileHandler::AddProfileShortcut, | 180 base::Bind(&ManageProfileHandler::AddProfileShortcut, |
| 181 base::Unretained(this))); | 181 base::Unretained(this))); |
| 182 web_ui()->RegisterMessageCallback("removeProfileShortcut", | 182 web_ui()->RegisterMessageCallback("removeProfileShortcut", |
| 183 base::Bind(&ManageProfileHandler::RemoveProfileShortcut, | 183 base::Bind(&ManageProfileHandler::RemoveProfileShortcut, |
| 184 base::Unretained(this))); | 184 base::Unretained(this))); |
| 185 web_ui()->RegisterMessageCallback("refreshGaiaPicture", | 185 web_ui()->RegisterMessageCallback("refreshGaiaPicture", |
| 186 base::Bind(&ManageProfileHandler::RefreshGaiaPicture, | 186 base::Bind(&ManageProfileHandler::RefreshGaiaPicture, |
| 187 base::Unretained(this))); | 187 base::Unretained(this))); |
| 188 web_ui()->RegisterMessageCallback( |
| 189 "showDisconnectManagedProfileDialog", |
| 190 base::Bind(&ManageProfileHandler::ShowDisconnectManagedProfileDialog, |
| 191 base::Unretained(this))); |
| 188 } | 192 } |
| 189 | 193 |
| 190 void ManageProfileHandler::Uninitialize() { | 194 void ManageProfileHandler::Uninitialize() { |
| 191 registrar_.RemoveAll(); | 195 registrar_.RemoveAll(); |
| 192 } | 196 } |
| 193 | 197 |
| 194 void ManageProfileHandler::Observe( | 198 void ManageProfileHandler::Observe( |
| 195 int type, | 199 int type, |
| 196 const content::NotificationSource& source, | 200 const content::NotificationSource& source, |
| 197 const content::NotificationDetails& details) { | 201 const content::NotificationDetails& details) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 base::DictionaryValue profile_name_dict; | 310 base::DictionaryValue profile_name_dict; |
| 307 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { | 311 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { |
| 308 profile_name_dict.SetBoolean( | 312 profile_name_dict.SetBoolean( |
| 309 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(i)), true); | 313 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(i)), true); |
| 310 } | 314 } |
| 311 | 315 |
| 312 web_ui()->CallJavascriptFunction( | 316 web_ui()->CallJavascriptFunction( |
| 313 "ManageProfileOverlay.receiveExistingProfileNames", profile_name_dict); | 317 "ManageProfileOverlay.receiveExistingProfileNames", profile_name_dict); |
| 314 } | 318 } |
| 315 | 319 |
| 320 void ManageProfileHandler::ShowDisconnectManagedProfileDialog( |
| 321 const base::ListValue* args) { |
| 322 base::DictionaryValue replacements; |
| 323 GenerateSignedinUserSpecificStrings(&replacements); |
| 324 web_ui()->CallJavascriptFunction( |
| 325 "ManageProfileOverlay.showDisconnectManagedProfileDialog", replacements); |
| 326 } |
| 327 |
| 316 void ManageProfileHandler::SetProfileIconAndName(const base::ListValue* args) { | 328 void ManageProfileHandler::SetProfileIconAndName(const base::ListValue* args) { |
| 317 DCHECK(args); | 329 DCHECK(args); |
| 318 | 330 |
| 319 base::FilePath profile_file_path; | 331 base::FilePath profile_file_path; |
| 320 if (!GetProfilePathFromArgs(args, &profile_file_path)) | 332 if (!GetProfilePathFromArgs(args, &profile_file_path)) |
| 321 return; | 333 return; |
| 322 | 334 |
| 323 ProfileInfoCache& cache = | 335 ProfileInfoCache& cache = |
| 324 g_browser_process->profile_manager()->GetProfileInfoCache(); | 336 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 325 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); | 337 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 ProfileSyncServiceFactory::GetForProfile(profile); | 473 ProfileSyncServiceFactory::GetForProfile(profile); |
| 462 GoogleServiceAuthError::State state = service->GetAuthError().state(); | 474 GoogleServiceAuthError::State state = service->GetAuthError().state(); |
| 463 bool has_error = (state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || | 475 bool has_error = (state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || |
| 464 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP || | 476 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP || |
| 465 state == GoogleServiceAuthError::ACCOUNT_DELETED || | 477 state == GoogleServiceAuthError::ACCOUNT_DELETED || |
| 466 state == GoogleServiceAuthError::ACCOUNT_DISABLED); | 478 state == GoogleServiceAuthError::ACCOUNT_DISABLED); |
| 467 web_ui()->CallJavascriptFunction("CreateProfileOverlay.updateSignedInStatus", | 479 web_ui()->CallJavascriptFunction("CreateProfileOverlay.updateSignedInStatus", |
| 468 base::StringValue(username), | 480 base::StringValue(username), |
| 469 base::FundamentalValue(has_error)); | 481 base::FundamentalValue(has_error)); |
| 470 | 482 |
| 471 base::DictionaryValue replacements; | |
| 472 GenerateSignedinUserSpecificStrings(&replacements); | |
| 473 web_ui()->CallJavascriptFunction("loadTimeData.overrideValues", replacements); | |
| 474 | |
| 475 OnCreateSupervisedUserPrefChange(); | 483 OnCreateSupervisedUserPrefChange(); |
| 476 } | 484 } |
| 477 | 485 |
| 478 void ManageProfileHandler::OnCreateSupervisedUserPrefChange() { | 486 void ManageProfileHandler::OnCreateSupervisedUserPrefChange() { |
| 479 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 487 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 480 base::FundamentalValue allowed( | 488 base::FundamentalValue allowed( |
| 481 prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed)); | 489 prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed)); |
| 482 web_ui()->CallJavascriptFunction( | 490 web_ui()->CallJavascriptFunction( |
| 483 "CreateProfileOverlay.updateManagedUsersAllowed", allowed); | 491 "CreateProfileOverlay.updateManagedUsersAllowed", allowed); |
| 484 } | 492 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 529 |
| 522 // Update the UI buttons. | 530 // Update the UI buttons. |
| 523 OnHasProfileShortcuts(false); | 531 OnHasProfileShortcuts(false); |
| 524 } | 532 } |
| 525 | 533 |
| 526 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { | 534 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { |
| 527 profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui())); | 535 profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui())); |
| 528 } | 536 } |
| 529 | 537 |
| 530 } // namespace options | 538 } // namespace options |
| OLD | NEW |