Skip to content

Instantly share code, notes, and snippets.

@khrona
Created March 28, 2011 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save khrona/890768 to your computer and use it in GitHub Desktop.
Save khrona/890768 to your computer and use it in GitHub Desktop.
We wish to load a local HTML file (page.html) that references a local Flash file (example.swf). Flash's local security policy prevents us from doing so without first prompting the user. This example shows how to workaround this using ResourceInterceptor i
using namespace Awesomium;
class MyResourceInterceptor : public ResourceInterceptor
{
ResourceResponse* onRequest(WebView* caller,
const std::string& url,
const std::string& referrer,
const std::string& httpMethod,
const char* uploadData,
size_t uploadDataSize) {
// For each resource request to foobar.com, return the contents
// of a corresponding local file by creating a new ResourceResponse
if(url == "http://www.foobar.com/page.html")
return ResourceResponse::Create(L"C:\\your\\path\\here\\page.html");
else if(url == "http://www.foobar.com/example.swf")
return ResourceResponse::Create(L"C:\\your\\path\\here\\example.swf");
else
return 0;
}
};
void createWebView()
{
WebView* webView = webCore->createWebView(WIDTH, HEIGHT);
webView->setResourceInterceptor(new MyResourceInterceptor());
webView->loadURL("http://www.foobar.com/page.html");
}
/**
* Contents of page.html should be something like:
*
* <html>
* <body>
* <embed src="example.swf" width=512 height=512></embed>
* </body>
* </html>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment