| Index: chrome/test/data/extensions/tray_cast/background.js
|
| diff --git a/chrome/test/data/extensions/tray_cast/background.js b/chrome/test/data/extensions/tray_cast/background.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a80f5c2255cdd031b67fa81af21d86441107962e
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/tray_cast/background.js
|
| @@ -0,0 +1,72 @@
|
| +var backgroundSetup = {}
|
| +
|
| +tryCreateActivity = function(id, title, tabId) {
|
| + if (id === undefined || title === undefined || tabId === undefined)
|
| + return null;
|
| +
|
| + return {
|
| + "id": id,
|
| + "title": title,
|
| + "tabId": tabId
|
| + };
|
| +}
|
| +
|
| +var receiversActivities = [];
|
| +// Add a new receiver. |activityTitle| and |activityTabId| are optional
|
| +// parameters.
|
| +addReceiver = function(id, receiverName, activityTitle, activityTabId) {
|
| + receiversActivities.push({
|
| + "activity": tryCreateActivity(id, activityTitle, activityTabId),
|
| + "receiver": {
|
| + "id": id,
|
| + "name": receiverName
|
| + }
|
| + });
|
| +}
|
| +// Required API method.
|
| +getMirrorCapableReceiversAndActivities = function() {
|
| + if (this !== backgroundSetup)
|
| + throw 'this !== backgroundSetup';
|
| +
|
| + return receiversActivities;
|
| +}
|
| +
|
| +var stopMirroringReason = "";
|
| +var stopMirroringCalled = false;
|
| +wasStopMirroringCalledWithUserStop = function() {
|
| + return stopMirroringCalled && stopMirroringReason == 'user-stop';
|
| +}
|
| +// Required API method.
|
| +stopMirroring = function(reason) {
|
| + if (this !== backgroundSetup)
|
| + throw 'this !== backgroundSetup';
|
| +
|
| + stopMirroringReason = reason;
|
| + stopMirroringCalled = true;
|
| + for (item of receiversActivities) {
|
| + if (item.activity != null)
|
| + item.activity = null;
|
| + }
|
| +}
|
| +
|
| +var launchTabId = 1;
|
| +var launchTabTitle = "Fake Cast";
|
| +var launchDesktopMirroringReceiverId = "";
|
| +getLaunchDesktopMirroringReceiverId = function() {
|
| + return launchDesktopMirroringReceiverId;
|
| +}
|
| +// Required API method.
|
| +launchDesktopMirroring = function(receiverId) {
|
| + if (this !== backgroundSetup)
|
| + throw 'this !== backgroundSetup';
|
| +
|
| + launchDesktopMirroringReceiverId = receiverId;
|
| +
|
| + for (item of receiversActivities) {
|
| + if (item.receiver.id == receiverId) {
|
| + item.activity =
|
| + tryCreateActivity(receiverId, launchTabId, launchTabTitle);
|
| + break;
|
| + }
|
| + }
|
| +}
|
|
|