1 // Copyright (c) 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.
5 function makeURL(toolchain, config) {
6 return 'index.html?tc=' + toolchain + '&config=' + config;
9 function createWindow(url) {
10 console.log('loading ' + url);
11 chrome.app.window.create(url, {
18 function onLaunched(launchData) {
19 // Send and XHR to get the URL to load from a configuration file.
20 // Normally you won't need to do this; just call:
22 // chrome.app.window.create('<your url>', {...});
24 // In the SDK we want to be able to load different URLs (for different
25 // toolchain/config combinations) from the commandline, so we to read
26 // this information from the file "run_package_config".
27 var xhr = new XMLHttpRequest();
28 xhr.open('GET', 'run_package_config', true);
29 xhr.onload = function() {
30 var toolchain_config = this.responseText.split(' ');
31 createWindow(makeURL.apply(null, toolchain_config));
33 xhr.onerror = function() {
34 // Can't find the config file, just load the default.
35 createWindow('index.html');
40 chrome.app.runtime.onLaunched.addListener(onLaunched);