1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 /** 6 * Displays a webview based authorization dialog. 7 * @param {string} key A unique identifier that the caller can use to locate 8 * the dialog window. 9 * @param {string} url A URL that will be loaded in the webview. 10 * @param {string} mode 'interactive' or 'silent'. The window will be displayed 11 * if the mode is 'interactive'. 12 */ 13 function showAuthDialog(key, url, mode) { 14 var options = { 15 frame: 'none', 16 id: key, 17 minWidth: 1024, 18 minHeight: 768, 19 hidden: true 20 }; 21 chrome.app.window.create('scope_approval_dialog.html', 22 options, 23 function(win) { 24 win.contentWindow.addEventListener('load', function(event) { 25 var windowParam; 26 if (mode == 'interactive') 27 windowParam = win; 28 win.contentWindow.loadAuthUrlAndShowWindow(url, windowParam); 29 }); 30 }); 31 } 32 33 chrome.identityPrivate.onWebFlowRequest.addListener(showAuthDialog); 34 35