- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / desktop_capture_delegate / example.com.html
1 <!--
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.
5 -->
6 <script>
7
8 var extensionId = "knldjmfmopnpolahpmmgbagdohdnhkik";
9
10 function sendToBrowser(msg) {
11   domAutomationController.send(msg);
12 }
13
14
15 function requestStreamId(callback) {
16   function onResponse(response) {
17     if (chrome.runtime.lastError) {
18       sendToBrowser(false);
19       return;
20     }
21     id = response["id"];
22     callback(id);
23   };
24
25   chrome.runtime.sendMessage(
26       extensionId, ["getStream"], onResponse);
27 }
28
29 function getStream() {
30   function onStreamId(id) {
31     if (!id) {
32       sendToBrowser(false);
33       return;
34     }
35     navigator.webkitGetUserMedia({
36       audio:false,
37       video: { mandatory: { chromeMediaSource: "desktop",
38                             chromeMediaSourceId: id } }
39     }, sendToBrowser.bind(null, true), sendToBrowser.bind(null, false));
40   };
41   requestStreamId(onStreamId);
42 }
43
44 function getStreamWithInvalidId() {
45   function onStreamId(id) {
46     if (!id) {
47       sendToBrowser(false);
48       return;
49     }
50     navigator.webkitGetUserMedia({
51       audio:false,
52       video: { mandatory: { chromeMediaSource: "desktop",
53                             chromeMediaSourceId: id + "x" } }
54     }, sendToBrowser.bind(null, false), sendToBrowser.bind(null, true));
55   };
56   requestStreamId(onStreamId);
57 }
58
59 </script>