Nashenas
Nashenas

Reputation: 1691

Accessing the Cast API from within an extension page

I was working on a chromecast app, and I wanted to incorporate it into a chrome extension. I'm also using knockout.js in order to help with some of the UI. I have two pages, one is unsandboxed (http://jsfiddle.net/AuJaX/3/), and the other is sandboxed (http://jsfiddle.net/V2dJc/1/). None of the console.log's ever get called. My manifest is below:

{
  "manifest_version": 2,
  "name": "__MSG_app_title__",
  "description": "__MSG_app_description__",
  "version": "0.1",
  "content_scripts": [
    {
  "matches": ["<all_urls>"],
      "js": ["js/content/content.js"]
    }
  ],
  "background": {
    "scripts": ["js/back/background.js"],
    "persistent": false
  },
  "permissions": [
    "tabs",
    "contextMenus"
  ],
  "page_action": {
    "default_title": "__MSG_app_title__",
    "default_icon": {
      "19": "images/icon-19.png"
    }
  },
  "sandbox": {
    "pages": ["sandboxed.html"]
  },
  "icons": { "48": "images/icon.png" },
  "default_locale": "en"
}

Is there anything that I'm doing wrong, or is this something that's not supported (yet??)?

Upvotes: 0

Views: 3898

Answers (1)

Nick Spacek
Nick Spacek

Reputation: 4773

Did you whitelist the domain you are trying to use the extension on? Currently to have the Cast API injected into the page you need two things:

<html data-cast-api-enabled="true">

and you need to follow the steps at the bottom of this page (whitelisting in the extension, not the same as the Google Cast device whitelisting):

https://developers.google.com/cast/whitelisting#whitelist-chrome

That said, I doubt this is going to work. The instructions are for getting the Cast API injected into a regular web page. However, if I'm not mistaken you want the API injected into your Chrome extension page. I don't know if it will be made available there, since I don't think two different extensions are allowed to interact.

Upvotes: 3

Related Questions