blob: 0cf2327981d514d94980f0b617e1d31e1fac321d [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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// For open-source builds, the redirect URL ends in /dev. For official builds,
6// it ends in /rel/{extension-id}. This distinction is handled by the manifest;
7// all we have to do here is check the extension id in the case that there is
8// one, to allow the official beta and dev channels to co-exist.
9
10var extensionId = chrome.i18n.getMessage('@@extension_id');
11var officialPath = '/talkgadget/oauth/chrome-remote-desktop/rel/' + extensionId;
12var unofficialPath = '/talkgadget/oauth/chrome-remote-desktop/dev';
13
14if (window.location.pathname == officialPath ||
15 window.location.pathname == unofficialPath) {
Torne (Richard Coles)68043e12013-09-26 13:24:57 +010016 var query = window.location.search.substring(1);
17 var parts = query.split('&');
18 var queryArgs = {};
19 for (var i = 0; i < parts.length; i++) {
20 var pair = parts[i].split('=');
21 queryArgs[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
22 }
23
24 chrome.extension.sendMessage(queryArgs);
25 window.close();
Torne (Richard Coles)58218062012-11-14 11:43:16 +000026}