<commit_before>// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var webview;

/**
 * Points the webview to the starting URL of a scope authorization
 * flow, and unhides the dialog once the page has loaded.
 * @param {string} url The url of the authorization entry point.
 * @param {Object} win The dialog window that contains this page. Can
 *     be left undefined if the caller does not want to display the
 *     window.
 */
function loadAuthUrlAndShowWindow(url, win) {
  webview.onBeforeSendHeaders.addListener(function(details) {
    headers = details.requestHeaders || [];
    headers.push({'name': 'X-Browser-View',
                  'value': 'embedded'});
    return { requestHeaders: headers };
  }, {
    urls: ['https://accounts.google.com/*'],
  }, ['blocking', 'requestHeaders']);
  webview.src = url;
  if (win) {
    webview.addEventListener('loadstop', function() {
      win.show();
    });
  }
}
<commit_msg>Identity API: handle window.open events from the scope approval webview<commit_after>// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var webview;

/**
 * Points the webview to the starting URL of a scope authorization
 * flow, and unhides the dialog once the page has loaded.
 * @param {string} url The url of the authorization entry point.
 * @param {Object} win The dialog window that contains this page. Can
 *     be left undefined if the caller does not want to display the
 *     window.
 */
function loadAuthUrlAndShowWindow(url, win) {
  // Send popups from the webview to a normal browser window.
  webview.addEventListener('newwindow', function(e) {
    e.window.discard();
    window.open(e.targetUrl);
  });

  // Request a customized view from GAIA.
  webview.onBeforeSendHeaders.addListener(function(details) {
    headers = details.requestHeaders || [];
    headers.push({'name': 'X-Browser-View',
                  'value': 'embedded'});
    return { requestHeaders: headers };
  }, {
    urls: ['https://accounts.google.com/*'],
  }, ['blocking', 'requestHeaders']);

  webview.src = url;
  if (win) {
    webview.addEventListener('loadstop', function() {
      win.show();
    });
  }
}

{'fraction_non_alphanumeric': 0.11866554054054054, 'fraction_numerical': 0.0033783783783783786, 'mean_word_length': 3.322992700729927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2564887', 'n_tokens_mistral': 680, 'n_tokens_neox': 657, 'n_words': 247}