| 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 /** | 5 /** |
| 6 * Contains the possible types of Change Picture selections. | 6 * Contains the possible types of Change Picture selections. |
| 7 * @enum {string} | 7 * @enum {string} |
| 8 */ | 8 */ |
| 9 var ChangePictureSelectionTypes = { | 9 var ChangePictureSelectionTypes = { |
| 10 CAMERA: 'camera', | 10 CAMERA: 'camera', |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 type: String, | 78 type: String, |
| 79 value: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING', | 79 value: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING', |
| 80 }, | 80 }, |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * The default user images. | 83 * The default user images. |
| 84 * @private {!Array<!settings.DefaultImage>} | 84 * @private {!Array<!settings.DefaultImage>} |
| 85 */ | 85 */ |
| 86 defaultImages_: { | 86 defaultImages_: { |
| 87 type: Array, | 87 type: Array, |
| 88 value: function() { return []; }, | 88 value: function() { |
| 89 return []; |
| 90 }, |
| 89 }, | 91 }, |
| 90 | 92 |
| 91 /** @private */ | 93 /** @private */ |
| 92 selectionTypesEnum_: { | 94 selectionTypesEnum_: { |
| 93 type: Object, | 95 type: Object, |
| 94 value: ChangePictureSelectionTypes, | 96 value: ChangePictureSelectionTypes, |
| 95 readOnly: true, | 97 readOnly: true, |
| 96 }, | 98 }, |
| 97 }, | 99 }, |
| 98 | 100 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 113 */ | 115 */ |
| 114 lastSelectedImageType_: '', | 116 lastSelectedImageType_: '', |
| 115 | 117 |
| 116 /** @override */ | 118 /** @override */ |
| 117 ready: function() { | 119 ready: function() { |
| 118 this.browserProxy_ = settings.ChangePictureBrowserProxyImpl.getInstance(); | 120 this.browserProxy_ = settings.ChangePictureBrowserProxyImpl.getInstance(); |
| 119 }, | 121 }, |
| 120 | 122 |
| 121 /** @override */ | 123 /** @override */ |
| 122 attached: function() { | 124 attached: function() { |
| 123 this.addWebUIListener('default-images-changed', | 125 this.addWebUIListener( |
| 124 this.receiveDefaultImages_.bind(this)); | 126 'default-images-changed', this.receiveDefaultImages_.bind(this)); |
| 125 this.addWebUIListener('selected-image-changed', | 127 this.addWebUIListener( |
| 126 this.receiveSelectedImage_.bind(this)); | 128 'selected-image-changed', this.receiveSelectedImage_.bind(this)); |
| 127 this.addWebUIListener('old-image-changed', | 129 this.addWebUIListener( |
| 128 this.receiveOldImage_.bind(this)); | 130 'old-image-changed', this.receiveOldImage_.bind(this)); |
| 129 this.addWebUIListener('profile-image-changed', | 131 this.addWebUIListener( |
| 130 this.receiveProfileImage_.bind(this)); | 132 'profile-image-changed', this.receiveProfileImage_.bind(this)); |
| 131 this.addWebUIListener('camera-presence-changed', | 133 this.addWebUIListener( |
| 132 this.receiveCameraPresence_.bind(this)); | 134 'camera-presence-changed', this.receiveCameraPresence_.bind(this)); |
| 133 }, | 135 }, |
| 134 | 136 |
| 135 | 137 |
| 136 /** @protected */ | 138 /** @protected */ |
| 137 currentRouteChanged: function(newRoute) { | 139 currentRouteChanged: function(newRoute) { |
| 138 if (newRoute == settings.Route.CHANGE_PICTURE) { | 140 if (newRoute == settings.Route.CHANGE_PICTURE) { |
| 139 this.browserProxy_.initialize(); | 141 this.browserProxy_.initialize(); |
| 140 | 142 |
| 141 // This in needed because we manually clear the selectedItem_ property | 143 // This in needed because we manually clear the selectedItem_ property |
| 142 // when navigating away. The selector element doesn't fire its upward | 144 // when navigating away. The selector element doesn't fire its upward |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 this.lastSelectedImageType_ = this.selectedItem_.dataset.type; | 305 this.lastSelectedImageType_ = this.selectedItem_.dataset.type; |
| 304 e.detail.keyboardEvent.preventDefault(); | 306 e.detail.keyboardEvent.preventDefault(); |
| 305 break; | 307 break; |
| 306 | 308 |
| 307 case 'enter': | 309 case 'enter': |
| 308 case 'space': | 310 case 'space': |
| 309 if (this.selectedItem_.dataset.type == | 311 if (this.selectedItem_.dataset.type == |
| 310 ChangePictureSelectionTypes.CAMERA) { | 312 ChangePictureSelectionTypes.CAMERA) { |
| 311 var /** SettingsCameraElement */ camera = this.$.camera; | 313 var /** SettingsCameraElement */ camera = this.$.camera; |
| 312 camera.takePhoto(); | 314 camera.takePhoto(); |
| 313 } else if (this.selectedItem_.dataset.type == | 315 } else if ( |
| 314 ChangePictureSelectionTypes.FILE) { | 316 this.selectedItem_.dataset.type == |
| 317 ChangePictureSelectionTypes.FILE) { |
| 315 this.browserProxy_.chooseFile(); | 318 this.browserProxy_.chooseFile(); |
| 316 } else if (this.selectedItem_.dataset.type == | 319 } else if ( |
| 317 ChangePictureSelectionTypes.OLD) { | 320 this.selectedItem_.dataset.type == |
| 321 ChangePictureSelectionTypes.OLD) { |
| 318 this.onTapDiscardOldImage_(); | 322 this.onTapDiscardOldImage_(); |
| 319 } | 323 } |
| 320 break; | 324 break; |
| 321 } | 325 } |
| 322 }, | 326 }, |
| 323 | 327 |
| 324 /** | 328 /** |
| 325 * Handler for when the an image is activated. | 329 * Handler for when the an image is activated. |
| 326 * @param {!Event} event | 330 * @param {!Event} event |
| 327 * @private | 331 * @private |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 369 |
| 366 announceAccessibleMessage(this.i18n('photoDiscardAccessibleText')); | 370 announceAccessibleMessage(this.i18n('photoDiscardAccessibleText')); |
| 367 }, | 371 }, |
| 368 | 372 |
| 369 /** | 373 /** |
| 370 * @param {string} oldImageUrl | 374 * @param {string} oldImageUrl |
| 371 * @return {boolean} True if there is no Old image and the Old image icon | 375 * @return {boolean} True if there is no Old image and the Old image icon |
| 372 * should be hidden. | 376 * should be hidden. |
| 373 * @private | 377 * @private |
| 374 */ | 378 */ |
| 375 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; }, | 379 isOldImageHidden_: function(oldImageUrl) { |
| 380 return oldImageUrl.length == 0; |
| 381 }, |
| 376 | 382 |
| 377 /** | 383 /** |
| 378 * @param {ChangePictureImageElement} selectedItem | 384 * @param {ChangePictureImageElement} selectedItem |
| 379 * @return {boolean} True if the preview image should be hidden. | 385 * @return {boolean} True if the preview image should be hidden. |
| 380 * @private | 386 * @private |
| 381 */ | 387 */ |
| 382 isPreviewImageHidden_: function(selectedItem) { | 388 isPreviewImageHidden_: function(selectedItem) { |
| 383 if (!selectedItem) | 389 if (!selectedItem) |
| 384 return true; | 390 return true; |
| 385 | 391 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 * @param {!ChangePictureImageElement} selectedItem | 430 * @param {!ChangePictureImageElement} selectedItem |
| 425 * @param {!Array<!settings.DefaultImage>} defaultImages | 431 * @param {!Array<!settings.DefaultImage>} defaultImages |
| 426 * @return {string} The author name for the selected default image. An empty | 432 * @return {string} The author name for the selected default image. An empty |
| 427 * string is returned if there is no valid author name. | 433 * string is returned if there is no valid author name. |
| 428 * @private | 434 * @private |
| 429 */ | 435 */ |
| 430 getAuthorName_: function(selectedItem, defaultImages) { | 436 getAuthorName_: function(selectedItem, defaultImages) { |
| 431 if (!this.isAuthorCreditShown_(selectedItem)) | 437 if (!this.isAuthorCreditShown_(selectedItem)) |
| 432 return ''; | 438 return ''; |
| 433 | 439 |
| 434 assert(selectedItem.dataset.defaultImageIndex !== null && | 440 assert( |
| 435 selectedItem.dataset.defaultImageIndex < defaultImages.length); | 441 selectedItem.dataset.defaultImageIndex !== null && |
| 442 selectedItem.dataset.defaultImageIndex < defaultImages.length); |
| 436 return defaultImages[selectedItem.dataset.defaultImageIndex].author; | 443 return defaultImages[selectedItem.dataset.defaultImageIndex].author; |
| 437 }, | 444 }, |
| 438 | 445 |
| 439 /** | 446 /** |
| 440 * @param {!ChangePictureImageElement} selectedItem | 447 * @param {!ChangePictureImageElement} selectedItem |
| 441 * @param {!Array<!settings.DefaultImage>} defaultImages | 448 * @param {!Array<!settings.DefaultImage>} defaultImages |
| 442 * @return {string} The author website for the selected default image. An | 449 * @return {string} The author website for the selected default image. An |
| 443 * empty string is returned if there is no valid author name. | 450 * empty string is returned if there is no valid author name. |
| 444 * @private | 451 * @private |
| 445 */ | 452 */ |
| 446 getAuthorWebsite_: function(selectedItem, defaultImages) { | 453 getAuthorWebsite_: function(selectedItem, defaultImages) { |
| 447 if (!this.isAuthorCreditShown_(selectedItem)) | 454 if (!this.isAuthorCreditShown_(selectedItem)) |
| 448 return ''; | 455 return ''; |
| 449 | 456 |
| 450 assert(selectedItem.dataset.defaultImageIndex !== null && | 457 assert( |
| 451 selectedItem.dataset.defaultImageIndex < defaultImages.length); | 458 selectedItem.dataset.defaultImageIndex !== null && |
| 459 selectedItem.dataset.defaultImageIndex < defaultImages.length); |
| 452 return defaultImages[selectedItem.dataset.defaultImageIndex].website; | 460 return defaultImages[selectedItem.dataset.defaultImageIndex].website; |
| 453 }, | 461 }, |
| 454 }); | 462 }); |
| OLD | NEW |