Chromium Code Reviews| 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_: { |
|
dpapad
2016/04/09 00:16:35
Shouldn't this be
/**
* @private {settings.Cha
tommycli
2016/04/11 19:09:57
Done. Yes I think you are correct. I wonder what i
| |
| 51 type: settings.ChangePictureImageElement, | 51 type: settings.ChangePictureImageElement, |
| 52 notify: !!settings_test.changePictureNotifyForTest, | 52 value: null, |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * The url of the 'old' image, which is the existing image sourced from | 56 * 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 | 57 * 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 | 58 * empty string instead of undefined, because Polymer bindings don't behave |
| 59 * as expected with undefined properties. | 59 * as expected with undefined properties. |
| 60 * @private {string} | 60 * @private {string} |
| 61 */ | 61 */ |
| 62 oldImageUrl_: { | 62 oldImageUrl_: { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 81 type: Array, | 81 type: Array, |
| 82 value: function() { return []; }, | 82 value: function() { return []; }, |
| 83 }, | 83 }, |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * The fallback image to be selected when the user discards the 'old' image. | 86 * 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. | 87 * This may be null if the user started with the 'old' image. |
| 88 * @private {?settings.ChangePictureImageElement} | 88 * @private {?settings.ChangePictureImageElement} |
| 89 */ | 89 */ |
| 90 fallbackImage_: { | 90 fallbackImage_: { |
| 91 type: settings.ChangePictureImageElement, | 91 type: settings.ChangePictureImageElement, |
|
dpapad
2016/04/09 00:16:35
Same here.
tommycli
2016/04/11 19:09:57
Done.
| |
| 92 value: null, | 92 value: null, |
| 93 }, | 93 }, |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * Type of the last selected icon. This is used to jump back to the camera | 96 * Type of the last selected icon. This is used to jump back to the camera |
| 97 * after the user discards a newly taken photo. | 97 * after the user discards a newly taken photo. |
| 98 * @private {string} | 98 * @private {string} |
| 99 */ | 99 */ |
| 100 lastSelectedImageType_: { | 100 lastSelectedImageType_: { |
| 101 type: String, | 101 type: String, |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 if (this.fallbackImage_ != null) { | 315 if (this.fallbackImage_ != null) { |
| 316 this.selectImage_(this.fallbackImage_); | 316 this.selectImage_(this.fallbackImage_); |
| 317 return; | 317 return; |
| 318 } | 318 } |
| 319 | 319 |
| 320 // If the user has not chosen an image since opening the subpage and | 320 // If the user has not chosen an image since opening the subpage and |
| 321 // discards the current photo, select the first default image. | 321 // discards the current photo, select the first default image. |
| 322 assert(this.defaultImages_.length > 0); | 322 assert(this.defaultImages_.length > 0); |
| 323 this.browserProxy_.selectDefaultImage(this.defaultImages_[0].url); | 323 this.browserProxy_.selectDefaultImage(this.defaultImages_[0].url); |
| 324 | 324 |
| 325 announceAccessibleMessage( | 325 announceAccessibleMessage(this.i18n('photoDiscardAccessibleText')); |
| 326 loadTimeData.getString('photoDiscardAccessibleText')); | |
| 327 }, | 326 }, |
| 328 | 327 |
| 329 /** | 328 /** |
| 330 * @param {string} oldImageUrl | 329 * @param {string} oldImageUrl |
| 331 * @return {boolean} True if there is no old image and the old image icon | 330 * @return {boolean} True if there is no old image and the old image icon |
| 332 * should be hidden. | 331 * should be hidden. |
| 333 * @private | 332 * @private |
| 334 */ | 333 */ |
| 335 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; }, | 334 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; }, |
| 336 | 335 |
| 337 /** | 336 /** |
| 338 * @param {settings.ChangePictureImageElement} selectedItem | 337 * @param {settings.ChangePictureImageElement} selectedItem |
| 339 * @return {boolean} True if the preview image should be hidden. | 338 * @return {boolean} True if the preview image should be hidden. |
| 340 * @private | 339 * @private |
| 341 */ | 340 */ |
| 342 isPreviewImageHidden_: function(selectedItem) { | 341 isPreviewImageHidden_: function(selectedItem) { |
| 343 if (!selectedItem) | 342 if (!selectedItem) |
| 344 return true; | 343 return true; |
| 345 | 344 |
| 346 var type = selectedItem.dataset.type; | 345 var type = selectedItem.dataset.type; |
| 347 return type != 'default' && type != 'profile' && type != 'old'; | 346 return type != 'default' && type != 'profile' && type != 'old'; |
| 348 }, | 347 }, |
| 349 | 348 |
| 350 /** | 349 /** |
| 351 * @param {settings.ChangePictureImageElement} selectedItem | 350 * @param {settings.ChangePictureImageElement} selectedItem |
| 352 * @return {boolean} True if the camera is selected in the image grid. | 351 * @return {boolean} True if the camera is selected in the image grid. |
| 353 * @private | 352 * @private |
| 354 */ | 353 */ |
| 355 isCameraActive_: function(cameraPresent, selectedItem) { | 354 isCameraActive_: function(cameraPresent, selectedItem) { |
| 356 return cameraPresent && selectedItem && | 355 return cameraPresent && selectedItem != null && |
|
dpapad
2016/04/09 00:16:35
Nit (optional): Use "!==" instead of "!=".
tommycli
2016/04/11 19:09:57
This didn't work for me because even with the valu
dpapad
2016/04/11 19:36:38
That is odd. Polymer data bindings guarantee that
tommycli
2016/04/11 21:20:52
I investigated this in detail. Basically: when iro
dpapad
2016/04/11 21:29:33
Thanks for investigating!
| |
| 357 selectedItem.dataset.type == 'camera'; | 356 selectedItem.dataset.type == 'camera'; |
| 358 }, | 357 }, |
| 359 | 358 |
| 360 /** | 359 /** |
| 361 * @param {settings.ChangePictureImageElement} selectedItem | 360 * @param {settings.ChangePictureImageElement} selectedItem |
| 362 * @return {boolean} True if the discard controls should be hidden. | 361 * @return {boolean} True if the discard controls should be hidden. |
| 363 * @private | 362 * @private |
| 364 */ | 363 */ |
| 365 isDiscardHidden_: function(selectedItem) { | 364 isDiscardHidden_: function(selectedItem) { |
| 366 return !selectedItem || selectedItem.dataset.type != 'old'; | 365 return !selectedItem || selectedItem.dataset.type != 'old'; |
| 367 }, | 366 }, |
| 368 | 367 |
| 369 /** | 368 /** |
| 370 * @param {settings.ChangePictureImageElement} selectedItem | 369 * @param {settings.ChangePictureImageElement} selectedItem |
| 371 * @return {boolean} True if the author credit text is shown. | 370 * @return {boolean} True if the author credit text is shown. |
| 372 * @private | 371 * @private |
| 373 */ | 372 */ |
| 374 isAuthorCreditShown_: function(selectedItem) { | 373 isAuthorCreditShown_: function(selectedItem) { |
| 375 return selectedItem && selectedItem.dataset.type == 'default'; | 374 return selectedItem != null && selectedItem.dataset.type == 'default'; |
| 376 }, | 375 }, |
| 377 | 376 |
| 378 /** | 377 /** |
| 379 * @param {!settings.ChangePictureImageElement} selectedItem | 378 * @param {!settings.ChangePictureImageElement} selectedItem |
| 380 * @param {!Array<!settings.DefaultImage>} defaultImages | 379 * @param {!Array<!settings.DefaultImage>} defaultImages |
| 381 * @return {string} The author name for the selected default image. An empty | 380 * @return {string} The author name for the selected default image. An empty |
| 382 * string is returned if there is no valid author name. | 381 * string is returned if there is no valid author name. |
| 383 * @private | 382 * @private |
| 384 */ | 383 */ |
| 385 getAuthorName_: function(selectedItem, defaultImages) { | 384 getAuthorName_: function(selectedItem, defaultImages) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 400 */ | 399 */ |
| 401 getAuthorWebsite_: function(selectedItem, defaultImages) { | 400 getAuthorWebsite_: function(selectedItem, defaultImages) { |
| 402 if (!this.isAuthorCreditShown_(selectedItem)) | 401 if (!this.isAuthorCreditShown_(selectedItem)) |
| 403 return ''; | 402 return ''; |
| 404 | 403 |
| 405 assert(selectedItem.dataset.defaultImageIndex !== null && | 404 assert(selectedItem.dataset.defaultImageIndex !== null && |
| 406 selectedItem.dataset.defaultImageIndex < defaultImages.length); | 405 selectedItem.dataset.defaultImageIndex < defaultImages.length); |
| 407 return defaultImages[selectedItem.dataset.defaultImageIndex].website; | 406 return defaultImages[selectedItem.dataset.defaultImageIndex].website; |
| 408 }, | 407 }, |
| 409 }); | 408 }); |
| OLD | NEW |