| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @fileoverview | 30 * @fileoverview |
| 31 * 'settings-change-picture' is the settings subpage containing controls to | 31 * 'settings-change-picture' is the settings subpage containing controls to |
| 32 * edit a ChromeOS user's picture. | 32 * edit a ChromeOS user's picture. |
| 33 */ | 33 */ |
| 34 Polymer({ | 34 Polymer({ |
| 35 is: 'settings-change-picture', | 35 is: 'settings-change-picture', |
| 36 | 36 |
| 37 behaviors: [ | 37 behaviors: [ |
| 38 settings.RouteObserverBehavior, |
| 38 I18nBehavior, | 39 I18nBehavior, |
| 39 WebUIListenerBehavior, | 40 WebUIListenerBehavior, |
| 40 ], | 41 ], |
| 41 | 42 |
| 42 properties: { | 43 properties: { |
| 43 /** | 44 /** |
| 44 * True if the user has a plugged-in webcam. | 45 * True if the user has a plugged-in webcam. |
| 45 * @private {boolean} | 46 * @private {boolean} |
| 46 */ | 47 */ |
| 47 cameraPresent_: { | 48 cameraPresent_: { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 this.addWebUIListener('default-images-changed', | 126 this.addWebUIListener('default-images-changed', |
| 126 this.receiveDefaultImages_.bind(this)); | 127 this.receiveDefaultImages_.bind(this)); |
| 127 this.addWebUIListener('selected-image-changed', | 128 this.addWebUIListener('selected-image-changed', |
| 128 this.receiveSelectedImage_.bind(this)); | 129 this.receiveSelectedImage_.bind(this)); |
| 129 this.addWebUIListener('old-image-changed', | 130 this.addWebUIListener('old-image-changed', |
| 130 this.receiveOldImage_.bind(this)); | 131 this.receiveOldImage_.bind(this)); |
| 131 this.addWebUIListener('profile-image-changed', | 132 this.addWebUIListener('profile-image-changed', |
| 132 this.receiveProfileImage_.bind(this)); | 133 this.receiveProfileImage_.bind(this)); |
| 133 this.addWebUIListener('camera-presence-changed', | 134 this.addWebUIListener('camera-presence-changed', |
| 134 this.receiveCameraPresence_.bind(this)); | 135 this.receiveCameraPresence_.bind(this)); |
| 136 }, |
| 135 | 137 |
| 136 this.browserProxy_.initialize(); | 138 |
| 139 /** @protected */ |
| 140 currentRouteChanged: function(newRoute) { |
| 141 // Reset the selection state when we navigate to this page. |
| 142 if (newRoute == settings.Route.CHANGE_PICTURE) { |
| 143 this.browserProxy_.initialize(); |
| 144 } else { |
| 145 // Ensure we deactivate the camera when we navigate away. |
| 146 this.selectedItem_ = null; |
| 147 } |
| 137 }, | 148 }, |
| 138 | 149 |
| 139 /** | 150 /** |
| 140 * Handler for the 'default-images-changed' event. | 151 * Handler for the 'default-images-changed' event. |
| 141 * @param {!Array<!settings.DefaultImage>} images | 152 * @param {!Array<!settings.DefaultImage>} images |
| 142 * @private | 153 * @private |
| 143 */ | 154 */ |
| 144 receiveDefaultImages_: function(images) { | 155 receiveDefaultImages_: function(images) { |
| 145 this.defaultImages_ = images; | 156 this.defaultImages_ = images; |
| 146 }, | 157 }, |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 type != ChangePictureSelectionTypes.OLD; | 378 type != ChangePictureSelectionTypes.OLD; |
| 368 }, | 379 }, |
| 369 | 380 |
| 370 /** | 381 /** |
| 371 * @param {boolean} cameraPresent | 382 * @param {boolean} cameraPresent |
| 372 * @param {ChangePictureImageElement} selectedItem | 383 * @param {ChangePictureImageElement} selectedItem |
| 373 * @return {boolean} True if the camera is selected in the image grid. | 384 * @return {boolean} True if the camera is selected in the image grid. |
| 374 * @private | 385 * @private |
| 375 */ | 386 */ |
| 376 isCameraActive_: function(cameraPresent, selectedItem) { | 387 isCameraActive_: function(cameraPresent, selectedItem) { |
| 377 return cameraPresent && selectedItem && | 388 return cameraPresent && !!selectedItem && |
| 378 selectedItem.dataset.type == ChangePictureSelectionTypes.CAMERA; | 389 selectedItem.dataset.type == ChangePictureSelectionTypes.CAMERA; |
| 379 }, | 390 }, |
| 380 | 391 |
| 381 /** | 392 /** |
| 382 * @param {ChangePictureImageElement} selectedItem | 393 * @param {ChangePictureImageElement} selectedItem |
| 383 * @return {boolean} True if the discard controls should be hidden. | 394 * @return {boolean} True if the discard controls should be hidden. |
| 384 * @private | 395 * @private |
| 385 */ | 396 */ |
| 386 isDiscardHidden_: function(selectedItem) { | 397 isDiscardHidden_: function(selectedItem) { |
| 387 return !selectedItem || | 398 return !selectedItem || |
| 388 selectedItem.dataset.type != ChangePictureSelectionTypes.OLD; | 399 selectedItem.dataset.type != ChangePictureSelectionTypes.OLD; |
| 389 }, | 400 }, |
| 390 | 401 |
| 391 /** | 402 /** |
| 392 * @param {ChangePictureImageElement} selectedItem | 403 * @param {ChangePictureImageElement} selectedItem |
| 393 * @return {boolean} True if the author credit text is shown. | 404 * @return {boolean} True if the author credit text is shown. |
| 394 * @private | 405 * @private |
| 395 */ | 406 */ |
| 396 isAuthorCreditShown_: function(selectedItem) { | 407 isAuthorCreditShown_: function(selectedItem) { |
| 397 return selectedItem && | 408 return !!selectedItem && |
| 398 selectedItem.dataset.type == ChangePictureSelectionTypes.DEFAULT; | 409 selectedItem.dataset.type == ChangePictureSelectionTypes.DEFAULT; |
| 399 }, | 410 }, |
| 400 | 411 |
| 401 /** | 412 /** |
| 402 * @param {!ChangePictureImageElement} selectedItem | 413 * @param {!ChangePictureImageElement} selectedItem |
| 403 * @param {!Array<!settings.DefaultImage>} defaultImages | 414 * @param {!Array<!settings.DefaultImage>} defaultImages |
| 404 * @return {string} The author name for the selected default image. An empty | 415 * @return {string} The author name for the selected default image. An empty |
| 405 * string is returned if there is no valid author name. | 416 * string is returned if there is no valid author name. |
| 406 * @private | 417 * @private |
| 407 */ | 418 */ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 423 */ | 434 */ |
| 424 getAuthorWebsite_: function(selectedItem, defaultImages) { | 435 getAuthorWebsite_: function(selectedItem, defaultImages) { |
| 425 if (!this.isAuthorCreditShown_(selectedItem)) | 436 if (!this.isAuthorCreditShown_(selectedItem)) |
| 426 return ''; | 437 return ''; |
| 427 | 438 |
| 428 assert(selectedItem.dataset.defaultImageIndex !== null && | 439 assert(selectedItem.dataset.defaultImageIndex !== null && |
| 429 selectedItem.dataset.defaultImageIndex < defaultImages.length); | 440 selectedItem.dataset.defaultImageIndex < defaultImages.length); |
| 430 return defaultImages[selectedItem.dataset.defaultImageIndex].website; | 441 return defaultImages[selectedItem.dataset.defaultImageIndex].website; |
| 431 }, | 442 }, |
| 432 }); | 443 }); |
| OLD | NEW |