| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.exportPath('settings_test'); | 5 cr.exportPath('settings_test'); |
| 6 | 6 |
| 7 /** @type {boolean} */ | 7 /** @type {boolean} */ |
| 8 settings_test.changePictureNotifyForTest; | 8 settings_test.changePictureNotifyForTest; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 cameraPresent_: { | 40 cameraPresent_: { |
| 41 type: Boolean, | 41 type: Boolean, |
| 42 value: false, | 42 value: false, |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * The currently selected item. This property is bound to the iron-selector | 46 * The currently selected item. This property is bound to the iron-selector |
| 47 * and never directly assigned. | 47 * and never directly assigned. |
| 48 * @private {settings.ChangePictureImageElement} | 48 * @private {settings.ChangePictureImageElement} |
| 49 */ | 49 */ |
| 50 selectedItem_: { | 50 selectedItem_: Object, |
| 51 type: settings.ChangePictureImageElement, | |
| 52 notify: !!settings_test.changePictureNotifyForTest, | |
| 53 }, | |
| 54 | 51 |
| 55 /** | 52 /** |
| 56 * The url of the 'old' image, which is the existing image sourced from | 53 * The url of the 'old' image, which is the existing image sourced from |
| 57 * the camera, a file, or a deprecated default image. It defaults to an | 54 * the camera, a file, or a deprecated default image. It defaults to an |
| 58 * empty string instead of undefined, because Polymer bindings don't behave | 55 * empty string instead of undefined, because Polymer bindings don't behave |
| 59 * as expected with undefined properties. | 56 * as expected with undefined properties. |
| 60 * @private {string} | 57 * @private {string} |
| 61 */ | 58 */ |
| 62 oldImageUrl_: { | 59 oldImageUrl_: { |
| 63 type: String, | 60 type: String, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 80 defaultImages_: { | 77 defaultImages_: { |
| 81 type: Array, | 78 type: Array, |
| 82 value: function() { return []; }, | 79 value: function() { return []; }, |
| 83 }, | 80 }, |
| 84 | 81 |
| 85 /** | 82 /** |
| 86 * The fallback image to be selected when the user discards the 'old' image. | 83 * The fallback image to be selected when the user discards the 'old' image. |
| 87 * This may be null if the user started with the 'old' image. | 84 * This may be null if the user started with the 'old' image. |
| 88 * @private {?settings.ChangePictureImageElement} | 85 * @private {?settings.ChangePictureImageElement} |
| 89 */ | 86 */ |
| 90 fallbackImage_: { | 87 fallbackImage_: Object, |
| 91 type: settings.ChangePictureImageElement, | |
| 92 value: null, | |
| 93 }, | |
| 94 | 88 |
| 95 /** | 89 /** |
| 96 * Type of the last selected icon. This is used to jump back to the camera | 90 * Type of the last selected icon. This is used to jump back to the camera |
| 97 * after the user discards a newly taken photo. | 91 * after the user discards a newly taken photo. |
| 98 * @private {string} | 92 * @private {string} |
| 99 */ | 93 */ |
| 100 lastSelectedImageType_: { | 94 lastSelectedImageType_: { |
| 101 type: String, | 95 type: String, |
| 102 value: '', | 96 value: '', |
| 103 }, | 97 }, |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 if (this.fallbackImage_ != null) { | 309 if (this.fallbackImage_ != null) { |
| 316 this.selectImage_(this.fallbackImage_); | 310 this.selectImage_(this.fallbackImage_); |
| 317 return; | 311 return; |
| 318 } | 312 } |
| 319 | 313 |
| 320 // If the user has not chosen an image since opening the subpage and | 314 // If the user has not chosen an image since opening the subpage and |
| 321 // discards the current photo, select the first default image. | 315 // discards the current photo, select the first default image. |
| 322 assert(this.defaultImages_.length > 0); | 316 assert(this.defaultImages_.length > 0); |
| 323 this.browserProxy_.selectDefaultImage(this.defaultImages_[0].url); | 317 this.browserProxy_.selectDefaultImage(this.defaultImages_[0].url); |
| 324 | 318 |
| 325 announceAccessibleMessage( | 319 announceAccessibleMessage(this.i18n('photoDiscardAccessibleText')); |
| 326 loadTimeData.getString('photoDiscardAccessibleText')); | |
| 327 }, | 320 }, |
| 328 | 321 |
| 329 /** | 322 /** |
| 330 * @param {string} oldImageUrl | 323 * @param {string} oldImageUrl |
| 331 * @return {boolean} True if there is no old image and the old image icon | 324 * @return {boolean} True if there is no old image and the old image icon |
| 332 * should be hidden. | 325 * should be hidden. |
| 333 * @private | 326 * @private |
| 334 */ | 327 */ |
| 335 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; }, | 328 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; }, |
| 336 | 329 |
| 337 /** | 330 /** |
| 338 * @param {settings.ChangePictureImageElement} selectedItem | 331 * @param {settings.ChangePictureImageElement} selectedItem |
| 339 * @return {boolean} True if the preview image should be hidden. | 332 * @return {boolean} True if the preview image should be hidden. |
| 340 * @private | 333 * @private |
| 341 */ | 334 */ |
| 342 isPreviewImageHidden_: function(selectedItem) { | 335 isPreviewImageHidden_: function(selectedItem) { |
| 343 if (!selectedItem) | 336 if (!selectedItem) |
| 344 return true; | 337 return true; |
| 345 | 338 |
| 346 var type = selectedItem.dataset.type; | 339 var type = selectedItem.dataset.type; |
| 347 return type != 'default' && type != 'profile' && type != 'old'; | 340 return type != 'default' && type != 'profile' && type != 'old'; |
| 348 }, | 341 }, |
| 349 | 342 |
| 350 /** | 343 /** |
| 351 * @param {settings.ChangePictureImageElement} selectedItem | 344 * @param {settings.ChangePictureImageElement} selectedItem |
| 352 * @return {boolean} True if the camera is selected in the image grid. | 345 * @return {boolean} True if the camera is selected in the image grid. |
| 353 * @private | 346 * @private |
| 354 */ | 347 */ |
| 355 isCameraActive_: function(cameraPresent, selectedItem) { | 348 isCameraActive_: function(cameraPresent, selectedItem) { |
| 356 return cameraPresent && selectedItem && | 349 return cameraPresent && selectedItem != null && |
| 357 selectedItem.dataset.type == 'camera'; | 350 selectedItem.dataset.type == 'camera'; |
| 358 }, | 351 }, |
| 359 | 352 |
| 360 /** | 353 /** |
| 361 * @param {settings.ChangePictureImageElement} selectedItem | 354 * @param {settings.ChangePictureImageElement} selectedItem |
| 362 * @return {boolean} True if the discard controls should be hidden. | 355 * @return {boolean} True if the discard controls should be hidden. |
| 363 * @private | 356 * @private |
| 364 */ | 357 */ |
| 365 isDiscardHidden_: function(selectedItem) { | 358 isDiscardHidden_: function(selectedItem) { |
| 366 return !selectedItem || selectedItem.dataset.type != 'old'; | 359 return !selectedItem || selectedItem.dataset.type != 'old'; |
| 367 }, | 360 }, |
| 368 | 361 |
| 369 /** | 362 /** |
| 370 * @param {settings.ChangePictureImageElement} selectedItem | 363 * @param {settings.ChangePictureImageElement} selectedItem |
| 371 * @return {boolean} True if the author credit text is shown. | 364 * @return {boolean} True if the author credit text is shown. |
| 372 * @private | 365 * @private |
| 373 */ | 366 */ |
| 374 isAuthorCreditShown_: function(selectedItem) { | 367 isAuthorCreditShown_: function(selectedItem) { |
| 375 return selectedItem && selectedItem.dataset.type == 'default'; | 368 return selectedItem != null && selectedItem.dataset.type == 'default'; |
| 376 }, | 369 }, |
| 377 | 370 |
| 378 /** | 371 /** |
| 379 * @param {!settings.ChangePictureImageElement} selectedItem | 372 * @param {!settings.ChangePictureImageElement} selectedItem |
| 380 * @param {!Array<!settings.DefaultImage>} defaultImages | 373 * @param {!Array<!settings.DefaultImage>} defaultImages |
| 381 * @return {string} The author name for the selected default image. An empty | 374 * @return {string} The author name for the selected default image. An empty |
| 382 * string is returned if there is no valid author name. | 375 * string is returned if there is no valid author name. |
| 383 * @private | 376 * @private |
| 384 */ | 377 */ |
| 385 getAuthorName_: function(selectedItem, defaultImages) { | 378 getAuthorName_: function(selectedItem, defaultImages) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 400 */ | 393 */ |
| 401 getAuthorWebsite_: function(selectedItem, defaultImages) { | 394 getAuthorWebsite_: function(selectedItem, defaultImages) { |
| 402 if (!this.isAuthorCreditShown_(selectedItem)) | 395 if (!this.isAuthorCreditShown_(selectedItem)) |
| 403 return ''; | 396 return ''; |
| 404 | 397 |
| 405 assert(selectedItem.dataset.defaultImageIndex !== null && | 398 assert(selectedItem.dataset.defaultImageIndex !== null && |
| 406 selectedItem.dataset.defaultImageIndex < defaultImages.length); | 399 selectedItem.dataset.defaultImageIndex < defaultImages.length); |
| 407 return defaultImages[selectedItem.dataset.defaultImageIndex].website; | 400 return defaultImages[selectedItem.dataset.defaultImageIndex].website; |
| 408 }, | 401 }, |
| 409 }); | 402 }); |
| OLD | NEW |