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

Unified Diff: components/chrome_apps/webstore_widget/app/background.js

Issue 1123373003: Launch webstore widget app when unsupported printer is plugged in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_cws_widget_scripts
Patch Set: bump app version Created 5 years, 7 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: 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
+ };
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698