190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file. 490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)/** 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * Displays a webview based authorization dialog. 790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * @param {string} key A unique identifier that the caller can use to locate 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * the dialog window. 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * @param {string} url A URL that will be loaded in the webview. 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * @param {string} mode 'interactive' or 'silent'. The window will be displayed 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * if the mode is 'interactive'. 1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) */ 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)function showAuthDialog(key, url, mode) { 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) var options = { 1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) frame: 'none', 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) id: key, 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) minWidth: 1024, 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) minHeight: 768, 1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) hidden: true 2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) }; 2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) chrome.app.window.create('scope_approval_dialog.html', 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) options, 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) function(win) { 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) win.contentWindow.addEventListener('load', function(event) { 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) var windowParam; 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (mode == 'interactive') 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) windowParam = win; 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) win.contentWindow.loadAuthUrlAndShowWindow(url, windowParam); 2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) }); 3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) }); 3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)chrome.identityPrivate.onWebFlowRequest.addListener(showAuthDialog); 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 35