summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webframeloaderclient_impl.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 16:37:20 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 16:37:20 +0000
commit7e45de83658f59c24998c37bf252792dfb31eb43 (patch)
tree9bff5b72794b2aef52053974e0d4b4364731abb9 /webkit/glue/webframeloaderclient_impl.cc
parent6b606125caa86980e660b441a1a0ca3d4c19bd50 (diff)
downloadchromium_src-7e45de83658f59c24998c37bf252792dfb31eb43.zip
chromium_src-7e45de83658f59c24998c37bf252792dfb31eb43.tar.gz
chromium_src-7e45de83658f59c24998c37bf252792dfb31eb43.tar.bz2
Convert types in WebFrameLoaderClientImpl in preparation for moving
this class into the WebKit API implementation. R=dglazkov BUG=10034 TEST=none Review URL: http://codereview.chromium.org/273003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webframeloaderclient_impl.cc')
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc98
1 files changed, 44 insertions, 54 deletions
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index 0841657..826625dd 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -4,9 +4,6 @@
#include "config.h"
-#include <string>
-#include <vector>
-
#include "Chrome.h"
#include "CString.h"
#include "Document.h"
@@ -27,9 +24,6 @@
#include "WindowFeatures.h"
#undef LOG
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "base/string_util.h"
#include "net/base/mime_util.h"
#include "net/base/net_errors.h"
#include "webkit/api/public/WebForm.h"
@@ -47,19 +41,14 @@
#include "webkit/api/src/WrappedResourceRequest.h"
#include "webkit/api/src/WrappedResourceResponse.h"
#include "webkit/glue/glue_util.h"
-#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/webdevtoolsagent_impl.h"
#include "webkit/glue/webframe_impl.h"
#include "webkit/glue/webframeloaderclient_impl.h"
#include "webkit/glue/webkit_glue.h"
-#include "webkit/glue/webview_delegate.h"
#include "webkit/glue/webview_impl.h"
using namespace WebCore;
-using base::Time;
-using base::TimeDelta;
-
using WebKit::WebData;
using WebKit::WebDataSourceImpl;
using WebKit::WebNavigationType;
@@ -429,7 +418,8 @@ void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() {
void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() {
WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl();
if (!ds) {
- NOTREACHED() << "Got a server redirect when there is no provisional DS";
+ // Got a server redirect when there is no provisional DS!
+ ASSERT_NOT_REACHED();
return;
}
@@ -439,13 +429,13 @@ void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
// A provisional load should have started already, which should have put an
// entry in our redirect chain.
- DCHECK(ds->hasRedirectChain());
+ ASSERT(ds->hasRedirectChain());
// The URL of the destination is on the provisional data source. We also need
// to update the redirect chain to account for this addition (we do this
// before the callback so the callback can look at the redirect chain to see
// what happened).
- ds->appendRedirect(ds->request().url());
+ ds->appendRedirect(webkit_glue::WebURLToKURL(ds->request().url()));
if (webframe_->client())
webframe_->client()->didReceiveServerRedirectForProvisionalLoad(webframe_);
@@ -455,8 +445,8 @@ void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
void WebFrameLoaderClient::dispatchDidCancelClientRedirect() {
// No longer expecting a client redirect.
if (webframe_->client()) {
- expected_client_redirect_src_ = GURL();
- expected_client_redirect_dest_ = GURL();
+ expected_client_redirect_src_ = KURL();
+ expected_client_redirect_dest_ = KURL();
webframe_->client()->didCancelClientRedirect(webframe_);
}
@@ -470,26 +460,25 @@ void WebFrameLoaderClient::dispatchWillPerformClientRedirect(
double fire_date) {
// Tells dispatchDidStartProvisionalLoad that if it sees this item it is a
// redirect and the source item should be added as the start of the chain.
- expected_client_redirect_src_ = webframe_->url();
- expected_client_redirect_dest_ = webkit_glue::KURLToGURL(url);
+ expected_client_redirect_src_ = webkit_glue::WebURLToKURL(webframe_->url());
+ expected_client_redirect_dest_ = url;
// TODO(timsteele): bug 1135512. Webkit does not properly notify us of
// cancelling http > file client redirects. Since the FrameLoader's policy
// is to never carry out such a navigation anyway, the best thing we can do
// for now to not get confused is ignore this notification.
- if (expected_client_redirect_dest_.SchemeIsFile() &&
- (expected_client_redirect_src_.SchemeIs("http") ||
- expected_client_redirect_src_.SchemeIsSecure())) {
- expected_client_redirect_src_ = GURL();
- expected_client_redirect_dest_ = GURL();
+ if (expected_client_redirect_dest_.isLocalFile() &&
+ expected_client_redirect_src_.protocolInHTTPFamily()) {
+ expected_client_redirect_src_ = KURL();
+ expected_client_redirect_dest_ = KURL();
return;
}
if (webframe_->client()) {
webframe_->client()->willPerformClientRedirect(
webframe_,
- expected_client_redirect_src_,
- expected_client_redirect_dest_,
+ webkit_glue::KURLToWebURL(expected_client_redirect_src_),
+ webkit_glue::KURLToWebURL(expected_client_redirect_dest_),
static_cast<unsigned int>(interval),
static_cast<unsigned int>(fire_date));
}
@@ -503,10 +492,10 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() {
webview->client()->didStartLoading();
WebDataSourceImpl* ds = webframe_->GetDataSourceImpl();
- DCHECK(ds) << "DataSource NULL when navigating to reference fragment";
+ ASSERT(ds); // Should not be null when navigating to a reference fragment!
if (ds) {
- GURL url = ds->request().url();
- GURL chain_end = ds->endOfRedirectChain();
+ KURL url = webkit_glue::WebURLToKURL(ds->request().url());
+ KURL chain_end = ds->endOfRedirectChain();
ds->clearRedirectChain();
// Figure out if this location change is because of a JS-initiated client
@@ -523,13 +512,15 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() {
!webframe_->isProcessingUserGesture();
if (was_client_redirect) {
- if (webframe_->client())
- webframe_->client()->didCompleteClientRedirect(webframe_, chain_end);
+ if (webframe_->client()) {
+ webframe_->client()->didCompleteClientRedirect(
+ webframe_, webkit_glue::KURLToWebURL(chain_end));
+ }
ds->appendRedirect(chain_end);
// Make sure we clear the expected redirect since we just effectively
// completed it.
- expected_client_redirect_src_ = GURL();
- expected_client_redirect_dest_ = GURL();
+ expected_client_redirect_src_ = KURL();
+ expected_client_redirect_dest_ = KURL();
}
// Regardless of how we got here, we are navigating to a URL so we need to
@@ -566,24 +557,24 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() {
// See dispatchDidReceiveServerRedirectForProvisionalLoad.
WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl();
if (!ds) {
- NOTREACHED() << "Attempting to provisional load but there isn't one";
+ ASSERT_NOT_REACHED();
return;
}
- GURL url = ds->request().url();
+ KURL url = webkit_glue::WebURLToKURL(ds->request().url());
// Since the provisional load just started, we should have not gotten
// any redirects yet.
- DCHECK(!ds->hasRedirectChain());
+ ASSERT(!ds->hasRedirectChain());
// If this load is what we expected from a client redirect, treat it as a
// redirect from that original page. The expected redirect urls will be
// cleared by DidCancelClientRedirect.
bool completing_client_redirect = false;
- if (expected_client_redirect_src_.is_valid()) {
+ if (expected_client_redirect_src_.isValid()) {
// expected_client_redirect_dest_ could be something like
// "javascript:history.go(-1)" thus we need to exclude url starts with
// "javascript:". See bug: 1080873
- DCHECK(expected_client_redirect_dest_.SchemeIs("javascript") ||
+ ASSERT(expected_client_redirect_dest_.protocolIs("javascript") ||
expected_client_redirect_dest_ == url);
ds->appendRedirect(expected_client_redirect_src_);
completing_client_redirect = true;
@@ -599,7 +590,7 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() {
webframe_->client()->didStartProvisionalLoad(webframe_);
if (completing_client_redirect)
webframe_->client()->didCompleteClientRedirect(
- webframe_, expected_client_redirect_src_);
+ webframe_, webkit_glue::KURLToWebURL(expected_client_redirect_src_));
}
}
@@ -685,7 +676,7 @@ Frame* WebFrameLoaderClient::dispatchCreatePage() {
// Make sure that we have a valid disposition. This should have been set in
// the preceeding call to dispatchDecidePolicyForNewWindowAction.
- DCHECK(next_navigation_policy_ != WebKit::WebNavigationPolicyIgnore);
+ ASSERT(next_navigation_policy_ != WebKit::WebNavigationPolicyIgnore);
WebNavigationPolicy policy = next_navigation_policy_;
next_navigation_policy_ = WebKit::WebNavigationPolicyIgnore;
@@ -699,9 +690,8 @@ Frame* WebFrameLoaderClient::dispatchCreatePage() {
void WebFrameLoaderClient::dispatchShow() {
WebViewImpl* webview = webframe_->GetWebViewImpl();
- WebViewDelegate* d = webview->delegate();
- if (d)
- d->show(webview->initial_navigation_policy());
+ if (webview && webview->client())
+ webview->client()->show(webview->initial_navigation_policy());
}
static bool TreatAsAttachment(const ResourceResponse& response) {
@@ -809,8 +799,8 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(
// Give the delegate a chance to change the navigation policy.
const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl();
if (ds) {
- GURL url = ds->request().url();
- if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) {
+ KURL url = webkit_glue::WebURLToKURL(ds->request().url());
+ if (url.protocolIs(webkit_glue::kBackForwardNavigationScheme)) {
HandleBackForwardNavigation(url);
navigation_policy = WebKit::WebNavigationPolicyIgnore;
} else {
@@ -1152,7 +1142,8 @@ String WebFrameLoaderClient::userAgent(const KURL& url) {
}
void WebFrameLoaderClient::savePlatformDataToCachedFrame(WebCore::CachedFrame*) {
- NOTREACHED() << "Page cache should be disabled";
+ // The page cache should be disabled.
+ ASSERT_NOT_REACHED();
}
void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) {
@@ -1177,7 +1168,7 @@ void WebFrameLoaderClient::download(ResourceHandle* handle,
const ResourceRequest& request,
const ResourceRequest& initialRequest,
const ResourceResponse& response) {
- NOTREACHED();
+ ASSERT_NOT_REACHED();
}
PassRefPtr<Frame> WebFrameLoaderClient::createFrame(
@@ -1246,7 +1237,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(
// (e.g., acrobat reader).
void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) {
plugin_widget_ = static_cast<WebPluginContainerImpl*>(pluginWidget);
- DCHECK(plugin_widget_.get());
+ ASSERT(plugin_widget_.get());
}
PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(
@@ -1293,8 +1284,7 @@ ObjectContentType WebFrameLoaderClient::objectContentType(
String WebFrameLoaderClient::overrideMediaType() const {
// FIXME
- String rv;
- return rv;
+ return String();
}
bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy(
@@ -1310,12 +1300,12 @@ bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy(
policy);
}
-void WebFrameLoaderClient::HandleBackForwardNavigation(const GURL& url) {
- DCHECK(url.SchemeIs(webkit_glue::kBackForwardNavigationScheme));
+void WebFrameLoaderClient::HandleBackForwardNavigation(const KURL& url) {
+ ASSERT(url.protocolIs(webkit_glue::kBackForwardNavigationScheme));
- std::string offset_str = url.ExtractFileName();
- int offset;
- if (!StringToInt(offset_str, &offset))
+ bool ok;
+ int offset = url.lastPathComponent().toIntStrict(&ok);
+ if (!ok)
return;
WebViewImpl* webview = webframe_->GetWebViewImpl();