KirovBvulgaru / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

Detect whether or not an app using the SDK is packaged or hosted to determine whether to use window.localStorage or chrome.storage.local #128

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
While Issue 37 has indeed been marked fixed, it isn't really fixed as the 
latest comment points out. Why? Because the cast_sender.js file depends on an 
API only available to web apps and extensions: window.localStorage. Using 
window.localStorage in a packaged app violates CSP and thus throws an error, 
telling the developer to use the chrome.storage.local API instead.

So, let's split Line 29 into an if statement, shall we? That seems to be the 
only fix to this problem.

Current cast_sender.js, line 29:

localStorage.castDevExtensionId && 
chrome.cast.ApiBootstrap_.EXTENSION_IDS.splice(1, 0, 
localStorage.castDevExtensionId);

Proposed changes to cast_sender.js, lines 29-33:

if(chrome.runtime && chrome.runtime.getManifest().app) {
  chrome.storage.local.castDevExtensionId && chrome.cast.ApiBootstrap_.EXTENSION_IDS.splice(1, 0, chrome.storage.local.castDevExtensionId); //window.localStorage violates CSP for packaged apps
} else {
  localStorage.castDevExtensionId && chrome.cast.ApiBootstrap_.EXTENSION_IDS.splice(1, 0, localStorage.castDevExtensionId);
}

Original issue reported on code.google.com by Kenny.Strawn on 7 Feb 2014 at 12:01

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
First file below is the current version, second is the one with my proposed 
changes added.

Original comment by Kenny.Strawn on 7 Feb 2014 at 12:11

Attachments:

GoogleCodeExporter commented 8 years ago
Packaged apps are not supported at this point.

Original comment by anad...@google.com on 7 Feb 2014 at 8:41