| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var webview; | 5 var webview; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Points the webview to the starting URL of a scope authorization | 8 * Points the webview to the starting URL of a scope authorization |
| 9 * flow, and unhides the dialog once the page has loaded. | 9 * flow, and unhides the dialog once the page has loaded. |
| 10 * @param {string} url The url of the authorization entry point. | 10 * @param {string} url The url of the authorization entry point. |
| 11 * @param {Object} win The dialog window that contains this page. Can | 11 * @param {Object} win The dialog window that contains this page. Can |
| 12 * be left undefined if the caller does not want to display the | 12 * be left undefined if the caller does not want to display the |
| 13 * window. | 13 * window. |
| 14 */ | 14 */ |
| 15 function loadAuthUrlAndShowWindow(url, win) { | 15 function loadAuthUrlAndShowWindow(url, win) { |
| 16 // Send popups from the webview to a normal browser window. |
| 17 webview.addEventListener('newwindow', function(e) { |
| 18 e.window.discard(); |
| 19 window.open(e.targetUrl); |
| 20 }); |
| 21 |
| 22 // Request a customized view from GAIA. |
| 16 webview.onBeforeSendHeaders.addListener(function(details) { | 23 webview.onBeforeSendHeaders.addListener(function(details) { |
| 17 headers = details.requestHeaders || []; | 24 headers = details.requestHeaders || []; |
| 18 headers.push({'name': 'X-Browser-View', | 25 headers.push({'name': 'X-Browser-View', |
| 19 'value': 'embedded'}); | 26 'value': 'embedded'}); |
| 20 return { requestHeaders: headers }; | 27 return { requestHeaders: headers }; |
| 21 }, { | 28 }, { |
| 22 urls: ['https://accounts.google.com/*'], | 29 urls: ['https://accounts.google.com/*'], |
| 23 }, ['blocking', 'requestHeaders']); | 30 }, ['blocking', 'requestHeaders']); |
| 31 |
| 24 webview.src = url; | 32 webview.src = url; |
| 25 if (win) { | 33 if (win) { |
| 26 webview.addEventListener('loadstop', function() { | 34 webview.addEventListener('loadstop', function() { |
| 27 win.show(); | 35 win.show(); |
| 28 }); | 36 }); |
| 29 } | 37 } |
| 30 } | 38 } |
| 31 | 39 |
| 32 document.addEventListener('DOMContentLoaded', function() { | 40 document.addEventListener('DOMContentLoaded', function() { |
| 33 webview = document.querySelector('webview'); | 41 webview = document.querySelector('webview'); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 45 } | 53 } |
| 46 | 54 |
| 47 insertRule('.titlebar-close-button', resources.IDR_CLOSE_DIALOG); | 55 insertRule('.titlebar-close-button', resources.IDR_CLOSE_DIALOG); |
| 48 insertRule('.titlebar-close-button:hover', resources.IDR_CLOSE_DIALOG_H); | 56 insertRule('.titlebar-close-button:hover', resources.IDR_CLOSE_DIALOG_H); |
| 49 insertRule('.titlebar-close-button:active', resources.IDR_CLOSE_DIALOG_P); | 57 insertRule('.titlebar-close-button:active', resources.IDR_CLOSE_DIALOG_P); |
| 50 | 58 |
| 51 document.title = resources.IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE; | 59 document.title = resources.IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE; |
| 52 }); | 60 }); |
| 53 }); | 61 }); |
| 54 | 62 |
| OLD | NEW |