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

Side by Side Diff: chrome/browser/resources/md_extensions/manager.js

Issue 2526893002: [MD Extensions] Update subpages when the backing extension data changes (Closed)
Patch Set: Michael's Created 4 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
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 * The different pages that can be shown at a time. 6 * The different pages that can be shown at a time.
7 * Note: This must remain in sync with the order in manager.html! 7 * Note: This must remain in sync with the order in manager.html!
8 * @enum {string} 8 * @enum {string}
9 */ 9 */
10 var Page = { 10 var Page = {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 inDevMode: { 56 inDevMode: {
57 type: Boolean, 57 type: Boolean,
58 value: false, 58 value: false,
59 }, 59 },
60 60
61 filter: { 61 filter: {
62 type: String, 62 type: String,
63 value: '', 63 value: '',
64 }, 64 },
65 65
66 /**
67 * The item currently displayed in the error subpage. We use a separate
68 * item for different pages (rather than a single subpageItem_ property)
69 * so that hidden subpages don't update when an item updates. That is, we
70 * don't want the details view subpage to update when the item shown in
71 * the errors page updates, and vice versa.
72 * @private {!chrome.developerPrivate.ExtensionInfo|undefined}
73 */
74 errorPageItem_: Object,
75
76 /**
77 * The item currently displayed in the details view subpage. See also
78 * errorPageItem_.
79 * @private {!chrome.developerPrivate.ExtensionInfo|undefined}
80 */
81 detailViewItem_: Object,
82
66 /** @type {!Array<!chrome.developerPrivate.ExtensionInfo>} */ 83 /** @type {!Array<!chrome.developerPrivate.ExtensionInfo>} */
67 extensions: { 84 extensions: {
68 type: Array, 85 type: Array,
69 value: function() { return []; }, 86 value: function() { return []; },
70 }, 87 },
71 88
72 /** @type {!Array<!chrome.developerPrivate.ExtensionInfo>} */ 89 /** @type {!Array<!chrome.developerPrivate.ExtensionInfo>} */
73 apps: { 90 apps: {
74 type: Array, 91 type: Array,
75 value: function() { return []; }, 92 value: function() { return []; },
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 get errorPage() { 126 get errorPage() {
110 return this.$['error-page']; 127 return this.$['error-page'];
111 }, 128 },
112 129
113 /** 130 /**
114 * Shows the details view for a given item. 131 * Shows the details view for a given item.
115 * @param {!chrome.developerPrivate.ExtensionInfo} data 132 * @param {!chrome.developerPrivate.ExtensionInfo} data
116 */ 133 */
117 showItemDetails: function(data) { 134 showItemDetails: function(data) {
118 this.$['items-list'].willShowItemSubpage(data.id); 135 this.$['items-list'].willShowItemSubpage(data.id);
119 this.$['details-view'].data = data; 136 this.detailViewItem_ = data;
120 this.changePage(Page.DETAIL_VIEW); 137 this.changePage(Page.DETAIL_VIEW);
121 }, 138 },
122 139
123 /** 140 /**
124 * @param {!CustomEvent} event 141 * @param {!CustomEvent} event
125 * @private 142 * @private
126 */ 143 */
127 onFilterChanged_: function(event) { 144 onFilterChanged_: function(event) {
128 this.filter = /** @type {string} */ (event.detail); 145 this.filter = /** @type {string} */ (event.detail);
129 }, 146 },
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 /** 213 /**
197 * @param {!chrome.developerPrivate.ExtensionInfo} item The data for the 214 * @param {!chrome.developerPrivate.ExtensionInfo} item The data for the
198 * item to update. 215 * item to update.
199 */ 216 */
200 updateItem: function(item) { 217 updateItem: function(item) {
201 var listId = this.getListId_(item.type); 218 var listId = this.getListId_(item.type);
202 var index = this.getIndexInList_(listId, item.id); 219 var index = this.getIndexInList_(listId, item.id);
203 // We should never try and update a non-existent item. 220 // We should never try and update a non-existent item.
204 assert(index >= 0); 221 assert(index >= 0);
205 this.set([listId, index], item); 222 this.set([listId, index], item);
223
224 // Update the subpage if it is open and displaying the item. If it's not
225 // open, we don't update the data even if it's displaying that item. We'll
226 // set the item correctly before opening the page. It's a little weird
227 // that the DOM will have stale data, but there's no point in causing the
228 // extra work.
229 if (this.detailViewItem_ && this.detailViewItem_.id == item.id &&
230 this.$.pages.selected == Page.DETAIL_VIEW) {
231 this.detailViewItem_ = item;
232 } else if (this.errorPageItem_ && this.errorPageItem_.id == item.id &&
233 this.$.pages.selected == Page.ERROR_PAGE) {
234 this.errorPageItem_ = item;
235 }
206 }, 236 },
207 237
208 /** 238 /**
209 * @param {!chrome.developerPrivate.ExtensionInfo} item The data for the 239 * @param {!chrome.developerPrivate.ExtensionInfo} item The data for the
210 * item to remove. 240 * item to remove.
211 */ 241 */
212 removeItem: function(item) { 242 removeItem: function(item) {
213 var listId = this.getListId_(item.type); 243 var listId = this.getListId_(item.type);
214 var index = this.getIndexInList_(listId, item.id); 244 var index = this.getIndexInList_(listId, item.id);
215 // We should never try and remove a non-existent item. 245 // We should never try and remove a non-existent item.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 }, 306 },
277 307
278 /** 308 /**
279 * Handles the event for the user clicking on the errors button. 309 * Handles the event for the user clicking on the errors button.
280 * @param {!CustomEvent} e 310 * @param {!CustomEvent} e
281 * @private 311 * @private
282 */ 312 */
283 onShouldShowItemErrors_: function(e) { 313 onShouldShowItemErrors_: function(e) {
284 var data = e.detail.data; 314 var data = e.detail.data;
285 this.$['items-list'].willShowItemSubpage(data.id); 315 this.$['items-list'].willShowItemSubpage(data.id);
286 this.$['error-page'].data = data; 316 this.errorPageItem_ = data;
287 this.changePage(Page.ERROR_PAGE); 317 this.changePage(Page.ERROR_PAGE);
288 }, 318 },
289 319
290 /** @private */ 320 /** @private */
291 onDetailsViewClose_: function() { 321 onDetailsViewClose_: function() {
322 // Note: we don't reset detailViewItem_ here because doing so just causes
323 // extra work for the data-bound details view.
292 this.changePage(Page.ITEM_LIST); 324 this.changePage(Page.ITEM_LIST);
293 }, 325 },
294 326
295 /** @private */ 327 /** @private */
296 onErrorPageClose_: function() { 328 onErrorPageClose_: function() {
329 // Note: we don't reset errorPageItem_ here because doing so just causes
330 // extra work for the data-bound error page.
297 this.changePage(Page.ITEM_LIST); 331 this.changePage(Page.ITEM_LIST);
298 } 332 }
299 }); 333 });
300 334
301 /** 335 /**
302 * @param {extensions.Manager} manager 336 * @param {extensions.Manager} manager
303 * @constructor 337 * @constructor
304 * @implements {extensions.SidebarListDelegate} 338 * @implements {extensions.SidebarListDelegate}
305 */ 339 */
306 function ListHelper(manager) { 340 function ListHelper(manager) {
(...skipping 23 matching lines...) Expand all
330 }, 364 },
331 365
332 /** @override */ 366 /** @override */
333 showPackDialog: function() { 367 showPackDialog: function() {
334 this.manager_.packDialog.show(); 368 this.manager_.packDialog.show();
335 } 369 }
336 }; 370 };
337 371
338 return {Manager: Manager}; 372 return {Manager: Manager};
339 }); 373 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_extensions/manager.html ('k') | chrome/test/data/webui/extensions/cr_extensions_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698