| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
 |   2 // Use of this source code is governed by a BSD-style license that can be | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 /** | 
 |   6  * @fileoverview | 
 |   7  * 'site-data' handles showing the local storage summary list for all sites. | 
 |   8  */ | 
 |   9  | 
 |  10 Polymer({ | 
 |  11   is: 'site-data', | 
 |  12  | 
 |  13   behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], | 
 |  14  | 
 |  15   properties: { | 
 |  16     /** | 
 |  17      * A summary list of all sites and how many entities each contain. | 
 |  18      * @type {Array<CookieDataSummaryItem>} | 
 |  19      */ | 
 |  20     sites: Array, | 
 |  21  | 
 |  22     /** | 
 |  23      * The cookie tree with the details needed to display individual sites and | 
 |  24      * their contained data. | 
 |  25      * @type {!settings.CookieTreeNode} | 
 |  26      */ | 
 |  27     treeNodes_: Object, | 
 |  28  | 
 |  29     /** | 
 |  30      * Keeps track of how many outstanding requests for more data there are. | 
 |  31      */ | 
 |  32     requests_: Number, | 
 |  33   }, | 
 |  34  | 
 |  35   ready: function() { | 
 |  36     this.addWebUIListener('loadChildren', this.loadChildren_.bind(this)); | 
 |  37     this.addWebUIListener('onTreeItemRemoved', | 
 |  38         this.onTreeItemRemoved_.bind(this)); | 
 |  39     this.treeNodes_ = new settings.CookieTreeNode(null); | 
 |  40     // Start the initial request. | 
 |  41     this.browserProxy.reloadCookies(); | 
 |  42     this.requests_ = 1; | 
 |  43   }, | 
 |  44  | 
 |  45   loadChildren_: function(list) { | 
 |  46     var parentId = list[0]; | 
 |  47     var data = list[1]; | 
 |  48  | 
 |  49     if (parentId == null) { | 
 |  50       this.treeNodes_.addChildNodes(this.treeNodes_, data); | 
 |  51     } else { | 
 |  52       this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, data); | 
 |  53     } | 
 |  54  | 
 |  55     for (var i = 0; i < data.length; ++i) { | 
 |  56       var prefix = parentId == null ? '' : parentId + ', '; | 
 |  57       if (data[i].hasChildren) { | 
 |  58         this.requests_ += 1; | 
 |  59         this.browserProxy.loadCookieChildren(prefix + data[i].id); | 
 |  60       } | 
 |  61     } | 
 |  62  | 
 |  63     if (--this.requests_ == 0) | 
 |  64       this.sites = this.treeNodes_.getSummaryList(); | 
 |  65   }, | 
 |  66  | 
 |  67   /** | 
 |  68    * Called when an item is removed. | 
 |  69    */ | 
 |  70   onTreeItemRemoved_: function(args) { | 
 |  71     this.treeNodes_.removeByParentId(args[0], args[1], args[2]); | 
 |  72     this.sites = this.treeNodes_.getSummaryList(); | 
 |  73   }, | 
 |  74  | 
 |  75   /** | 
 |  76    * @param {!{model: !{item: !{title: string, id: string}}}} event | 
 |  77    * @private | 
 |  78    */ | 
 |  79   onSiteTap_: function(event) { | 
 |  80     var dialog = document.createElement('site-data-details-dialog'); | 
 |  81     dialog.category = this.category; | 
 |  82     this.shadowRoot.appendChild(dialog); | 
 |  83  | 
 |  84     var node = this.treeNodes_.fetchNodeById(event.model.item.id, false); | 
 |  85     dialog.open(node); | 
 |  86  | 
 |  87     dialog.addEventListener('iron-overlay-closed', function(event) { | 
 |  88       // The drop-down box in the dialog also generates iron-overlay-closed. | 
 |  89       // Ignore anything but that event coming from a dialog object. | 
 |  90       if (event.path[0].id == 'dialog') | 
 |  91         dialog.remove(); | 
 |  92     }); | 
 |  93   }, | 
 |  94 }); | 
| OLD | NEW |