Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2497)

Unified Diff: chrome/browser/resources/md_extensions/item_source.js

Issue 2266303002: [MD Extensions] Add the source type on the details page for an extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: michaels Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3b16ea9bbd3dfc63ada6739814b654a8174b9f56
--- /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;
+ }
+ if (item.location == chrome.developerPrivate.Location.THIRD_PARTY)
+ return SourceType.SIDELOADED;
+ if (item.location == chrome.developerPrivate.Location.UNPACKED)
+ return SourceType.UNPACKED;
+ 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};
+});
« no previous file with comments | « chrome/browser/resources/md_extensions/item_source.html ('k') | chrome/browser/ui/webui/extensions/extensions_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698