Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-site-settings-page' is the settings page containing privacy and | 7 * 'settings-site-settings-page' is the settings page containing privacy and |
| 8 * security site settings. | 8 * security site settings. |
| 9 * | 9 * |
| 10 * Example: | 10 * Example: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 this.addCategory(settings.ContentSettingsTypes.NOTIFICATIONS); | 62 this.addCategory(settings.ContentSettingsTypes.NOTIFICATIONS); |
| 63 this.addCategory(settings.ContentSettingsTypes.IMAGES); | 63 this.addCategory(settings.ContentSettingsTypes.IMAGES); |
| 64 }.bind(this)); | 64 }.bind(this)); |
| 65 }, | 65 }, |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Adds a single category to the page. | 68 * Adds a single category to the page. |
| 69 * @param {number} category The category to add. | 69 * @param {number} category The category to add. |
| 70 */ | 70 */ |
| 71 addCategory: function(category) { | 71 addCategory: function(category) { |
| 72 var root = this.$.list; | 72 var self = this; |
|
tommycli
2016/02/17 18:18:06
nit: same comment. Does .bind(this) do the trick i
Finnur
2016/02/18 20:38:18
Done.
| |
| 73 var paperIcon = document.createElement('paper-icon-item'); | 73 this.$.prefsApi.getDefaultValueForContentType(category). |
| 74 paperIcon.addEventListener('tap', this.onTapCategory.bind(this)); | 74 then(function(enabled) { |
| 75 var root = self.$.list; | |
| 76 var paperIcon = document.createElement('paper-icon-item'); | |
| 77 paperIcon.addEventListener('tap', self.onTapCategory.bind(self)); | |
| 75 | 78 |
| 76 var ironIcon = document.createElement('iron-icon'); | 79 var ironIcon = document.createElement('iron-icon'); |
| 77 ironIcon.setAttribute('icon', this.computeIconForContentCategory(category)); | 80 ironIcon.setAttribute('icon', |
| 78 ironIcon.setAttribute('item-icon', ''); | 81 self.computeIconForContentCategory(category)); |
| 82 ironIcon.setAttribute('item-icon', ''); | |
| 79 | 83 |
| 80 var description = document.createElement('div'); | 84 var description = document.createElement('div'); |
| 81 description.setAttribute('class', 'flex'); | 85 description.setAttribute('class', 'flex'); |
| 82 description.appendChild( | 86 description.appendChild(document.createTextNode( |
| 83 document.createTextNode(this.computeTitleForContentCategory(category))); | 87 self.computeTitleForContentCategory(category))); |
| 84 var setting = document.createElement('div'); | 88 var setting = document.createElement('div'); |
| 85 setting.setAttribute('class', 'option-value'); | 89 setting.setAttribute('class', 'option-value'); |
| 86 | 90 |
| 87 setting.appendChild(document.createTextNode( | 91 setting.appendChild(document.createTextNode( |
| 88 this.computeCategoryDesc( | 92 self.computeCategoryDesc(category, enabled, false))); |
| 89 category, this.isCategoryAllowed(category), false))); | |
| 90 | 93 |
| 91 paperIcon.appendChild(ironIcon); | 94 paperIcon.appendChild(ironIcon); |
| 92 paperIcon.appendChild(description); | 95 paperIcon.appendChild(description); |
| 93 paperIcon.appendChild(setting); | 96 paperIcon.appendChild(setting); |
| 94 root.appendChild(paperIcon); | 97 root.appendChild(paperIcon); |
| 98 }); | |
| 95 }, | 99 }, |
| 96 | 100 |
| 97 /** | 101 /** |
| 98 * Handles selection of a single category and navigates to the details for | 102 * Handles selection of a single category and navigates to the details for |
| 99 * that category. | 103 * that category. |
| 100 */ | 104 */ |
| 101 onTapCategory: function(event) { | 105 onTapCategory: function(event) { |
| 102 var description = event.currentTarget.querySelector('.flex').innerText; | 106 var description = event.currentTarget.querySelector('.flex').innerText; |
| 103 this.categorySelected = this.computeCategoryTextId( | 107 this.categorySelected = this.computeCategoryTextId( |
| 104 this.computeCategoryFromDesc(description)); | 108 this.computeCategoryFromDesc(description)); |
| 105 this.currentRoute = { | 109 this.currentRoute = { |
| 106 page: this.currentRoute.page, | 110 page: this.currentRoute.page, |
| 107 section: 'privacy', | 111 section: 'privacy', |
| 108 subpage: ['site-settings', 'site-settings-category-' + | 112 subpage: ['site-settings', 'site-settings-category-' + |
| 109 this.categorySelected], | 113 this.categorySelected], |
| 110 }; | 114 }; |
| 111 }, | 115 }, |
| 112 }); | 116 }); |
| OLD | NEW |