• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2012 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// Script that automatically listend for an onAuthRequired request and sends
6// hardcoded credentials back.
7
8var gPendingCallbacks = [];
9var bkg = chrome.extension.getBackgroundPage();
10
11bkg.console.log("Listening")
12chrome.webRequest.onAuthRequired.addListener(handleAuthRequest,
13                                             {urls: ["<all_urls>"]},
14                                             ["asyncBlocking"]);
15
16function processPendingCallbacks() {
17  bkg.console.log("Calling back with credentials");
18  var callback = gPendingCallbacks.pop();
19  callback({authCredentials: {username: 'admin', password: 'password'}});
20}
21
22function handleAuthRequest(details, callback) {
23  gPendingCallbacks.push(callback);
24  processPendingCallbacks();
25}
26
27
28