2 Copyright 2013 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
8 var extensionId
= "knldjmfmopnpolahpmmgbagdohdnhkik";
10 function sendToBrowser(msg
) {
11 domAutomationController
.send(msg
);
14 function requestStreamId(callback
) {
15 function onResponse(response
) {
16 if (chrome
.runtime
.lastError
) {
24 chrome
.runtime
.sendMessage(
25 extensionId
, ["getStream"], onResponse
);
28 function getStream() {
29 function onStreamId(id
) {
34 navigator
.webkitGetUserMedia({
36 video
: { mandatory
: { chromeMediaSource
: "desktop",
37 chromeMediaSourceId
: id
} }
38 }, sendToBrowser
.bind(null, true), sendToBrowser
.bind(null, false));
40 requestStreamId(onStreamId
);
43 function getStreamWithInvalidId() {
44 function onStreamId(id
) {
49 navigator
.webkitGetUserMedia({
51 video
: { mandatory
: { chromeMediaSource
: "desktop",
52 chromeMediaSourceId
: id
+ "x" } }
53 }, sendToBrowser
.bind(null, false), sendToBrowser
.bind(null, true));
55 requestStreamId(onStreamId
);
58 function openPickerDialogAndReturn() {
59 chrome
.runtime
.sendMessage(
60 extensionId
, ["getStreamNoWait"], function(message
) {
61 // Once the picker is shown request to close the tab. The picker should
62 // be destroyed as result.