void SfDelegate::OnReceivedRedirect( net::URLRequest *request, const GURL &new_url, bool *defer_redirect) { #ifndef ANDROID_DEFAULT_CODE const char *uri =NULL; uri = new_url.spec().c_str(); MY_LOGI(StringPrintf("OnReceivedRedirect,original_url=%s ",request->original_url().spec().c_str()).c_str()); MY_LOGI(StringPrintf("OnReceivedRedirect, new_url=%s", new_url.spec().c_str()).c_str()); MY_LOGI(StringPrintf("OnReceivedRedirect,defer_redirect=%d",*defer_redirect).c_str()); mOwner->OnReceivedRedirect( uri); #else MY_LOGV("OnReceivedRedirect"); #endif }
void WebRequest::handleDataURL(GURL url) { OwnPtr<std::string> data(new std::string); std::string mimeType; std::string charset; if (net::DataURL::Parse(url, &mimeType, &charset, data.get())) { // PopulateURLResponse from chrome implementation // weburlloader_impl.cc m_loadState = Response; OwnPtr<WebResponse> webResponse(new WebResponse(url.spec(), mimeType, data->size(), charset, 200)); m_urlLoader->maybeCallOnMainThread(NewRunnableMethod( m_urlLoader.get(), &WebUrlLoaderClient::didReceiveResponse, webResponse.release())); if (!data->empty()) { m_loadState = GotData; m_urlLoader->maybeCallOnMainThread(NewRunnableMethod( m_urlLoader.get(), &WebUrlLoaderClient::didReceiveDataUrl, data.release())); } } else { // handle the failed case } finish(true); }
void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url) { Q_ASSERT(validated_url.is_valid()); if (validated_url.spec() == content::kUnreachableWebDataURL) { m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID()); m_viewClient->iconChanged(QUrl()); // Trigger LoadFinished signal for main frame's error page only. if (!render_frame_host->GetParent()) m_viewClient->loadFinished(true /* success */, toQt(validated_url), true /* isErrorPage */); return; } if (render_frame_host->GetParent()) return; m_viewClient->loadFinished(true, toQt(validated_url)); content::NavigationEntry *entry = web_contents()->GetController().GetActiveEntry(); if (!entry) return; content::FaviconStatus &favicon = entry->GetFavicon(); if (favicon.valid) m_viewClient->iconChanged(toQt(favicon.url)); else m_viewClient->iconChanged(QUrl()); }
// Called upon a server-initiated redirect. The delegate may call the // request's Cancel method to prevent the redirect from being followed. // Since there may be multiple chained redirects, there may also be more // than one redirect call. // // When this function is called, the request will still contain the // original URL, the destination of the redirect is provided in 'new_url'. // If the delegate does not cancel the request and |*defer_redirect| is // false, then the redirect will be followed, and the request's URL will be // changed to the new URL. Otherwise if the delegate does not cancel the // request and |*defer_redirect| is true, then the redirect will be // followed once FollowDeferredRedirect is called on the URLRequest. // // The caller must set |*defer_redirect| to false, so that delegates do not // need to set it if they are happy with the default behavior of not // deferring redirect. void WebRequest::OnReceivedRedirect(net::URLRequest* newRequest, const GURL& newUrl, bool* deferRedirect) { ASSERT(m_loadState < Response, "Redirect after receiving response"); ASSERT(newRequest && newRequest->status().is_success(), "Invalid redirect"); // SAMSUNG CHANGE : read timer stop timer_.Stop(); // SAMSUNG CHANGE //Android KITKAT Merge - START m_url = newUrl.spec(); //Android KITKAT Merge - END OwnPtr<WebResponse> webResponse(new WebResponse(newRequest)); webResponse->setUrl(newUrl.spec()); m_urlLoader->maybeCallOnMainThread(NewRunnableMethod( m_urlLoader.get(), &WebUrlLoaderClient::willSendRequest, webResponse.release())); // Defer the redirect until followDeferredRedirect() is called. *deferRedirect = true; }
void WebRequest::handleBrowserURL(GURL url) { std::string data("data:text/html;charset=utf-8,"); if (url.spec() == "browser:incognito") { AssetManager* assetManager = globalAssetManager(); Asset* asset = assetManager->open("webkit/incognito_mode_start_page.html", Asset::ACCESS_BUFFER); if (asset) { data.append((const char*)asset->getBuffer(false), asset->getLength()); delete asset; } } GURL dataURL(data.c_str()); handleDataURL(dataURL); }
void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description, bool was_ignored_by_handler) { Q_UNUSED(was_ignored_by_handler); if (validated_url.spec() == content::kUnreachableWebDataURL) { m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID()); qCritical("Loading error-page failed. This shouldn't happen."); if (!render_frame_host->GetParent()) m_viewClient->loadFinished(false /* success */, toQt(validated_url), true /* isErrorPage */); return; } if (render_frame_host->GetParent()) return; m_viewClient->loadFinished(false /* success */ , toQt(validated_url), false /* isErrorPage */, error_code, toQt(error_description)); m_viewClient->loadProgressChanged(0); }
void setStringField(JNIEnv* env, jobject obj, jfieldID field, const GURL& url) { jstring jstr = stdStringToJstring(env, url.spec(), false); env->SetObjectField(obj, field, jstr); env->DeleteLocalRef(jstr); }
QUrl WebContentsAdapter::activeUrl() const { GURL gurl = webContents()->GetVisibleURL(); return QUrl(QString::fromStdString(gurl.spec())); }