Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: chrome/browser/resources/settings/people_page/change_picture.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 /** 93 /**
92 * The fallback image to be selected when the user discards the Old image. 94 * The fallback image to be selected when the user discards the Old image.
93 * This may be null if the user started with the Old image. 95 * This may be null if the user started with the Old image.
94 * @private {?ChangePictureImageElement} 96 * @private {?ChangePictureImageElement}
95 */ 97 */
96 fallbackImage_: Object, 98 fallbackImage_: Object,
97 99
98 /** 100 /**
(...skipping 17 matching lines...) Expand all
116 browserProxy_: { 118 browserProxy_: {
117 type: Object, 119 type: Object,
118 value: function() { 120 value: function() {
119 return settings.ChangePictureBrowserProxyImpl.getInstance(); 121 return settings.ChangePictureBrowserProxyImpl.getInstance();
120 }, 122 },
121 }, 123 },
122 }, 124 },
123 125
124 /** @override */ 126 /** @override */
125 attached: function() { 127 attached: function() {
126 this.addWebUIListener('default-images-changed', 128 this.addWebUIListener(
127 this.receiveDefaultImages_.bind(this)); 129 'default-images-changed', this.receiveDefaultImages_.bind(this));
128 this.addWebUIListener('selected-image-changed', 130 this.addWebUIListener(
129 this.receiveSelectedImage_.bind(this)); 131 'selected-image-changed', this.receiveSelectedImage_.bind(this));
130 this.addWebUIListener('old-image-changed', 132 this.addWebUIListener(
131 this.receiveOldImage_.bind(this)); 133 'old-image-changed', this.receiveOldImage_.bind(this));
132 this.addWebUIListener('profile-image-changed', 134 this.addWebUIListener(
133 this.receiveProfileImage_.bind(this)); 135 'profile-image-changed', this.receiveProfileImage_.bind(this));
134 this.addWebUIListener('camera-presence-changed', 136 this.addWebUIListener(
135 this.receiveCameraPresence_.bind(this)); 137 'camera-presence-changed', this.receiveCameraPresence_.bind(this));
136 }, 138 },
137 139
138 140
139 /** @protected */ 141 /** @protected */
140 currentRouteChanged: function(newRoute) { 142 currentRouteChanged: function(newRoute) {
141 // Reset the selection state when we navigate to this page. 143 // Reset the selection state when we navigate to this page.
142 if (newRoute == settings.Route.CHANGE_PICTURE) { 144 if (newRoute == settings.Route.CHANGE_PICTURE) {
143 this.browserProxy_.initialize(); 145 this.browserProxy_.initialize();
144 } else { 146 } else {
145 // Ensure we deactivate the camera when we navigate away. 147 // Ensure we deactivate the camera when we navigate away.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 this.lastSelectedImageType_ = this.selectedItem_.dataset.type; 295 this.lastSelectedImageType_ = this.selectedItem_.dataset.type;
294 e.detail.keyboardEvent.preventDefault(); 296 e.detail.keyboardEvent.preventDefault();
295 break; 297 break;
296 298
297 case 'enter': 299 case 'enter':
298 case 'space': 300 case 'space':
299 if (this.selectedItem_.dataset.type == 301 if (this.selectedItem_.dataset.type ==
300 ChangePictureSelectionTypes.CAMERA) { 302 ChangePictureSelectionTypes.CAMERA) {
301 var /** SettingsCameraElement */ camera = this.$.camera; 303 var /** SettingsCameraElement */ camera = this.$.camera;
302 camera.takePhoto(); 304 camera.takePhoto();
303 } else if (this.selectedItem_.dataset.type == 305 } else if (
304 ChangePictureSelectionTypes.FILE) { 306 this.selectedItem_.dataset.type ==
307 ChangePictureSelectionTypes.FILE) {
305 this.browserProxy_.chooseFile(); 308 this.browserProxy_.chooseFile();
306 } else if (this.selectedItem_.dataset.type == 309 } else if (
307 ChangePictureSelectionTypes.OLD) { 310 this.selectedItem_.dataset.type ==
311 ChangePictureSelectionTypes.OLD) {
308 this.onTapDiscardOldImage_(); 312 this.onTapDiscardOldImage_();
309 } 313 }
310 break; 314 break;
311 } 315 }
312 }, 316 },
313 317
314 /** 318 /**
315 * Handler for when the an image is activated. 319 * Handler for when the an image is activated.
316 * @param {!Event} event 320 * @param {!Event} event
317 * @private 321 * @private
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 358
355 announceAccessibleMessage(this.i18n('photoDiscardAccessibleText')); 359 announceAccessibleMessage(this.i18n('photoDiscardAccessibleText'));
356 }, 360 },
357 361
358 /** 362 /**
359 * @param {string} oldImageUrl 363 * @param {string} oldImageUrl
360 * @return {boolean} True if there is no Old image and the Old image icon 364 * @return {boolean} True if there is no Old image and the Old image icon
361 * should be hidden. 365 * should be hidden.
362 * @private 366 * @private
363 */ 367 */
364 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; }, 368 isOldImageHidden_: function(oldImageUrl) {
369 return oldImageUrl.length == 0;
370 },
365 371
366 /** 372 /**
367 * @param {ChangePictureImageElement} selectedItem 373 * @param {ChangePictureImageElement} selectedItem
368 * @return {boolean} True if the preview image should be hidden. 374 * @return {boolean} True if the preview image should be hidden.
369 * @private 375 * @private
370 */ 376 */
371 isPreviewImageHidden_: function(selectedItem) { 377 isPreviewImageHidden_: function(selectedItem) {
372 if (!selectedItem) 378 if (!selectedItem)
373 return true; 379 return true;
374 380
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 * @param {!ChangePictureImageElement} selectedItem 419 * @param {!ChangePictureImageElement} selectedItem
414 * @param {!Array<!settings.DefaultImage>} defaultImages 420 * @param {!Array<!settings.DefaultImage>} defaultImages
415 * @return {string} The author name for the selected default image. An empty 421 * @return {string} The author name for the selected default image. An empty
416 * string is returned if there is no valid author name. 422 * string is returned if there is no valid author name.
417 * @private 423 * @private
418 */ 424 */
419 getAuthorName_: function(selectedItem, defaultImages) { 425 getAuthorName_: function(selectedItem, defaultImages) {
420 if (!this.isAuthorCreditShown_(selectedItem)) 426 if (!this.isAuthorCreditShown_(selectedItem))
421 return ''; 427 return '';
422 428
423 assert(selectedItem.dataset.defaultImageIndex !== null && 429 assert(
424 selectedItem.dataset.defaultImageIndex < defaultImages.length); 430 selectedItem.dataset.defaultImageIndex !== null &&
431 selectedItem.dataset.defaultImageIndex < defaultImages.length);
425 return defaultImages[selectedItem.dataset.defaultImageIndex].author; 432 return defaultImages[selectedItem.dataset.defaultImageIndex].author;
426 }, 433 },
427 434
428 /** 435 /**
429 * @param {!ChangePictureImageElement} selectedItem 436 * @param {!ChangePictureImageElement} selectedItem
430 * @param {!Array<!settings.DefaultImage>} defaultImages 437 * @param {!Array<!settings.DefaultImage>} defaultImages
431 * @return {string} The author website for the selected default image. An 438 * @return {string} The author website for the selected default image. An
432 * empty string is returned if there is no valid author name. 439 * empty string is returned if there is no valid author name.
433 * @private 440 * @private
434 */ 441 */
435 getAuthorWebsite_: function(selectedItem, defaultImages) { 442 getAuthorWebsite_: function(selectedItem, defaultImages) {
436 if (!this.isAuthorCreditShown_(selectedItem)) 443 if (!this.isAuthorCreditShown_(selectedItem))
437 return ''; 444 return '';
438 445
439 assert(selectedItem.dataset.defaultImageIndex !== null && 446 assert(
440 selectedItem.dataset.defaultImageIndex < defaultImages.length); 447 selectedItem.dataset.defaultImageIndex !== null &&
448 selectedItem.dataset.defaultImageIndex < defaultImages.length);
441 return defaultImages[selectedItem.dataset.defaultImageIndex].website; 449 return defaultImages[selectedItem.dataset.defaultImageIndex].website;
442 }, 450 },
443 }); 451 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698