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

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

Issue 2424183002: Remove Chromecast extension support from cast system tray menu. (Closed)
Patch Set: Additional removals Created 4 years, 1 month 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 // Copyright (c) 2015 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 var backgroundSetup = {}
6
7 // If all required activity information is available, then this will return an
8 // activity structure; otherwise, it will return null. This lets us
9 // unconditionally assign to the 'activity' field in a JSON object.
10 tryCreateActivity_ = function(id, title, tabId) {
11 if (id === undefined || title === undefined || tabId === undefined)
12 return null;
13
14 return {
15 'id': id,
16 'title': title,
17 'tabId': tabId
18 };
19 }
20
21 var receiversActivities = [];
22 var sendDevices = function() {
23 chrome.cast.devicesPrivate.updateDevices(receiversActivities);
24 }
25 chrome.cast.devicesPrivate.updateDevicesRequested.addListener(sendDevices);
26
27 // Add a new receiver. |activityTitle| and |activityTabId| are optional
28 // parameters.
29 var addReceiver = function(id, receiverName, activityTitle, activityTabId) {
30 receiversActivities.push({
31 'receiver': {
32 'id': id,
33 'name': receiverName
34 },
35 'activity': tryCreateActivity_(id, activityTitle, activityTabId)
36 });
37
38 sendDevices();
39 }
40
41 var stopMirroringCalled = false;
42 chrome.cast.devicesPrivate.stopCast.addListener(function(reason) {
43 if (reason !== 'user-stop')
44 throw 'expected reason to be "user-stop"';
45
46 var foundActivity = false;
47 for (item of receiversActivities) {
48 if (item.activity != null) {
49 item.activity = null;
50 foundActivity = true;
51 }
52 }
53 if (foundActivity === false)
54 throw 'stopMirroring called when there was nothing being mirrored'
55
56 stopMirroringCalled = true;
57 sendDevices();
58 });
59
60
61 var launchDesktopMirroringReceiverId = '';
62 chrome.cast.devicesPrivate.startCast.addListener(function(receiverId) {
63 launchDesktopMirroringReceiverId = receiverId;
64
65 var tabTitle = 'Tab Title';
66 var tabId = 1;
67
68 for (item of receiversActivities) {
69 if (item.receiver.id == receiverId) {
70 item.activity = tryCreateActivity_(receiverId, tabTitle, tabId);
71 break;
72 }
73 }
74
75 sendDevices();
76 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698