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

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

Issue 1610973002: Settings People Revamp: Implement Change People preview pane (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0072-settings-add-tests-for-cros-choose-picture
Patch Set: Created 4 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 cr.define('settings_test', function() { 5 cr.define('settings_test', function() {
6 var changePictureOptions = settings_test.changePictureOptions || { 6 var changePictureOptions = settings_test.changePictureOptions || {
7 /** 7 /**
8 * True if property changes should fire events for testing purposes. 8 * True if property changes should fire events for testing purposes.
9 * @type {boolean} 9 * @type {boolean}
10 */ 10 */
(...skipping 21 matching lines...) Expand all
32 /** 32 /**
33 * The currently selected profile image URL. May be a data URL. 33 * The currently selected profile image URL. May be a data URL.
34 * @private {string} 34 * @private {string}
35 */ 35 */
36 selectedImageUrl_: { 36 selectedImageUrl_: {
37 type: String, 37 type: String,
38 notify: settings_test.changePictureOptions.notifyPropertyChangesForTest, 38 notify: settings_test.changePictureOptions.notifyPropertyChangesForTest,
39 }, 39 },
40 40
41 /** 41 /**
42 * True only if the user has selected the camera icon. Old photos captured
43 * from the camera are represented as the 'old' image.
44 * @private {boolean}
45 */
46 cameraActive_: {
47 type: Boolean,
48 value: false,
49 },
50
51 /**
52 * This differs from its default value only if the user has just captured
53 * a new photo from the camera.
54 * @private {string}
55 */
56 cameraImageUrl_: {
57 type: String,
58 value: settings.ChangePicturePrivateApi.ButtonImages.TAKE_PHOTO,
59 },
60
61 /**
62 * This differs from its default value only if the user has just captured
63 * a new photo from the camera.
64 * @private {string}
65 */
66 cameraImageTitle_: {
67 type: String,
68 value: function() { return loadTimeData.getString('takePhoto'); },
69 },
70
71 /**
42 * The url of the 'old' image, which is the existing image sourced from 72 * The url of the 'old' image, which is the existing image sourced from
43 * the camera, a file, or a deprecated default image. 73 * the camera, a file, or a deprecated default image.
44 * @private {string} 74 * @private {string}
45 */ 75 */
46 oldImageUrl_: String, 76 oldImageUrl_: String,
47 77
48 /** 78 /**
49 * The url of the profile image. 79 * The url of the profile image.
50 * @private {string} 80 * @private {string}
51 */ 81 */
(...skipping 22 matching lines...) Expand all
74 */ 104 */
75 receiveDefaultImages: function(images) { 105 receiveDefaultImages: function(images) {
76 this.defaultImages_ = images; 106 this.defaultImages_ = images;
77 }.bind(this), 107 }.bind(this),
78 108
79 /** 109 /**
80 * Called from C++ to provide the URL of the selected image. 110 * Called from C++ to provide the URL of the selected image.
81 * @param {string} imageUrl 111 * @param {string} imageUrl
82 */ 112 */
83 receiveSelectedImage: function(imageUrl) { 113 receiveSelectedImage: function(imageUrl) {
114 this.cameraActive_ = false;
84 this.selectedImageUrl_ = imageUrl; 115 this.selectedImageUrl_ = imageUrl;
85 }.bind(this), 116 }.bind(this),
86 117
87 /** 118 /**
88 * Called from C++ to provide the URL of the 'old' image. The 'old' 119 * Called from C++ to provide the URL of the 'old' image. The 'old'
89 * image is any selected non-profile and non-default image. It can be 120 * image is any selected non-profile and non-default image. It can be
90 * from the camera, a file, or a deprecated default image. When this 121 * from the camera, a file, or a deprecated default image. When this
91 * method is called, it's implied that the old image is selected. 122 * method is called, it's implied that the old image is selected.
92 * @param {string} imageUrl 123 * @param {string} imageUrl
93 */ 124 */
94 receiveOldImage: function(imageUrl) { 125 receiveOldImage: function(imageUrl) {
126 this.cameraActive_ = false;
95 this.oldImageUrl_ = imageUrl; 127 this.oldImageUrl_ = imageUrl;
96 this.selectedImageUrl_ = imageUrl; 128 this.selectedImageUrl_ = imageUrl;
97 }.bind(this), 129 }.bind(this),
98 130
99 /** 131 /**
100 * Called from C++ to provide the URL of the profile image. 132 * Called from C++ to provide the URL of the profile image.
101 * @param {string} imageUrl 133 * @param {string} imageUrl
102 * @param {boolean} selected 134 * @param {boolean} selected
103 */ 135 */
104 receiveProfileImage: function(imageUrl, selected) { 136 receiveProfileImage: function(imageUrl, selected) {
105 this.profileImageUrl_ = imageUrl; 137 this.profileImageUrl_ = imageUrl;
106 if (selected) 138 if (selected) {
139 this.cameraActive_ = false;
107 this.selectedImageUrl_ = imageUrl; 140 this.selectedImageUrl_ = imageUrl;
141 }
108 }.bind(this), 142 }.bind(this),
109 143
110 /** 144 /**
111 * Called from the C++ to notify page about camera presence. 145 * Called from the C++ to notify page about camera presence.
112 * @param {boolean} cameraPresent 146 * @param {boolean} cameraPresent
113 */ 147 */
114 receiveCameraPresence: function(cameraPresent) { 148 receiveCameraPresence: function(cameraPresent) {
115 // TODO(tommycli): Implement camera functionality. 149 // TODO(tommycli): Implement camera functionality.
116 }.bind(this), 150 }.bind(this),
117 }; 151 };
118 152
119 cr.define('settings', function() { 153 cr.define('settings', function() {
120 var ChangePicturePage = nativeInterface; 154 var ChangePicturePage = nativeInterface;
121 return { 155 return {
122 ChangePicturePage: ChangePicturePage, 156 ChangePicturePage: ChangePicturePage,
123 }; 157 };
124 }); 158 });
125 159
126 settings.ChangePicturePrivateApi.initialize(); 160 settings.ChangePicturePrivateApi.initialize();
127 }, 161 },
128 162
129 /** 163 /**
164 * Handler for when the user clicks the camera image.
165 * @private
166 */
167 onCameraImageTap_: function() {
168 this.cameraActive_ = true;
169 },
170
171 /**
130 * Handler for when the user clicks a new profile image. 172 * Handler for when the user clicks a new profile image.
131 * @private 173 * @private
132 * @param {!Event} event 174 * @param {!Event} event
133 */ 175 */
134 onDefaultImageTap_: function(event) { 176 onDefaultImageTap_: function(event) {
135 var element = Polymer.dom(event).rootTarget; 177 var element = Polymer.dom(event).rootTarget;
136 178
137 var imageUrl = null; 179 var imageUrl = null;
138 if (element.nodeName == 'IMG') 180 if (element.nodeName == 'IMG')
139 imageUrl = element.src; 181 imageUrl = element.src;
(...skipping 29 matching lines...) Expand all
169 event.preventDefault(); 211 event.preventDefault();
170 }, 212 },
171 213
172 /** 214 /**
173 * Computed binding determining which profile image button is toggled on. 215 * Computed binding determining which profile image button is toggled on.
174 * @private 216 * @private
175 * @param {string} imageUrl 217 * @param {string} imageUrl
176 * @param {string} selectedImageUrl 218 * @param {string} selectedImageUrl
177 * @return {boolean} 219 * @return {boolean}
178 */ 220 */
179 isActiveImage_: function(imageUrl, selectedImageUrl) { 221 isActiveImage_: function(cameraActive, imageUrl, selectedImageUrl) {
180 return imageUrl == selectedImageUrl; 222 return !cameraActive && (imageUrl == selectedImageUrl);
181 }, 223 },
182 }); 224 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698