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

Side by Side Diff: chrome/browser/resources/options/chromeos/change_picture_options.js

Issue 8879015: [cros] Profile image no longer selected when user clicks Take Photo/Choose File buttons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style-ish fixes. Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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('options', function() { 5 cr.define('options', function() {
6 6
7 var OptionsPage = options.OptionsPage; 7 var OptionsPage = options.OptionsPage;
8 var UserImagesGrid = options.UserImagesGrid; 8 var UserImagesGrid = options.UserImagesGrid;
9 var ButtonImages = UserImagesGrid.ButtonImages; 9 var ButtonImages = UserImagesGrid.ButtonImages;
10 10
(...skipping 30 matching lines...) Expand all
41 /** 41 /**
42 * Initializes ChangePictureOptions page. 42 * Initializes ChangePictureOptions page.
43 */ 43 */
44 initializePage: function() { 44 initializePage: function() {
45 // Call base class implementation to start preferences initialization. 45 // Call base class implementation to start preferences initialization.
46 OptionsPage.prototype.initializePage.call(this); 46 OptionsPage.prototype.initializePage.call(this);
47 47
48 var imageGrid = $('images-grid'); 48 var imageGrid = $('images-grid');
49 UserImagesGrid.decorate(imageGrid); 49 UserImagesGrid.decorate(imageGrid);
50 50
51 imageGrid.addEventListener('change', function(e) { 51 imageGrid.addEventListener('change',
52 // Ignore programmatical selection. 52 this.handleImageSelected_.bind(this));
53 if (!imageGrid.inProgramSelection) {
54 // Button selections will be ignored by Chrome handler.
55 chrome.send('selectImage', [this.selectedItemUrl || '']);
56 }
57 });
58 imageGrid.addEventListener('activate', 53 imageGrid.addEventListener('activate',
59 this.handleImageActivated_.bind(this)); 54 this.handleImageActivated_.bind(this));
60 imageGrid.addEventListener('dblclick', 55 imageGrid.addEventListener('dblclick',
61 this.handleImageDblClick_.bind(this)); 56 this.handleImageDblClick_.bind(this));
62 57
63 // Add the "Choose file" button. 58 // Add the "Choose file" button.
64 imageGrid.addItem(ButtonImages.CHOOSE_FILE, 59 imageGrid.addItem(ButtonImages.CHOOSE_FILE,
65 localStrings.getString('chooseFile'), 60 localStrings.getString('chooseFile'),
66 this.handleChooseFile_.bind(this)); 61 this.handleChooseFile_.bind(this));
67 62
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 /** 108 /**
114 * Handles "Choose a file" button activation. 109 * Handles "Choose a file" button activation.
115 * @private 110 * @private
116 */ 111 */
117 handleChooseFile_: function() { 112 handleChooseFile_: function() {
118 chrome.send('chooseFile'); 113 chrome.send('chooseFile');
119 this.closePage_(); 114 this.closePage_();
120 }, 115 },
121 116
122 /** 117 /**
118 * Handles image selection change.
119 * @private
120 */
121 handleImageSelected_: function() {
122 var imageGrid = $('images-grid');
123 var url = imageGrid.selectedItemUrl;
124 // Ignore deselection, selection change caused by program itself and
125 // selection of one of the action buttons.
126 if (url &&
127 !imageGrid.inProgramSelection &&
128 ButtonImageUrls.indexOf(url) == -1) {
129 chrome.send('selectImage', [url]);
130 }
131 },
132
133 /**
123 * Handles image activation (by pressing Enter). 134 * Handles image activation (by pressing Enter).
124 * @private 135 * @private
125 */ 136 */
126 handleImageActivated_: function() { 137 handleImageActivated_: function() {
127 switch ($('images-grid').selectedItemUrl) { 138 switch ($('images-grid').selectedItemUrl) {
128 case ButtonImages.TAKE_PHOTO: 139 case ButtonImages.TAKE_PHOTO:
129 this.handleTakePhoto_(); 140 this.handleTakePhoto_();
130 break; 141 break;
131 case ButtonImages.CHOOSE_FILE: 142 case ButtonImages.CHOOSE_FILE:
132 this.handleChooseFile_(); 143 this.handleChooseFile_();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 }; 255 };
245 }); 256 });
246 257
247 // Export 258 // Export
248 return { 259 return {
249 ChangePictureOptions: ChangePictureOptions 260 ChangePictureOptions: ChangePictureOptions
250 }; 261 };
251 262
252 }); 263 });
253 264
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698