Chromium Code Reviews| Index: chrome/browser/resources/md_extensions/item_source.js |
| diff --git a/chrome/browser/resources/md_extensions/item_source.js b/chrome/browser/resources/md_extensions/item_source.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a69c018d96cb8f6799f9b0d81a6a361ab73549f6 |
| --- /dev/null |
| +++ b/chrome/browser/resources/md_extensions/item_source.js |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Closure compiler won't let this be declared inside cr.define(). |
| +/** @enum {string} */ |
| +var SourceType = { |
| + WEBSTORE: 'webstore', |
| + POLICY: 'policy', |
| + SIDELOADED: 'sideloaded', |
| + UNPACKED: 'unpacked', |
| +}; |
| + |
| +cr.define('extensions', function() { |
| + /** |
| + * @param {chrome.developerPrivate.ExtensionInfo} item |
| + * @return {SourceType} |
| + */ |
| + function getItemSource(item) { |
| + if (item.controlledInfo && |
| + item.controlledInfo.type == |
| + chrome.developerPrivate.ControllerType.POLICY) { |
| + return SourceType.POLICY; |
| + } else if (item.location == chrome.developerPrivate.Location.THIRD_PARTY) { |
|
michaelpg
2016/08/26 06:40:13
nit: don't use "else" (and all the braces that ent
Devlin
2016/08/26 18:31:00
Done.
|
| + return SourceType.SIDELOADED; |
| + } else if (item.location == chrome.developerPrivate.Location.UNPACKED) { |
| + return SourceType.UNPACKED; |
|
michaelpg
2016/08/26 06:40:13
indent off
Devlin
2016/08/26 18:31:00
Done.
|
| + } |
| + return SourceType.WEBSTORE; |
| + } |
| + |
| + /** |
| + * @param {SourceType} source |
| + * @return {string} |
| + */ |
| + function getItemSourceString(source) { |
| + switch (source) { |
| + case SourceType.POLICY: |
| + return loadTimeData.getString('itemSourcePolicy'); |
| + case SourceType.SIDELOADED: |
| + return loadTimeData.getString('itemSourceSideloaded'); |
| + case SourceType.UNPACKED: |
| + return loadTimeData.getString('itemSourceUnpacked'); |
| + case SourceType.WEBSTORE: |
| + return loadTimeData.getString('itemSourceWebstore'); |
| + } |
| + assertNotReached(); |
| + } |
| + |
| + return {getItemSource: getItemSource, |
| + getItemSourceString: getItemSourceString}; |
| +}); |