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

Side by Side Diff: chrome/browser/resources/options2/cookies_list.js

Issue 10536017: Refactoring CookiesTreeModel to support multiple data sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mostly working, just need to refresh properly on Remove All Created 8 years, 6 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', function() { 5 cr.define('options', function() {
6 /** @const */ var DeletableItemList = options.DeletableItemList; 6 /** @const */ var DeletableItemList = options.DeletableItemList;
7 /** @const */ var DeletableItem = options.DeletableItem; 7 /** @const */ var DeletableItem = options.DeletableItem;
8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
9 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; 9 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
10 10
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 }, 598 },
599 599
600 /** 600 /**
601 * The cookie tree path id. 601 * The cookie tree path id.
602 * @type {string} 602 * @type {string}
603 */ 603 */
604 get pathId() { 604 get pathId() {
605 var parent = this.parent; 605 var parent = this.parent;
606 if (parent && parent instanceof CookieTreeNode) 606 if (parent && parent instanceof CookieTreeNode)
607 return parent.pathId + ',' + this.data.id; 607 return parent.pathId + ',' + this.data.id;
608 if ($('cookies-list').rootId) {
609 return $('cookies-list').rootId + ',' + this.data.id;
610 }
608 return this.data.id; 611 return this.data.id;
609 }, 612 },
610 }; 613 };
611 614
612 /** 615 /**
613 * Creates a new cookies list. 616 * Creates a new cookies list.
614 * @param {Object=} opt_propertyBag Optional properties. 617 * @param {Object=} opt_propertyBag Optional properties.
615 * @constructor 618 * @constructor
616 * @extends {DeletableItemList} 619 * @extends {DeletableItemList}
617 */ 620 */
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 822
820 /** 823 /**
821 * Removes tree nodes by parent id. 824 * Removes tree nodes by parent id.
822 * This is used by cookies_view.js. 825 * This is used by cookies_view.js.
823 * @param {string} parentId Id of the parent node. 826 * @param {string} parentId Id of the parent node.
824 * @param {number} start The index at which to start removing the nodes. 827 * @param {number} start The index at which to start removing the nodes.
825 * @param {number} count Number of nodes to remove. 828 * @param {number} count Number of nodes to remove.
826 */ 829 */
827 removeByParentId: function(parentId, start, count) { 830 removeByParentId: function(parentId, start, count) {
828 var parent = parentId ? parentLookup[parentId] : this; 831 var parent = parentId ? parentLookup[parentId] : this;
829 if (!parent) 832 if (!parent) {
830 return; 833 if (parentId) {
834 parent = this;
835 } else {
836 return;
837 }
838 }
831 839
832 parent.startBatchUpdates(); 840 parent.startBatchUpdates();
833 while (count-- > 0) 841 while (count-- > 0)
834 parent.remove(start); 842 parent.remove(start);
835 parent.endBatchUpdates(); 843 parent.endBatchUpdates();
836 844
837 cr.dispatchSimpleEvent(this, 'change'); 845 cr.dispatchSimpleEvent(this, 'change');
838 }, 846 },
839 847
840 /** 848 /**
841 * Loads the immediate children of given parent node. 849 * Loads the immediate children of given parent node.
842 * This is used by cookies_view.js. 850 * This is used by cookies_view.js.
843 * @param {string} parentId Id of the parent node. 851 * @param {string} parentId Id of the parent node.
844 * @param {Array} children The immediate children of parent node. 852 * @param {Array} children The immediate children of parent node.
845 */ 853 */
846 loadChildren: function(parentId, children) { 854 loadChildren: function(parentId, children) {
847 if (parentId) 855 if (parentId)
848 delete lookupRequests[parentId]; 856 delete lookupRequests[parentId];
849 var parent = parentId ? parentLookup[parentId] : this; 857 var parent = parentId ? parentLookup[parentId] : this;
850 if (!parent) 858 if (!parent) {
851 return; 859 if (parentId) {
860 parent = this;
861 } else {
862 return;
863 }
864 }
852 865
853 parent.startBatchUpdates(); 866 parent.startBatchUpdates();
854 parent.clear(); 867 parent.clear();
855 this.addByParent_(parent, 0, children); 868 this.addByParent_(parent, 0, children);
856 parent.endBatchUpdates(); 869 parent.endBatchUpdates();
857 }, 870 },
858 }; 871 };
859 872
860 return { 873 return {
861 CookiesList: CookiesList 874 CookiesList: CookiesList
862 }; 875 };
863 }); 876 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698