void ViewListener::OnShowCreatedWebView(WebView *caller, WebView *new_view, const WebURL &opener_url, const WebURL &target_url, const Rect &initial_pos, bool is_popup) { DevMsg("ViewListener: OnShowCreatedWebView: %s\n", WebStringToCharString(target_url.spec())); //C_WebBrowser* pWebBrowser = g_pAnarchyManager->GetWebManager()->GetWebBrowser(); //pWebBrowser->PrepareWebView(new_view); new_view->Destroy(); }
void WebViewHost::willPerformClientRedirect(WebFrame* frame, const WebURL& from, const WebURL& to, double interval, double fire_time) { if (!m_shell->shouldDumpFrameLoadCallbacks()) return; printFrameDescription(frame); printf(" - willPerformClientRedirectToURL: %s \n", to.spec().data()); }
// REGULAR void LoadListener::OnFinishLoadingFrame(WebView* caller, int64 frame_id, bool is_main_frame, const WebURL& url) { C_AwesomiumBrowserInstance* pHudBrowserInstance = g_pAnarchyManager->GetAwesomiumBrowserManager()->FindAwesomiumBrowserInstance("hud"); std::string urlSpec = WebStringToCharString(url.spec()); if (caller == pHudBrowserInstance->GetWebView() && !g_pAnarchyManager->IsInitialized() && urlSpec == "asset://ui/startup.html" ) { g_pAnarchyManager->OnStartup(); return; } }
void LoadListener::OnDocumentReady(WebView* caller, const WebURL& url) { //DevMsg("LoadListener: OnDocumentReady: %s\n", WebStringToCharString(url.spec())); //C_WebBrowser* pWebBrowser = g_pAnarchyManager->GetWebManager()->GetWebBrowser(); std::string urlSpec = WebStringToCharString(url.spec()); size_t foundPrefix = urlSpec.find("asset://newwindow/"); if (foundPrefix == 0) { // extract a web tab id std::string id = urlSpec.substr(18); DevMsg("Sally: %s\n", urlSpec.c_str()); //if (id == "hud" && g_pAnarchyManager->GetState() == AASTATE_AWESOMIUMBROWSERMANAGERHUDWAIT )// || bHudReady // g_pAnarchyManager->GetAwesomiumBrowserManager()->OnHudWebViewDocumentReady(caller, id); //else g_pAnarchyManager->GetAwesomiumBrowserManager()->OnCreateWebViewDocumentReady(caller, id); } else { //DevMsg("hariy: %s\n", urlSpec.c_str()); //g_pAnarchyManager->GetAwesomiumBrowserManager()->OnHudWebViewDocumentReady(caller, "hud"); // if (!g_pAnarchyManager->GetWebManager()->GetHudReady()) // pWebBrowser->OnHudWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); //{ //foundPrefix = urlSpec.find("asset://ui/loading.html"); //if (foundPrefix == 0) // pWebBrowser->OnHudWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); //foundPrefix = urlSpec.find("asset://ui/hud.html"); //if (foundPrefix == 0) //pWebBrowser->OnHudWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); //else // { // foundPrefix = urlSpec.find("asset://ui/loading.html"); // if (foundPrefix == 0) // pWebBrowser->OnHudWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); //pWebBrowser->OnLoadingWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); // } //} /* else { foundPrefix = urlSpec.find("asset://ui/loading.html"); if ( foundPrefix == 0 ) pWebBrowser->OnLoadingWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); } */ } }
void MasterViewListener::OnShowCreatedWebView(WebView *caller, WebView *new_view, const WebURL &opener_url, const WebURL &target_url, const Rect &initial_pos, bool is_popup) { DevMsg("MasterViewListener: OnShowCreatedWebView: %s\n", WebStringToCharString(target_url.spec())); //C_WebBrowser* pWebBrowser = g_pAnarchyManager->GetWebManager()->GetWebBrowser(); std::string urlSpec = WebStringToCharString(target_url.spec()); size_t foundPrefix = urlSpec.find("asset://newwindow/"); if (foundPrefix == 0) { // extract a web tab id std::string id = urlSpec.substr(18); DevMsg("ID here is: %s\n", id.c_str()); g_pAnarchyManager->GetAwesomiumBrowserManager()->PrepareWebView(new_view, id); } else { new_view->Destroy(); } }
void WebViewHost::willPerformClientRedirect(WebFrame* frame, const WebURL& from, const WebURL& to, double interval, double fire_time) { if (m_shell->shouldDumpFrameLoadCallbacks()) { printFrameDescription(frame); printf(" - willPerformClientRedirectToURL: %s \n", to.spec().data()); } if (m_shell->shouldDumpUserGestureInFrameLoadCallbacks()) printFrameUserGestureStatus(frame, " - in willPerformClientRedirect\n"); }
TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus) { WebURL topFrameURL = toKURL("http://www.test.com?--x--"); registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_page.html")); loadURLInTopFrame(topFrameURL); SimpleWebPageSerializerClient serializerClient; WebVector<WebURL> links(&topFrameURL, 1); WebVector<WebString> localPaths(&"local", 1); WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &serializerClient, links, localPaths, ""); EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", serializerClient.toString().substr(1, 60)); }
TEST_F(WebPageSerializerTest, EncodingAndNormalization) { WebURL topFrameURL = toKURL("http://www.test.com"); registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("encoding_normalization.html")); loadURLInTopFrame(topFrameURL); SimpleWebPageSerializerClient serializerClient; WebVector<WebURL> links(&topFrameURL, 1); WebVector<WebString> localPaths(&"local", 1); WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &serializerClient, links, localPaths, ""); const char* expectedHTML = "<!DOCTYPE html>\n" "<!-- saved from url=(0020)http://www.test.com/ -->\n" "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-KR\"><meta charset=\"euc-kr\">\n" "<title>Ensure NFC normalization is not performed by page serializer</title>\n" "</head><body>\n" "\xe4\xc5\xd1\xe2\n" "\n</body></html>"; EXPECT_EQ(expectedHTML, serializerClient.toString()); }
TEST_F(WebPageSerializerTest, URLAttributeValues) { WebURL topFrameURL = toKURL("http://www.test.com"); registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("url_attribute_values.html")); registerMockedImageURL("javascript:\""); loadURLInTopFrame(topFrameURL); SimpleWebPageSerializerClient serializerClient; WebVector<WebURL> links(&topFrameURL, 1); WebVector<WebString> localPaths(&"local", 1); WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &serializerClient, links, localPaths, ""); const char* expectedHTML = "\n<!-- saved from url=(0020)http://www.test.com/ -->\n" "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><meta charset=\"utf8\">\n" "</head><body><img src=\"javascript:"\">\n" "<a href=\"http://www.test.com/local#"\">local</a>\n" "<a href=\"http://www.example.com/#"><script>alert(0)</script>\">external</a>\n" "</body></html>"; EXPECT_EQ(expectedHTML, serializerClient.toString()); }
static inline bool isSVGTestURL(const WebURL& url) { return url.isValid() && string(url.spec()).find("W3C-SVG-1.1") != string::npos; }
WebString WebPageSerializer::generateMarkOfTheWebDeclaration(const WebURL& url) { return String::format("\n<!-- saved from url=(%04d)%s -->\n", static_cast<int>(url.spec().length()), url.spec().data()); }
void MasterViewListener::OnChangeTargetURL(WebView* caller, const WebURL &url) { DevMsg("MasterViewListener: OnChangeTargetURL: %s\n", WebStringToCharString(url.spec())); }