| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 GenerateSignedinUserSpecificStrings(localized_strings); | 130 GenerateSignedinUserSpecificStrings(localized_strings); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void ManageProfileHandler::InitializeHandler() { | 133 void ManageProfileHandler::InitializeHandler() { |
| 134 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 134 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 135 content::NotificationService::AllSources()); | 135 content::NotificationService::AllSources()); |
| 136 | 136 |
| 137 Profile* profile = Profile::FromWebUI(web_ui()); | 137 Profile* profile = Profile::FromWebUI(web_ui()); |
| 138 pref_change_registrar_.Init(profile->GetPrefs()); | 138 pref_change_registrar_.Init(profile->GetPrefs()); |
| 139 pref_change_registrar_.Add( | 139 pref_change_registrar_.Add( |
| 140 prefs::kManagedUserCreationAllowed, | 140 prefs::kSupervisedUserCreationAllowed, |
| 141 base::Bind(&ManageProfileHandler::OnCreateManagedUserPrefChange, | 141 base::Bind(&ManageProfileHandler::OnCreateSupervisedUserPrefChange, |
| 142 base::Unretained(this))); | 142 base::Unretained(this))); |
| 143 ProfileSyncService* service = | 143 ProfileSyncService* service = |
| 144 ProfileSyncServiceFactory::GetForProfile(profile); | 144 ProfileSyncServiceFactory::GetForProfile(profile); |
| 145 // Sync may be disabled for tests. | 145 // Sync may be disabled for tests. |
| 146 if (service) | 146 if (service) |
| 147 service->AddObserver(this); | 147 service->AddObserver(this); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void ManageProfileHandler::InitializePage() { | 150 void ManageProfileHandler::InitializePage() { |
| 151 SendExistingProfileNames(); | 151 SendExistingProfileNames(); |
| 152 OnCreateManagedUserPrefChange(); | 152 OnCreateSupervisedUserPrefChange(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void ManageProfileHandler::RegisterMessages() { | 155 void ManageProfileHandler::RegisterMessages() { |
| 156 web_ui()->RegisterMessageCallback("setProfileIconAndName", | 156 web_ui()->RegisterMessageCallback("setProfileIconAndName", |
| 157 base::Bind(&ManageProfileHandler::SetProfileIconAndName, | 157 base::Bind(&ManageProfileHandler::SetProfileIconAndName, |
| 158 base::Unretained(this))); | 158 base::Unretained(this))); |
| 159 web_ui()->RegisterMessageCallback("requestDefaultProfileIcons", | 159 web_ui()->RegisterMessageCallback("requestDefaultProfileIcons", |
| 160 base::Bind(&ManageProfileHandler::RequestDefaultProfileIcons, | 160 base::Bind(&ManageProfileHandler::RequestDefaultProfileIcons, |
| 161 base::Unretained(this))); | 161 base::Unretained(this))); |
| 162 web_ui()->RegisterMessageCallback("requestNewProfileDefaults", | 162 web_ui()->RegisterMessageCallback("requestNewProfileDefaults", |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } else if (profiles::IsDefaultAvatarIconUrl(icon_url, &new_icon_index)) { | 351 } else if (profiles::IsDefaultAvatarIconUrl(icon_url, &new_icon_index)) { |
| 352 ProfileMetrics::LogProfileAvatarSelection(new_icon_index); | 352 ProfileMetrics::LogProfileAvatarSelection(new_icon_index); |
| 353 PrefService* pref_service = profile->GetPrefs(); | 353 PrefService* pref_service = profile->GetPrefs(); |
| 354 // Updating the profile preference will cause the cache to be updated for | 354 // Updating the profile preference will cause the cache to be updated for |
| 355 // this preference. | 355 // this preference. |
| 356 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); | 356 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); |
| 357 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); | 357 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); |
| 358 } | 358 } |
| 359 ProfileMetrics::LogProfileUpdate(profile_file_path); | 359 ProfileMetrics::LogProfileUpdate(profile_file_path); |
| 360 | 360 |
| 361 if (profile->IsManaged()) | 361 if (profile->IsSupervised()) |
| 362 return; | 362 return; |
| 363 | 363 |
| 364 base::string16 new_profile_name; | 364 base::string16 new_profile_name; |
| 365 if (!args->GetString(2, &new_profile_name)) | 365 if (!args->GetString(2, &new_profile_name)) |
| 366 return; | 366 return; |
| 367 | 367 |
| 368 profiles::UpdateProfileName(profile, new_profile_name); | 368 profiles::UpdateProfileName(profile, new_profile_name); |
| 369 } | 369 } |
| 370 | 370 |
| 371 #if defined(ENABLE_SETTINGS_APP) | 371 #if defined(ENABLE_SETTINGS_APP) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 state == GoogleServiceAuthError::ACCOUNT_DELETED || | 465 state == GoogleServiceAuthError::ACCOUNT_DELETED || |
| 466 state == GoogleServiceAuthError::ACCOUNT_DISABLED); | 466 state == GoogleServiceAuthError::ACCOUNT_DISABLED); |
| 467 web_ui()->CallJavascriptFunction("CreateProfileOverlay.updateSignedInStatus", | 467 web_ui()->CallJavascriptFunction("CreateProfileOverlay.updateSignedInStatus", |
| 468 base::StringValue(username), | 468 base::StringValue(username), |
| 469 base::FundamentalValue(has_error)); | 469 base::FundamentalValue(has_error)); |
| 470 | 470 |
| 471 base::DictionaryValue replacements; | 471 base::DictionaryValue replacements; |
| 472 GenerateSignedinUserSpecificStrings(&replacements); | 472 GenerateSignedinUserSpecificStrings(&replacements); |
| 473 web_ui()->CallJavascriptFunction("loadTimeData.overrideValues", replacements); | 473 web_ui()->CallJavascriptFunction("loadTimeData.overrideValues", replacements); |
| 474 | 474 |
| 475 OnCreateManagedUserPrefChange(); | 475 OnCreateSupervisedUserPrefChange(); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void ManageProfileHandler::OnCreateManagedUserPrefChange() { | 478 void ManageProfileHandler::OnCreateSupervisedUserPrefChange() { |
| 479 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 479 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 480 base::FundamentalValue allowed( | 480 base::FundamentalValue allowed( |
| 481 prefs->GetBoolean(prefs::kManagedUserCreationAllowed)); | 481 prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed)); |
| 482 web_ui()->CallJavascriptFunction( | 482 web_ui()->CallJavascriptFunction( |
| 483 "CreateProfileOverlay.updateManagedUsersAllowed", allowed); | 483 "CreateProfileOverlay.updateManagedUsersAllowed", allowed); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void ManageProfileHandler::OnHasProfileShortcuts(bool has_shortcuts) { | 486 void ManageProfileHandler::OnHasProfileShortcuts(bool has_shortcuts) { |
| 487 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 487 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 488 | 488 |
| 489 const base::FundamentalValue has_shortcuts_value(has_shortcuts); | 489 const base::FundamentalValue has_shortcuts_value(has_shortcuts); |
| 490 web_ui()->CallJavascriptFunction( | 490 web_ui()->CallJavascriptFunction( |
| 491 "ManageProfileOverlay.receiveHasProfileShortcuts", has_shortcuts_value); | 491 "ManageProfileOverlay.receiveHasProfileShortcuts", has_shortcuts_value); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 521 | 521 |
| 522 // Update the UI buttons. | 522 // Update the UI buttons. |
| 523 OnHasProfileShortcuts(false); | 523 OnHasProfileShortcuts(false); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { | 526 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { |
| 527 profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui())); | 527 profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui())); |
| 528 } | 528 } |
| 529 | 529 |
| 530 } // namespace options | 530 } // namespace options |
| OLD | NEW |