| 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 | 6 |
| 7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
| 8 var UserImagesGrid = options.UserImagesGrid; | 8 var UserImagesGrid = options.UserImagesGrid; |
| 9 var ButtonImages = UserImagesGrid.ButtonImages; | 9 var ButtonImages = UserImagesGrid.ButtonImages; |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // ChangePictureOptions class: | 22 // ChangePictureOptions class: |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Encapsulated handling of ChromeOS change picture options page. | 25 * Encapsulated handling of ChromeOS change picture options page. |
| 26 * @constructor | 26 * @constructor |
| 27 */ | 27 */ |
| 28 function ChangePictureOptions() { | 28 function ChangePictureOptions() { |
| 29 OptionsPage.call( | 29 OptionsPage.call( |
| 30 this, | 30 this, |
| 31 'changePicture', | 31 'changePicture', |
| 32 localStrings.getString('changePicturePage'), | 32 loadTimeData.getString('changePicturePage'), |
| 33 'change-picture-page'); | 33 'change-picture-page'); |
| 34 } | 34 } |
| 35 | 35 |
| 36 cr.addSingletonGetter(ChangePictureOptions); | 36 cr.addSingletonGetter(ChangePictureOptions); |
| 37 | 37 |
| 38 ChangePictureOptions.prototype = { | 38 ChangePictureOptions.prototype = { |
| 39 // Inherit ChangePictureOptions from OptionsPage. | 39 // Inherit ChangePictureOptions from OptionsPage. |
| 40 __proto__: options.OptionsPage.prototype, | 40 __proto__: options.OptionsPage.prototype, |
| 41 | 41 |
| 42 /** | 42 /** |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 this.handleImageActivated_.bind(this)); | 55 this.handleImageActivated_.bind(this)); |
| 56 imageGrid.addEventListener('dblclick', | 56 imageGrid.addEventListener('dblclick', |
| 57 this.handleImageDblClick_.bind(this)); | 57 this.handleImageDblClick_.bind(this)); |
| 58 | 58 |
| 59 // Ephemeral users can choose from the standard pictures only. This is | 59 // Ephemeral users can choose from the standard pictures only. This is |
| 60 // because a custom image would have to be written to a file outside the | 60 // because a custom image would have to be written to a file outside the |
| 61 // user's cryptohome where its removal on logout could not be guaranteed. | 61 // user's cryptohome where its removal on logout could not be guaranteed. |
| 62 if (!this.userIsEphemeral_()) { | 62 if (!this.userIsEphemeral_()) { |
| 63 // Add the "Choose file" button. | 63 // Add the "Choose file" button. |
| 64 imageGrid.addItem(ButtonImages.CHOOSE_FILE, | 64 imageGrid.addItem(ButtonImages.CHOOSE_FILE, |
| 65 localStrings.getString('chooseFile'), | 65 loadTimeData.getString('chooseFile'), |
| 66 this.handleChooseFile_.bind(this)); | 66 this.handleChooseFile_.bind(this)); |
| 67 | 67 |
| 68 // Profile image data. | 68 // Profile image data. |
| 69 this.profileImage_ = imageGrid.addItem( | 69 this.profileImage_ = imageGrid.addItem( |
| 70 ButtonImages.PROFILE_PICTURE, | 70 ButtonImages.PROFILE_PICTURE, |
| 71 localStrings.getString('profilePhotoLoading')); | 71 loadTimeData.getString('profilePhotoLoading')); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Old user image data (if present). | 74 // Old user image data (if present). |
| 75 this.oldImage_ = null; | 75 this.oldImage_ = null; |
| 76 | 76 |
| 77 $('change-picture-overlay-confirm').onclick = this.closePage_; | 77 $('change-picture-overlay-confirm').onclick = this.closePage_; |
| 78 | 78 |
| 79 chrome.send('onChangePicturePageInitialized'); | 79 chrome.send('onChangePicturePageInitialized'); |
| 80 }, | 80 }, |
| 81 | 81 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 */ | 196 */ |
| 197 setCameraPresent_: function(present) { | 197 setCameraPresent_: function(present) { |
| 198 var imageGrid = $('images-grid'); | 198 var imageGrid = $('images-grid'); |
| 199 // Ephemeral users can choose from the standard pictures only. This is | 199 // Ephemeral users can choose from the standard pictures only. This is |
| 200 // because a custom image would have to be written to a file outside the | 200 // because a custom image would have to be written to a file outside the |
| 201 // user's cryptohome where its removal on logout could not be guaranteed. | 201 // user's cryptohome where its removal on logout could not be guaranteed. |
| 202 var showTakePhotoButton = present && !this.userIsEphemeral_(); | 202 var showTakePhotoButton = present && !this.userIsEphemeral_(); |
| 203 if (showTakePhotoButton && !this.takePhotoButton_) { | 203 if (showTakePhotoButton && !this.takePhotoButton_) { |
| 204 this.takePhotoButton_ = imageGrid.addItem( | 204 this.takePhotoButton_ = imageGrid.addItem( |
| 205 ButtonImages.TAKE_PHOTO, | 205 ButtonImages.TAKE_PHOTO, |
| 206 localStrings.getString('takePhoto'), | 206 loadTimeData.getString('takePhoto'), |
| 207 this.handleTakePhoto_.bind(this), | 207 this.handleTakePhoto_.bind(this), |
| 208 1); | 208 1); |
| 209 } else if (!showTakePhotoButton && this.takePhotoButton_) { | 209 } else if (!showTakePhotoButton && this.takePhotoButton_) { |
| 210 imageGrid.removeItem(this.takePhotoButton_); | 210 imageGrid.removeItem(this.takePhotoButton_); |
| 211 this.takePhotoButton_ = null; | 211 this.takePhotoButton_ = null; |
| 212 } | 212 } |
| 213 }, | 213 }, |
| 214 | 214 |
| 215 /** | 215 /** |
| 216 * Adds or updates old user image taken from file/camera (neither a profile | 216 * Adds or updates old user image taken from file/camera (neither a profile |
| (...skipping 15 matching lines...) Expand all Loading... |
| 232 | 232 |
| 233 /** | 233 /** |
| 234 * Updates user's profile image. | 234 * Updates user's profile image. |
| 235 * @param {string} imageUrl Profile image, encoded as data URL. | 235 * @param {string} imageUrl Profile image, encoded as data URL. |
| 236 * @param {boolean} select If true, profile image should be selected. | 236 * @param {boolean} select If true, profile image should be selected. |
| 237 * @private | 237 * @private |
| 238 */ | 238 */ |
| 239 setProfileImage_: function(imageUrl, select) { | 239 setProfileImage_: function(imageUrl, select) { |
| 240 var imageGrid = $('images-grid'); | 240 var imageGrid = $('images-grid'); |
| 241 this.profileImage_ = imageGrid.updateItem( | 241 this.profileImage_ = imageGrid.updateItem( |
| 242 this.profileImage_, imageUrl, localStrings.getString('profilePhoto')); | 242 this.profileImage_, imageUrl, loadTimeData.getString('profilePhoto')); |
| 243 if (select) | 243 if (select) |
| 244 imageGrid.selectedItem = this.profileImage_; | 244 imageGrid.selectedItem = this.profileImage_; |
| 245 }, | 245 }, |
| 246 | 246 |
| 247 /** | 247 /** |
| 248 * Selects user image with the given URL. | 248 * Selects user image with the given URL. |
| 249 * @param {string} url URL of the image to select. | 249 * @param {string} url URL of the image to select. |
| 250 * @private | 250 * @private |
| 251 */ | 251 */ |
| 252 setSelectedImage_: function(url) { | 252 setSelectedImage_: function(url) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 264 imageGrid.addItem(url); | 264 imageGrid.addItem(url); |
| 265 } | 265 } |
| 266 }, | 266 }, |
| 267 | 267 |
| 268 /** | 268 /** |
| 269 * Returns whether the user is logged in as ephemeral. | 269 * Returns whether the user is logged in as ephemeral. |
| 270 * @return {boolean} True if the user is logged in as ephemeral. | 270 * @return {boolean} True if the user is logged in as ephemeral. |
| 271 * @private | 271 * @private |
| 272 */ | 272 */ |
| 273 userIsEphemeral_: function() { | 273 userIsEphemeral_: function() { |
| 274 return localStrings.getString('userIsEphemeral') == 'true'; | 274 return loadTimeData.getBoolean('userIsEphemeral'); |
| 275 }, | 275 }, |
| 276 }; | 276 }; |
| 277 | 277 |
| 278 // Forward public APIs to private implementations. | 278 // Forward public APIs to private implementations. |
| 279 [ | 279 [ |
| 280 'setCameraPresent', | 280 'setCameraPresent', |
| 281 'setDefaultImages', | 281 'setDefaultImages', |
| 282 'setOldImage', | 282 'setOldImage', |
| 283 'setProfileImage', | 283 'setProfileImage', |
| 284 'setSelectedImage', | 284 'setSelectedImage', |
| 285 ].forEach(function(name) { | 285 ].forEach(function(name) { |
| 286 ChangePictureOptions[name] = function() { | 286 ChangePictureOptions[name] = function() { |
| 287 var instance = ChangePictureOptions.getInstance(); | 287 var instance = ChangePictureOptions.getInstance(); |
| 288 return instance[name + '_'].apply(instance, arguments); | 288 return instance[name + '_'].apply(instance, arguments); |
| 289 }; | 289 }; |
| 290 }); | 290 }); |
| 291 | 291 |
| 292 // Export | 292 // Export |
| 293 return { | 293 return { |
| 294 ChangePictureOptions: ChangePictureOptions | 294 ChangePictureOptions: ChangePictureOptions |
| 295 }; | 295 }; |
| 296 | 296 |
| 297 }); | 297 }); |
| 298 | 298 |
| OLD | NEW |