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 // 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() { |
| 15 /** |
| 16 * @param {chrome.developerPrivate.ExtensionInfo} item |
| 17 * @return {SourceType} |
| 18 */ |
| 19 function getItemSource(item) { |
| 20 if (item.controlledInfo && |
| 21 item.controlledInfo.type == |
| 22 chrome.developerPrivate.ControllerType.POLICY) { |
| 23 return SourceType.POLICY; |
| 24 } |
| 25 if (item.location == chrome.developerPrivate.Location.THIRD_PARTY) |
| 26 return SourceType.SIDELOADED; |
| 27 if (item.location == chrome.developerPrivate.Location.UNPACKED) |
| 28 return SourceType.UNPACKED; |
| 29 return SourceType.WEBSTORE; |
| 30 } |
| 31 |
| 32 /** |
| 33 * @param {SourceType} source |
| 34 * @return {string} |
| 35 */ |
| 36 function getItemSourceString(source) { |
| 37 switch (source) { |
| 38 case SourceType.POLICY: |
| 39 return loadTimeData.getString('itemSourcePolicy'); |
| 40 case SourceType.SIDELOADED: |
| 41 return loadTimeData.getString('itemSourceSideloaded'); |
| 42 case SourceType.UNPACKED: |
| 43 return loadTimeData.getString('itemSourceUnpacked'); |
| 44 case SourceType.WEBSTORE: |
| 45 return loadTimeData.getString('itemSourceWebstore'); |
| 46 } |
| 47 assertNotReached(); |
| 48 } |
| 49 |
| 50 return {getItemSource: getItemSource, |
| 51 getItemSourceString: getItemSourceString}; |
| 52 }); |
OLD | NEW |