Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chrome/test/data/extensions/tray_cast/background.js

Issue 1224643008: Add a fake cast extension for testing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 var backgroundSetup = {}
2
3 tryCreateActivity = function(id, title, tabId) {
4 if (id === undefined || title === undefined || tabId === undefined)
5 return null;
6
7 return {
8 "id": id,
9 "title": title,
10 "tabId": tabId
11 };
12 }
13
14 var receiversActivities = [];
15 // Add a new receiver. |activityTitle| and |activityTabId| are optional
16 // parameters.
17 addReceiver = function(id, receiverName, activityTitle, activityTabId) {
18 receiversActivities.push({
19 "activity": tryCreateActivity(id, activityTitle, activityTabId),
20 "receiver": {
21 "id": id,
22 "name": receiverName
23 }
24 });
25 }
26 // Required API method.
27 getMirrorCapableReceiversAndActivities = function() {
28 if (this !== backgroundSetup)
29 throw 'this !== backgroundSetup';
30
31 return receiversActivities;
32 }
33
34 var stopMirroringReason = "";
35 var stopMirroringCalled = false;
36 wasStopMirroringCalledWithUserStop = function() {
37 return stopMirroringCalled && stopMirroringReason == 'user-stop';
38 }
39 // Required API method.
40 stopMirroring = function(reason) {
41 if (this !== backgroundSetup)
42 throw 'this !== backgroundSetup';
43
44 stopMirroringReason = reason;
45 stopMirroringCalled = true;
46 for (item of receiversActivities) {
47 if (item.activity != null)
48 item.activity = null;
49 }
50 }
51
52 var launchTabId = 1;
53 var launchTabTitle = "Fake Cast";
54 var launchDesktopMirroringReceiverId = "";
55 getLaunchDesktopMirroringReceiverId = function() {
56 return launchDesktopMirroringReceiverId;
57 }
58 // Required API method.
59 launchDesktopMirroring = function(receiverId) {
60 if (this !== backgroundSetup)
61 throw 'this !== backgroundSetup';
62
63 launchDesktopMirroringReceiverId = receiverId;
64
65 for (item of receiversActivities) {
66 if (item.receiver.id == receiverId) {
67 item.activity =
68 tryCreateActivity(receiverId, launchTabId, launchTabTitle);
69 break;
70 }
71 }
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698