| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 var Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
| 8 var UserImagesGrid = options.UserImagesGrid; | 8 var UserImagesGrid = options.UserImagesGrid; |
| 9 var ButtonImages = UserImagesGrid.ButtonImages; | 9 var ButtonImages = UserImagesGrid.ButtonImages; |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 // Old user image data (if present). | 98 // Old user image data (if present). |
| 99 this.oldImage_ = null; | 99 this.oldImage_ = null; |
| 100 | 100 |
| 101 $('change-picture-overlay-confirm').addEventListener( | 101 $('change-picture-overlay-confirm').addEventListener( |
| 102 'click', this.closeOverlay_.bind(this)); | 102 'click', this.closeOverlay_.bind(this)); |
| 103 | 103 |
| 104 chrome.send('onChangePicturePageInitialized'); | 104 chrome.send('onChangePicturePageInitialized'); |
| 105 }, | 105 }, |
| 106 | 106 |
| 107 /** | 107 /** @override */ |
| 108 * Called right after the page has been shown to user. | |
| 109 */ | |
| 110 didShowPage: function() { | 108 didShowPage: function() { |
| 111 var imageGrid = $('user-image-grid'); | 109 var imageGrid = $('user-image-grid'); |
| 112 // Reset camera element. | 110 // Reset camera element. |
| 113 imageGrid.cameraImage = null; | 111 imageGrid.cameraImage = null; |
| 114 imageGrid.updateAndFocus(); | 112 imageGrid.updateAndFocus(); |
| 115 chrome.send('onChangePicturePageShown'); | 113 chrome.send('onChangePicturePageShown'); |
| 116 }, | 114 }, |
| 117 | 115 |
| 118 /** | 116 /** @override */ |
| 119 * Called right before the page is hidden. | |
| 120 */ | |
| 121 willHidePage: function() { | 117 willHidePage: function() { |
| 122 var imageGrid = $('user-image-grid'); | 118 var imageGrid = $('user-image-grid'); |
| 123 imageGrid.blur(); // Make sure the image grid is not active. | 119 imageGrid.blur(); // Make sure the image grid is not active. |
| 124 imageGrid.stopCamera(); | 120 imageGrid.stopCamera(); |
| 125 if (this.oldImage_) { | 121 if (this.oldImage_) { |
| 126 imageGrid.removeItem(this.oldImage_); | 122 imageGrid.removeItem(this.oldImage_); |
| 127 this.oldImage_ = null; | 123 this.oldImage_ = null; |
| 128 } | 124 } |
| 129 chrome.send('onChangePicturePageHidden'); | 125 chrome.send('onChangePicturePageHidden'); |
| 130 }, | 126 }, |
| 131 | 127 |
| 132 /** | 128 /** |
| 133 * Called right after the page has been hidden. | 129 * Either willHidePage or didClosePage may be called depending on the way |
| 130 * the page was closed. |
| 131 * @override |
| 134 */ | 132 */ |
| 135 // TODO(ivankr): both callbacks are required as only one of them is called | |
| 136 // depending on the way the page was closed, see http://crbug.com/118923. | |
| 137 didClosePage: function() { | 133 didClosePage: function() { |
| 138 this.willHidePage(); | 134 this.willHidePage(); |
| 139 }, | 135 }, |
| 140 | 136 |
| 141 /** | 137 /** |
| 142 * Closes the overlay, returning to the main settings page. | 138 * Closes the overlay, returning to the main settings page. |
| 143 * @private | 139 * @private |
| 144 */ | 140 */ |
| 145 closeOverlay_: function() { | 141 closeOverlay_: function() { |
| 146 if (!$('change-picture-page').hidden) | 142 if (!$('change-picture-page').hidden) |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 'setProfileImage', | 328 'setProfileImage', |
| 333 'setSelectedImage', | 329 'setSelectedImage', |
| 334 ]); | 330 ]); |
| 335 | 331 |
| 336 // Export | 332 // Export |
| 337 return { | 333 return { |
| 338 ChangePictureOptions: ChangePictureOptions | 334 ChangePictureOptions: ChangePictureOptions |
| 339 }; | 335 }; |
| 340 | 336 |
| 341 }); | 337 }); |
| OLD | NEW |