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

Unified Diff: ui/file_manager/file_manager/foreground/js/web_store_utils.js

Issue 2805853002: Compile suggest_app_dialog in gyp v2 (Closed)
Patch Set: Fix unit test. Created 3 years, 8 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
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/web_store_utils.js
diff --git a/ui/file_manager/file_manager/foreground/js/web_store_utils.js b/ui/file_manager/file_manager/foreground/js/web_store_utils.js
new file mode 100644
index 0000000000000000000000000000000000000000..483af10a2c4e92a33ea3e240e47fd5981ee05f81
--- /dev/null
+++ b/ui/file_manager/file_manager/foreground/js/web_store_utils.js
@@ -0,0 +1,52 @@
+// Copyright 2017 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.
+
+/**
+ * Namespace for web store utility functions.
+ * @namespace
+ */
+var webStoreUtils = {};
+
+/**
+ * Location of the Chrome Web Store.
+ *
+ * @const
+ * @type {string}
+ */
+webStoreUtils.CHROME_WEB_STORE_URL = 'https://chrome.google.com/webstore';
+
+/**
+ * Base URL of apps list in the Chrome Web Store.
+ *
+ * @const
+ * @type {string}
+ */
+webStoreUtils.WEB_STORE_HANDLER_BASE_URL =
+ 'https://chrome.google.com/webstore/category/collection/file_handlers';
+
+/**
+ * Returns URL of the Chrome Web Store which show apps supporting the given
+ * file-extension and mime-type.
+ *
+ * @param {?string} extension Extension of the file (with the first dot).
+ * @param {?string} mimeType Mime type of the file.
+ * @return {string} URL
+ */
+webStoreUtils.createWebStoreLink = function(extension, mimeType) {
+ if (!extension || constants.EXECUTABLE_EXTENSIONS.indexOf(extension) !== -1)
+ return webStoreUtils.CHROME_WEB_STORE_URL;
+
+ if (extension[0] === '.')
+ extension = extension.substr(1);
+ else
+ console.warn('Please pass an extension with a dot to createWebStoreLink.');
+
+ var url = webStoreUtils.WEB_STORE_HANDLER_BASE_URL;
+ url += '?_fe=' + extension.toLowerCase().replace(/[^\w]/g, '');
+
+ // If a mime is given, add it into the URL.
+ if (mimeType)
+ url += '&_fmt=' + mimeType.replace(/[^-\w\/]/g, '');
+ return url;
+};
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698