Index: components/chrome_apps/webstore_widget/app/background.js |
diff --git a/components/chrome_apps/webstore_widget/app/background.js b/components/chrome_apps/webstore_widget/app/background.js |
index c878b2a7b4b992f8c2cb165e15874456d40fdead..42534ee874a2559b31aba8553ecb4ceb92d7c683 100644 |
--- a/components/chrome_apps/webstore_widget/app/background.js |
+++ b/components/chrome_apps/webstore_widget/app/background.js |
@@ -2,4 +2,30 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// TODO(tbarzic): Implement this. |
+/** @const {number} */ |
+var APP_WINDOW_WIDTH = 735; |
+ |
+/** @const {number} */ |
+var APP_WINDOW_HEIGHT = 530; |
+ |
+chrome.webstoreWidgetPrivate.onShowWidget.addListener(function(options) { |
+ if (!options || options.type != 'PRINTER_PROVIDER' || !options.usbId) { |
+ console.error('Invalid widget options.'); |
+ return; |
+ } |
+ |
+ chrome.app.window.create('app/main.html', { |
+ id: JSON.stringify(options), |
+ frame: 'none', |
+ innerBounds: {width: APP_WINDOW_WIDTH, height: APP_WINDOW_HEIGHT}, |
+ resizable: false |
+ }, function(createdWindow) { |
+ createdWindow.contentWindow.params = { |
+ filter: { |
+ 'printer_provider_vendor_id': options.usbId.vendorId, |
+ 'printer_provider_product_id': options.usbId.productId |
+ }, |
+ webstoreUrl: null |
+ }; |
+ }); |
+}); |