OLD | NEW |
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 Loading... |
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 // TODO(nasko): until the code is modified to account for the "app" level |
| 609 // in the tree model, use this hack of adding the root node id. |
| 610 if ($('cookies-list').rootId) { |
| 611 return $('cookies-list').rootId + ',' + this.data.id; |
| 612 } |
608 return this.data.id; | 613 return this.data.id; |
609 }, | 614 }, |
610 }; | 615 }; |
611 | 616 |
612 /** | 617 /** |
613 * Creates a new cookies list. | 618 * Creates a new cookies list. |
614 * @param {Object=} opt_propertyBag Optional properties. | 619 * @param {Object=} opt_propertyBag Optional properties. |
615 * @constructor | 620 * @constructor |
616 * @extends {DeletableItemList} | 621 * @extends {DeletableItemList} |
617 */ | 622 */ |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 | 824 |
820 /** | 825 /** |
821 * Removes tree nodes by parent id. | 826 * Removes tree nodes by parent id. |
822 * This is used by cookies_view.js. | 827 * This is used by cookies_view.js. |
823 * @param {string} parentId Id of the parent node. | 828 * @param {string} parentId Id of the parent node. |
824 * @param {number} start The index at which to start removing the nodes. | 829 * @param {number} start The index at which to start removing the nodes. |
825 * @param {number} count Number of nodes to remove. | 830 * @param {number} count Number of nodes to remove. |
826 */ | 831 */ |
827 removeByParentId: function(parentId, start, count) { | 832 removeByParentId: function(parentId, start, count) { |
828 var parent = parentId ? parentLookup[parentId] : this; | 833 var parent = parentId ? parentLookup[parentId] : this; |
829 if (!parent) | 834 if (!parent) { |
830 return; | 835 // TODO(nasko): Remove this once the "app" level in the tree model is |
| 836 // accounted for. |
| 837 if (parentId) { |
| 838 parent = this; |
| 839 } else { |
| 840 return; |
| 841 } |
| 842 } |
831 | 843 |
832 parent.startBatchUpdates(); | 844 parent.startBatchUpdates(); |
833 while (count-- > 0) | 845 while (count-- > 0) |
834 parent.remove(start); | 846 parent.remove(start); |
835 parent.endBatchUpdates(); | 847 parent.endBatchUpdates(); |
836 | 848 |
837 cr.dispatchSimpleEvent(this, 'change'); | 849 cr.dispatchSimpleEvent(this, 'change'); |
838 }, | 850 }, |
839 | 851 |
840 /** | 852 /** |
841 * Loads the immediate children of given parent node. | 853 * Loads the immediate children of given parent node. |
842 * This is used by cookies_view.js. | 854 * This is used by cookies_view.js. |
843 * @param {string} parentId Id of the parent node. | 855 * @param {string} parentId Id of the parent node. |
844 * @param {Array} children The immediate children of parent node. | 856 * @param {Array} children The immediate children of parent node. |
845 */ | 857 */ |
846 loadChildren: function(parentId, children) { | 858 loadChildren: function(parentId, children) { |
847 if (parentId) | 859 if (parentId) |
848 delete lookupRequests[parentId]; | 860 delete lookupRequests[parentId]; |
849 var parent = parentId ? parentLookup[parentId] : this; | 861 var parent = parentId ? parentLookup[parentId] : this; |
850 if (!parent) | 862 // TODO(nasko): Remove this once the "app" level in the tree model is |
851 return; | 863 // accounted for. |
| 864 if (!parent) { |
| 865 if (parentId) { |
| 866 parent = this; |
| 867 } else { |
| 868 return; |
| 869 } |
| 870 } |
852 | 871 |
853 parent.startBatchUpdates(); | 872 parent.startBatchUpdates(); |
854 parent.clear(); | 873 parent.clear(); |
855 this.addByParent_(parent, 0, children); | 874 this.addByParent_(parent, 0, children); |
856 parent.endBatchUpdates(); | 875 parent.endBatchUpdates(); |
857 }, | 876 }, |
858 }; | 877 }; |
859 | 878 |
860 return { | 879 return { |
861 CookiesList: CookiesList | 880 CookiesList: CookiesList |
862 }; | 881 }; |
863 }); | 882 }); |
OLD | NEW |