Commit 203c79b6 authored by bauerb@chromium.org's avatar bauerb@chromium.org

Dynamically update sign-in/Sync status in the profile creation overlay.

BUG=269006

Review URL: https://chromiumcodereview.appspot.com/22751002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217082 0039d316-1c4b-4281-b951-d872f2087c98
parent deadb057
...@@ -617,8 +617,13 @@ cr.define('options', function() { ...@@ -617,8 +617,13 @@ cr.define('options', function() {
var isSignedIn = email !== ''; var isSignedIn = email !== '';
$('create-profile-managed-signed-in').hidden = !isSignedIn; $('create-profile-managed-signed-in').hidden = !isSignedIn;
$('create-profile-managed-not-signed-in').hidden = isSignedIn; $('create-profile-managed-not-signed-in').hidden = isSignedIn;
$('select-existing-managed-profile-checkbox').hidden = !isSignedIn; var hideSelectExistingManagedUsers =
$('choose-existing-managed-profile').hidden = !isSignedIn; !isSignedIn ||
!loadTimeData.getBoolean('allowCreateExistingManagedUsers');
$('select-existing-managed-profile-checkbox').hidden =
hideSelectExistingManagedUsers;
$('choose-existing-managed-profile').hidden =
hideSelectExistingManagedUsers;
if (isSignedIn) { if (isSignedIn) {
var accountDetailsOutOfDate = var accountDetailsOutOfDate =
......
...@@ -82,6 +82,11 @@ ManageProfileHandler::ManageProfileHandler() ...@@ -82,6 +82,11 @@ ManageProfileHandler::ManageProfileHandler()
} }
ManageProfileHandler::~ManageProfileHandler() { ManageProfileHandler::~ManageProfileHandler() {
ProfileSyncService* service =
ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
// Sync may be disabled in tests.
if (service)
service->RemoveObserver(this);
} }
void ManageProfileHandler::GetLocalizedValues( void ManageProfileHandler::GetLocalizedValues(
...@@ -140,11 +145,17 @@ void ManageProfileHandler::InitializeHandler() { ...@@ -140,11 +145,17 @@ void ManageProfileHandler::InitializeHandler() {
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
pref_change_registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs()); Profile* profile = Profile::FromWebUI(web_ui());
pref_change_registrar_.Init(profile->GetPrefs());
pref_change_registrar_.Add( pref_change_registrar_.Add(
prefs::kManagedUserCreationAllowed, prefs::kManagedUserCreationAllowed,
base::Bind(&ManageProfileHandler::OnCreateManagedUserPrefChange, base::Bind(&ManageProfileHandler::OnCreateManagedUserPrefChange,
base::Unretained(this))); base::Unretained(this)));
ProfileSyncService* service =
ProfileSyncServiceFactory::GetForProfile(profile);
// Sync may be disabled for tests.
if (service)
service->AddObserver(this);
} }
void ManageProfileHandler::InitializePage() { void ManageProfileHandler::InitializePage() {
...@@ -206,6 +217,10 @@ void ManageProfileHandler::Observe( ...@@ -206,6 +217,10 @@ void ManageProfileHandler::Observe(
} }
} }
void ManageProfileHandler::OnStateChanged() {
RequestCreateProfileUpdate(NULL);
}
void ManageProfileHandler::RequestDefaultProfileIcons(const ListValue* args) { void ManageProfileHandler::RequestDefaultProfileIcons(const ListValue* args) {
base::StringValue create_value(kCreateProfileIconGridName); base::StringValue create_value(kCreateProfileIconGridName);
base::StringValue manage_value(kManageProfileIconGridName); base::StringValue manage_value(kManageProfileIconGridName);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/prefs/pref_change_registrar.h" #include "base/prefs/pref_change_registrar.h"
#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/ui/webui/options/options_ui.h" #include "chrome/browser/ui/webui/options/options_ui.h"
namespace base { namespace base {
...@@ -18,7 +19,8 @@ class StringValue; ...@@ -18,7 +19,8 @@ class StringValue;
namespace options { namespace options {
// Chrome personal stuff profiles manage overlay UI handler. // Chrome personal stuff profiles manage overlay UI handler.
class ManageProfileHandler : public OptionsPageUIHandler { class ManageProfileHandler : public OptionsPageUIHandler,
public ProfileSyncServiceObserver {
public: public:
ManageProfileHandler(); ManageProfileHandler();
virtual ~ManageProfileHandler(); virtual ~ManageProfileHandler();
...@@ -37,6 +39,9 @@ class ManageProfileHandler : public OptionsPageUIHandler { ...@@ -37,6 +39,9 @@ class ManageProfileHandler : public OptionsPageUIHandler {
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE; const content::NotificationDetails& details) OVERRIDE;
// ProfileSyncServiceObserver:
virtual void OnStateChanged() OVERRIDE;
private: private:
// Callback for the "requestDefaultProfileIcons" message. // Callback for the "requestDefaultProfileIcons" message.
// Sends the array of default profile icon URLs to WebUI. // Sends the array of default profile icon URLs to WebUI.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment