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

Unified Diff: ui/file_manager/file_manager/foreground/js/cws_container_client.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
Index: ui/file_manager/file_manager/foreground/js/cws_container_client.js
diff --git a/ui/file_manager/file_manager/foreground/js/cws_container_client.js b/ui/file_manager/file_manager/foreground/js/cws_container_client.js
index 9e319231f6a71b0cf47116d5e27a33b13e93cccd..f1d868c3b0db7b22cd1b86cfd62d69daee97bcdf 100644
--- a/ui/file_manager/file_manager/foreground/js/cws_container_client.js
+++ b/ui/file_manager/file_manager/foreground/js/cws_container_client.js
@@ -9,10 +9,15 @@
* @param {string} url Share Url for an entry.
* @param {string} target Target (scheme + host + port) of the widget.
* @param {Object<string, *>} options Options to be sent to the dialog host.
+ * @param {!CWSWidgetContainer.PlatformDelegate} delegate Delegate for accessing
+ * Chrome platform APIs.
* @constructor
* @extends {cr.EventTarget}
*/
-function CWSContainerClient(webView, width, height, url, target, options) {
+function CWSContainerClient(webView, width, height, url, target, options,
+ delegate) {
+ /** @private {!CWSWidgetContainer.PlatformDelegate} */
+ this.delegate_ = delegate;
this.webView_ = webView;
this.width_ = width;
this.height_ = height;
@@ -194,23 +199,26 @@ CWSContainerClient.prototype.postInstallSuccessMessage_ = function(itemId) {
*/
CWSContainerClient.prototype.postInitializeMessage_ = function() {
new Promise(function(fulfill, reject) {
- chrome.fileManagerPrivate.getProvidingExtensions(function(items) {
- if (chrome.runtime.lastError) {
- reject(chrome.runtime.lastError.message);
- return;
- }
- fulfill(items.map(function(item) {
- return item.extensionId;
- }));
+ this.delegate_.getInstalledItems(
+ /**
+ * @param {?Array.<!string>} items Installed items.
+ * Null on error.
+ */
+ function(items) {
+ if (!items) {
+ reject('Failed to retrive installed items.');
+ return;
+ }
+ fulfill(items);
})
- }).then(
+ }.bind(this)).then(
/**
* @param {!Array<string>} preinstalledExtensionIDs
*/
function(preinstalledExtensionIDs) {
var message = {
message: 'initialize',
- hl: util.getCurrentLocaleOrDefault(),
+ hl: this.delegate_.strings.UI_LOCALE,
width: this.width_,
height: this.height_,
preinstalled_items: preinstalledExtensionIDs,

Powered by Google App Engine
This is Rietveld 408576698