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

Side by Side Diff: chrome/browser/resources/options/browser_options_startup_page_list.js

Issue 12548008: Really fix crash when dragging and dropping in chrome://settings/startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Snip Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.browser_options', function() { 5 cr.define('options.browser_options', function() {
6 /** @const */ var AutocompleteList = cr.ui.AutocompleteList; 6 /** @const */ var AutocompleteList = cr.ui.AutocompleteList;
7 /** @const */ var InlineEditableItem = options.InlineEditableItem; 7 /** @const */ var InlineEditableItem = options.InlineEditableItem;
8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; 8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList;
9 9
10 /** 10 /**
(...skipping 27 matching lines...) Expand all
38 * @private 38 * @private
39 */ 39 */
40 urlField_: null, 40 urlField_: null,
41 41
42 /** @override */ 42 /** @override */
43 decorate: function() { 43 decorate: function() {
44 InlineEditableItem.prototype.decorate.call(this); 44 InlineEditableItem.prototype.decorate.call(this);
45 45
46 var pageInfo = this.pageInfo_; 46 var pageInfo = this.pageInfo_;
47 47
48 if (pageInfo.modelIndex == '-1') { 48 if (pageInfo.modelIndex == -1) {
49 this.isPlaceholder = true; 49 this.isPlaceholder = true;
50 pageInfo.title = loadTimeData.getString('startupAddLabel'); 50 pageInfo.title = loadTimeData.getString('startupAddLabel');
51 pageInfo.url = ''; 51 pageInfo.url = '';
52 } 52 }
53 53
54 var titleEl = this.ownerDocument.createElement('div'); 54 var titleEl = this.ownerDocument.createElement('div');
55 titleEl.className = 'title'; 55 titleEl.className = 'title';
56 titleEl.classList.add('favicon-cell'); 56 titleEl.classList.add('favicon-cell');
57 titleEl.classList.add('weakrtl'); 57 titleEl.classList.add('weakrtl');
58 titleEl.textContent = pageInfo.title; 58 titleEl.textContent = pageInfo.title;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 /** @override */ 143 /** @override */
144 createItem: function(pageInfo) { 144 createItem: function(pageInfo) {
145 var item = new StartupPageListItem(pageInfo); 145 var item = new StartupPageListItem(pageInfo);
146 item.urlField_.disabled = this.disabled; 146 item.urlField_.disabled = this.disabled;
147 return item; 147 return item;
148 }, 148 },
149 149
150 /** @override */ 150 /** @override */
151 deleteItemAtIndex: function(index) { 151 deleteItemAtIndex: function(index) {
152 chrome.send('removeStartupPages', [String(index)]); 152 chrome.send('removeStartupPages', [index]);
153 }, 153 },
154 154
155 /** 155 /**
156 * Computes the target item of drop event. 156 * Computes the target item of drop event.
157 * @param {Event} e The drop or dragover event. 157 * @param {Event} e The drop or dragover event.
158 * @private 158 * @private
159 */ 159 */
160 getTargetFromDropEvent_: function(e) { 160 getTargetFromDropEvent_: function(e) {
161 var target = e.target; 161 var target = e.target;
162 // e.target may be an inner element of the list item 162 // e.target may be an inner element of the list item
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 e.preventDefault(); 226 e.preventDefault();
227 }, 227 },
228 228
229 /* 229 /*
230 * Handles the drop event. 230 * Handles the drop event.
231 * @param {Event} e The drop event. 231 * @param {Event} e The drop event.
232 * @private 232 * @private
233 */ 233 */
234 handleDrop_: function(e) { 234 handleDrop_: function(e) {
235 var dropTarget = this.getTargetFromDropEvent_(e); 235 var dropTarget = this.getTargetFromDropEvent_(e);
236
237 if (!(dropTarget instanceof StartupPageListItem) ||
238 dropTarget.pageInfo_.modelIndex == -1) {
239 return;
240 }
241
236 this.hideDropMarker_(); 242 this.hideDropMarker_();
237 243
238 // Insert the selection at the new position. 244 // Insert the selection at the new position.
239 var newIndex = this.dataModel.indexOf(dropTarget.pageInfo_); 245 var newIndex = this.dataModel.indexOf(dropTarget.pageInfo_);
240 if (this.dropPos == 'below') 246 if (this.dropPos == 'below')
241 newIndex += 1; 247 newIndex += 1;
242 248
243 var selected = this.selectionModel.selectedIndexes;
244 var stringized_selected = [];
245 for (var j = 0; j < selected.length; j++)
246 stringized_selected.push(String(selected[j]));
247
248 chrome.send('dragDropStartupPage', 249 chrome.send('dragDropStartupPage',
249 [String(newIndex), stringized_selected]); 250 [newIndex, this.selectionModel.selectedIndexes]);
Dan Beam 2013/03/09 00:22:04 nit: plural of index is indices, gar! </vent> (don
250 }, 251 },
251 252
252 /** 253 /**
253 * Handles the dragleave event. 254 * Handles the dragleave event.
254 * @param {Event} e The dragleave event. 255 * @param {Event} e The dragleave event.
255 * @private 256 * @private
256 */ 257 */
257 handleDragLeave_: function(e) { 258 handleDragLeave_: function(e) {
258 this.hideDropMarker_(); 259 this.hideDropMarker_();
259 }, 260 },
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 this.hideDropMarkerTimer_ = window.setTimeout(function() { 301 this.hideDropMarkerTimer_ = window.setTimeout(function() {
301 $('startupPagesListDropmarker').style.display = ''; 302 $('startupPagesListDropmarker').style.display = '';
302 }, 100); 303 }, 100);
303 }, 304 },
304 }; 305 };
305 306
306 return { 307 return {
307 StartupPageList: StartupPageList 308 StartupPageList: StartupPageList
308 }; 309 };
309 }); 310 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698