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

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

Issue 1091943002: Use delegate object for chrome API calls in cws_widget_container (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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/cws_widget_container.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/ui/suggest_apps_dialog.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js b/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
index ef98f0c5c41aade17bb43bdc986c46b2cd01fcbb..f0d4077f6aca5d739f256dde6bb51be58c2d51aa 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
@@ -33,7 +33,8 @@ function SuggestAppsDialog(parentNode, state) {
* @const {!CWSWidgetContainer}
* @private
*/
- this.widget_ = new CWSWidgetContainer(this.document_, widgetRoot, state);
+ this.widget_ = new CWSWidgetContainer(
+ this.document_, widgetRoot, this.createWidgetPlatformDelegate_(), state);
this.initialFocusElement_ = this.widget_.getInitiallyFocusedElement();
@@ -115,6 +116,71 @@ SuggestAppsDialog.prototype.showProviders = function(onDialogClosed) {
};
/**
+ * Creates platform delegate for CWSWidgetContainer.
+ * @return {!CWSWidgetContainer.PlatformDelegate}
+ * @private
+ */
+SuggestAppsDialog.prototype.createWidgetPlatformDelegate_ = function() {
+ return {
+ strings: {
+ UI_LOCALE: util.getCurrentLocaleOrDefault(),
+ LINK_TO_WEBSTORE: str('SUGGEST_DIALOG_LINK_TO_WEBSTORE'),
+ INSTALLATION_FAILED_MESSAGE: str('SUGGEST_DIALOG_INSTALLATION_FAILED')
+ },
+
+ metricsImpl: metrics,
+
+ /**
+ * @param {string} itemId,
+ * @param {function(?string)} callback Callback argument is set to error
+ * message (null on success)
+ */
+ installWebstoreItem: function(itemId, callback) {
+ chrome.fileManagerPrivate.installWebstoreItem(
+ itemId,
+ false /* show installation prompt */,
+ function() {
+ callback(chrome.runtime.lastError ?
+ chrome.runtime.lastError.message || 'UNKNOWN ERROR' : null);
+ });
+ },
+
+ /**
+ * @param {function(?Array.<!string>)} callback Callback
+ * argument is a list of installed item ids (null on error).
+ */
+ getInstalledItems: function(callback) {
+ chrome.fileManagerPrivate.getProvidingExtensions(function(items) {
+ if (chrome.runtime.lastError) {
+ console.error('Failed to get installed items: ' +
+ chrome.runtime.lastError.message);
+ callback(null);
+ return;
+ }
+ callback(items.map(function(item) {
+ return item.extensionId;
+ }));
+ });
+ },
+
+ /**
+ * @param {function(?string)} callback Callback argument is the requested
+ * token (null on error).
+ */
+ requestWebstoreAccessToken: function(callback) {
+ chrome.fileManagerPrivate.requestWebStoreAccessToken(function(token) {
+ if (chrome.runtime.lastError) {
+ console.error(chrome.runtime.lastError.message);
+ callback(null);
+ return;
+ }
+ callback(token);
+ });
+ }
+ };
+};
+
+/**
* Internal method to show a dialog. This should be called only from 'Suggest.
* appDialog.showXxxx()' functions.
*
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/cws_widget_container.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698