Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / managed_user_import.js
index 5430a46..36120e1 100644 (file)
@@ -66,7 +66,7 @@ cr.define('options', function() {
           this.showAvatarGridOrSubmit_.bind(this);
 
       $('create-new-user-link').onclick = function(event) {
-        OptionsPage.closeOverlay();
+        options.ManagedUserListData.removeObserver(self);
         OptionsPage.navigateToPage('createProfile');
       };
     },
@@ -77,6 +77,7 @@ cr.define('options', function() {
     didShowPage: function() {
       options.ManagedUserListData.requestExistingManagedUsers().then(
           this.receiveExistingManagedUsers_, this.onSigninError_.bind(this));
+      options.ManagedUserListData.addObserver(this);
 
       this.updateImportInProgress_(false);
       $('managed-user-import-error-bubble').hidden = true;
@@ -93,6 +94,13 @@ cr.define('options', function() {
     },
 
     /**
+     * @override
+     */
+    didClosePage: function() {
+      options.ManagedUserListData.removeObserver(this);
+    },
+
+    /**
      * Called when the user clicks the "OK" button. In case the managed
      * user being imported has no avatar in sync, it shows the avatar
      * icon grid. In case the avatar grid is visible or the managed user
@@ -120,7 +128,6 @@ cr.define('options', function() {
       // 'createProfile' is handled by CreateProfileHandler.
       chrome.send('createProfile', [managedUser.name, avatarUrl,
                                     false, true, managedUser.id]);
-      options.ManagedUserListData.reloadExistingManagedUsers();
     },
 
     /**
@@ -208,11 +215,14 @@ cr.define('options', function() {
     },
 
     /**
-     * Closes the overlay if importing the managed user was successful.
+     * Closes the overlay if importing the managed user was successful. Also
+     * reset the cached list of managed users in order to get an updated list
+     * when the overlay is reopened.
      * @private
      */
     onSuccess_: function() {
       this.updateImportInProgress_(false);
+      options.ManagedUserListData.resetPromise();
       OptionsPage.closeOverlay();
     },
   };