Created
March 28, 2011 16:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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