| 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 // Closure compiler won't let this be declared inside cr.define(). | |
| 6 /** @enum {string} */ | |
| 7 var SourceType = { | |
| 8 WEBSTORE: 'webstore', | |
| 9 POLICY: 'policy', | |
| 10 SIDELOADED: 'sideloaded', | |
| 11 UNPACKED: 'unpacked', | |
| 12 }; | |
| 13 | |
| 14 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
| 15 /** @interface */ | 6 /** @interface */ |
| 16 var ItemDelegate = function() {}; | 7 var ItemDelegate = function() {}; |
| 17 | 8 |
| 18 ItemDelegate.prototype = { | 9 ItemDelegate.prototype = { |
| 19 /** @param {string} id */ | 10 /** @param {string} id */ |
| 20 deleteItem: assertNotReached, | 11 deleteItem: assertNotReached, |
| 21 | 12 |
| 22 /** | 13 /** |
| 23 * @param {string} id | 14 * @param {string} id |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 142 } |
| 152 assertNotReached(); // FileNotFound. | 143 assertNotReached(); // FileNotFound. |
| 153 }, | 144 }, |
| 154 | 145 |
| 155 /** @private */ | 146 /** @private */ |
| 156 computeClasses_: function() { | 147 computeClasses_: function() { |
| 157 return this.isEnabled_() ? 'enabled' : 'disabled'; | 148 return this.isEnabled_() ? 'enabled' : 'disabled'; |
| 158 }, | 149 }, |
| 159 | 150 |
| 160 /** | 151 /** |
| 161 * @return {SourceType} | |
| 162 * @private | |
| 163 */ | |
| 164 computeSource_: function() { | |
| 165 if (this.data.controlledInfo && | |
| 166 this.data.controlledInfo.type == | |
| 167 chrome.developerPrivate.ControllerType.POLICY) { | |
| 168 return SourceType.POLICY; | |
| 169 } else if (this.data.location == | |
| 170 chrome.developerPrivate.Location.THIRD_PARTY) { | |
| 171 return SourceType.SIDELOADED; | |
| 172 } else if (this.data.location == | |
| 173 chrome.developerPrivate.Location.UNPACKED) { | |
| 174 return SourceType.UNPACKED; | |
| 175 } | |
| 176 return SourceType.WEBSTORE; | |
| 177 }, | |
| 178 | |
| 179 /** | |
| 180 * @return {string} | 152 * @return {string} |
| 181 * @private | 153 * @private |
| 182 */ | 154 */ |
| 183 computeSourceIndicatorIcon_: function() { | 155 computeSourceIndicatorIcon_: function() { |
| 184 switch (this.computeSource_()) { | 156 switch (extensions.getItemSource(this.data)) { |
| 185 case SourceType.POLICY: | 157 case SourceType.POLICY: |
| 186 return 'communication:business'; | 158 return 'communication:business'; |
| 187 case SourceType.SIDELOADED: | 159 case SourceType.SIDELOADED: |
| 188 return 'input'; | 160 return 'input'; |
| 189 case SourceType.UNPACKED: | 161 case SourceType.UNPACKED: |
| 190 return 'extensions-icons:unpacked'; | 162 return 'extensions-icons:unpacked'; |
| 191 case SourceType.WEBSTORE: | 163 case SourceType.WEBSTORE: |
| 192 return ''; | 164 return ''; |
| 193 } | 165 } |
| 194 assertNotReached(); | 166 assertNotReached(); |
| 195 }, | 167 }, |
| 196 | 168 |
| 197 /** | 169 /** |
| 198 * @return {string} | 170 * @return {string} |
| 199 * @private | 171 * @private |
| 200 */ | 172 */ |
| 201 computeSourceIndicatorText_: function() { | 173 computeSourceIndicatorText_: function() { |
| 202 switch (this.computeSource_()) { | 174 var sourceType = extensions.getItemSource(this.data); |
| 203 case SourceType.POLICY: | 175 return sourceType == SourceType.WEBSTORE ? '' : |
| 204 return loadTimeData.getString('itemSourcePolicy'); | 176 extensions.getItemSourceString(sourceType); |
| 205 case SourceType.SIDELOADED: | |
| 206 return loadTimeData.getString('itemSourceSideloaded'); | |
| 207 case SourceType.UNPACKED: | |
| 208 return loadTimeData.getString('itemSourceUnpacked'); | |
| 209 case SourceType.WEBSTORE: | |
| 210 return ''; | |
| 211 } | |
| 212 assertNotReached(); | |
| 213 }, | 177 }, |
| 214 | 178 |
| 215 /** | 179 /** |
| 216 * @param {chrome.developerPrivate.ExtensionView} view | 180 * @param {chrome.developerPrivate.ExtensionView} view |
| 217 * @private | 181 * @private |
| 218 */ | 182 */ |
| 219 computeInspectLabel_: function(view) { | 183 computeInspectLabel_: function(view) { |
| 220 // Trim the "chrome-extension://<id>/". | 184 // Trim the "chrome-extension://<id>/". |
| 221 var url = new URL(view.url); | 185 var url = new URL(view.url); |
| 222 var label = view.url; | 186 var label = view.url; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 250 return this.data.blacklistText ? 'severe' : 'mild'; | 214 return this.data.blacklistText ? 'severe' : 'mild'; |
| 251 }, | 215 }, |
| 252 }); | 216 }); |
| 253 | 217 |
| 254 return { | 218 return { |
| 255 Item: Item, | 219 Item: Item, |
| 256 ItemDelegate: ItemDelegate, | 220 ItemDelegate: ItemDelegate, |
| 257 }; | 221 }; |
| 258 }); | 222 }); |
| 259 | 223 |
| OLD | NEW |