Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1092)

Side by Side Diff: webkit/glue/webframe_impl.cc

Issue 159575: Move alternate error page loading out of WebFrame.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webframe_impl.h ('k') | webkit/glue/webframeloaderclient_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 #include "skia/ext/bitmap_platform_device.h" 145 #include "skia/ext/bitmap_platform_device.h"
146 #include "skia/ext/platform_canvas.h" 146 #include "skia/ext/platform_canvas.h"
147 #include "webkit/api/public/WebConsoleMessage.h" 147 #include "webkit/api/public/WebConsoleMessage.h"
148 #include "webkit/api/public/WebFindOptions.h" 148 #include "webkit/api/public/WebFindOptions.h"
149 #include "webkit/api/public/WebForm.h" 149 #include "webkit/api/public/WebForm.h"
150 #include "webkit/api/public/WebHistoryItem.h" 150 #include "webkit/api/public/WebHistoryItem.h"
151 #include "webkit/api/public/WebRect.h" 151 #include "webkit/api/public/WebRect.h"
152 #include "webkit/api/public/WebScriptSource.h" 152 #include "webkit/api/public/WebScriptSource.h"
153 #include "webkit/api/public/WebSize.h" 153 #include "webkit/api/public/WebSize.h"
154 #include "webkit/api/public/WebURLError.h" 154 #include "webkit/api/public/WebURLError.h"
155 #include "webkit/glue/alt_error_page_resource_fetcher.h"
156 #include "webkit/glue/chrome_client_impl.h" 155 #include "webkit/glue/chrome_client_impl.h"
157 #include "webkit/glue/dom_operations.h" 156 #include "webkit/glue/dom_operations.h"
158 #include "webkit/glue/dom_operations_private.h" 157 #include "webkit/glue/dom_operations_private.h"
159 #include "webkit/glue/glue_util.h" 158 #include "webkit/glue/glue_util.h"
160 #include "webkit/glue/webdatasource_impl.h" 159 #include "webkit/glue/webdatasource_impl.h"
161 #include "webkit/glue/webframe_impl.h" 160 #include "webkit/glue/webframe_impl.h"
162 #include "webkit/glue/webtextinput_impl.h" 161 #include "webkit/glue/webtextinput_impl.h"
163 #include "webkit/glue/webview_impl.h" 162 #include "webkit/glue/webview_impl.h"
164 163
165 #if defined(OS_LINUX) 164 #if defined(OS_LINUX)
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 void WebFrameImpl::StopLoading() { 596 void WebFrameImpl::StopLoading() {
598 if (!frame_) 597 if (!frame_)
599 return; 598 return;
600 599
601 // TODO(darin): Figure out what we should really do here. It seems like a 600 // TODO(darin): Figure out what we should really do here. It seems like a
602 // bug that FrameLoader::stopLoading doesn't call stopAllLoaders. 601 // bug that FrameLoader::stopLoading doesn't call stopAllLoaders.
603 frame_->loader()->stopAllLoaders(); 602 frame_->loader()->stopAllLoaders();
604 frame_->loader()->stopLoading(false); 603 frame_->loader()->stopLoading(false);
605 } 604 }
606 605
606 bool WebFrameImpl::IsLoading() const {
607 if (!frame_)
608 return false;
609 return frame_->loader()->isLoading();
610 }
611
607 WebFrame* WebFrameImpl::GetOpener() const { 612 WebFrame* WebFrameImpl::GetOpener() const {
608 if (frame_) { 613 if (frame_) {
609 Frame* opener = frame_->loader()->opener(); 614 Frame* opener = frame_->loader()->opener();
610 if (opener) 615 if (opener)
611 return FromFrame(opener); 616 return FromFrame(opener);
612 } 617 }
613 return NULL; 618 return NULL;
614 } 619 }
615 620
616 WebFrame* WebFrameImpl::GetParent() const { 621 WebFrame* WebFrameImpl::GetParent() const {
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 #endif 1502 #endif
1498 if (frame_->document() && frameview()) { 1503 if (frame_->document() && frameview()) {
1499 frameview()->paint(&gc, dirty_rect); 1504 frameview()->paint(&gc, dirty_rect);
1500 frame_->page()->inspectorController()->drawNodeHighlight(gc); 1505 frame_->page()->inspectorController()->drawNodeHighlight(gc);
1501 } else { 1506 } else {
1502 gc.fillRect(dirty_rect, Color::white); 1507 gc.fillRect(dirty_rect, Color::white);
1503 } 1508 }
1504 } 1509 }
1505 } 1510 }
1506 1511
1507 bool WebFrameImpl::IsLoading() {
1508 // I'm assuming this does what we want.
1509 return frame_->loader()->isLoading();
1510 }
1511
1512 void WebFrameImpl::Closing() { 1512 void WebFrameImpl::Closing() {
1513 alt_error_page_fetcher_.reset();
1514 frame_ = NULL; 1513 frame_ = NULL;
1515 } 1514 }
1516 1515
1517 void WebFrameImpl::DidReceiveData(DocumentLoader* loader, 1516 void WebFrameImpl::DidReceiveData(DocumentLoader* loader,
1518 const char* data, int length) { 1517 const char* data, int length) {
1519 // Set the text encoding. This calls begin() for us. It is safe to call 1518 // Set the text encoding. This calls begin() for us. It is safe to call
1520 // this multiple times (Mac does: page/mac/WebCoreFrameBridge.mm). 1519 // this multiple times (Mac does: page/mac/WebCoreFrameBridge.mm).
1521 bool user_chosen = true; 1520 bool user_chosen = true;
1522 String encoding = frame_->loader()->documentLoader()->overrideEncoding(); 1521 String encoding = frame_->loader()->documentLoader()->overrideEncoding();
1523 if (encoding.isNull()) { 1522 if (encoding.isNull()) {
1524 user_chosen = false; 1523 user_chosen = false;
1525 encoding = loader->response().textEncodingName(); 1524 encoding = loader->response().textEncodingName();
1526 } 1525 }
1527 frame_->loader()->setEncoding(encoding, user_chosen); 1526 frame_->loader()->setEncoding(encoding, user_chosen);
1528 1527
1529 // NOTE: mac only does this if there is a document 1528 // NOTE: mac only does this if there is a document
1530 frame_->loader()->addData(data, length); 1529 frame_->loader()->addData(data, length);
1531
1532 // It's possible that we get a DNS failure followed by a second load that
1533 // succeeds before we hear back from the alternate error page server. In
1534 // that case, cancel the alt error page download.
1535 alt_error_page_fetcher_.reset();
1536 } 1530 }
1537 1531
1538 void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) { 1532 void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) {
1539 WebViewImpl* web_view = GetWebViewImpl(); 1533 WebViewImpl* web_view = GetWebViewImpl();
1540 WebViewDelegate* delegate = web_view->delegate(); 1534 WebViewDelegate* delegate = web_view->delegate();
1541 if (delegate) { 1535 if (delegate) {
1542 const WebURLError& web_error = 1536 const WebURLError& web_error =
1543 webkit_glue::ResourceErrorToWebURLError(error); 1537 webkit_glue::ResourceErrorToWebURLError(error);
1544 if (was_provisional) { 1538 if (was_provisional) {
1545 delegate->DidFailProvisionalLoadWithError(web_view, web_error, this); 1539 delegate->DidFailProvisionalLoadWithError(web_view, web_error, this);
1546 } else { 1540 } else {
1547 delegate->DidFailLoadWithError(web_view, web_error, this); 1541 delegate->DidFailLoadWithError(web_view, web_error, this);
1548 } 1542 }
1549 } 1543 }
1550 } 1544 }
1551 1545
1552 void WebFrameImpl::LoadAlternateHTMLErrorPage(const WebURLRequest& request,
1553 const WebURLError& error,
1554 const GURL& error_page_url,
1555 bool replace,
1556 const GURL& fake_url) {
1557 // Load alternate HTML in place of the previous request. We use a fake_url
1558 // for the Base URL. That prevents other web content from the same origin
1559 // as the failed URL to script the error page.
1560
1561 LoadHTMLString("", // Empty document
1562 fake_url,
1563 error.unreachableURL,
1564 replace);
1565
1566 alt_error_page_fetcher_.reset(new AltErrorPageResourceFetcher(
1567 error_page_url, this, error.unreachableURL,
1568 NewCallback(this, &WebFrameImpl::AltErrorPageFinished)));
1569 }
1570
1571 void WebFrameImpl::DispatchWillSendRequest(WebURLRequest* request) { 1546 void WebFrameImpl::DispatchWillSendRequest(WebURLRequest* request) {
1572 ResourceResponse response; 1547 ResourceResponse response;
1573 frame_->loader()->client()->dispatchWillSendRequest(NULL, 0, 1548 frame_->loader()->client()->dispatchWillSendRequest(NULL, 0,
1574 *webkit_glue::WebURLRequestToMutableResourceRequest(request), 1549 *webkit_glue::WebURLRequestToMutableResourceRequest(request),
1575 response); 1550 response);
1576 } 1551 }
1577 1552
1578 void WebFrameImpl::ExecuteScript(const WebScriptSource& source) { 1553 void WebFrameImpl::ExecuteScript(const WebScriptSource& source) {
1579 frame_->loader()->executeScript( 1554 frame_->loader()->executeScript(
1580 WebCore::ScriptSourceCode( 1555 WebCore::ScriptSourceCode(
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 1815
1841 SecurityOrigin* security_origin = frame_->document()->securityOrigin(); 1816 SecurityOrigin* security_origin = frame_->document()->securityOrigin();
1842 1817
1843 if (!frame_->loader()->isScheduledLocationChangePending()) { 1818 if (!frame_->loader()->isScheduledLocationChangePending()) {
1844 frame_->loader()->stopAllLoaders(); 1819 frame_->loader()->stopAllLoaders();
1845 frame_->loader()->begin(frame_->loader()->url(), true, security_origin); 1820 frame_->loader()->begin(frame_->loader()->url(), true, security_origin);
1846 frame_->loader()->write(script_result); 1821 frame_->loader()->write(script_result);
1847 frame_->loader()->end(); 1822 frame_->loader()->end();
1848 } 1823 }
1849 } 1824 }
1850
1851 void WebFrameImpl::AltErrorPageFinished(const GURL& unreachable_url,
1852 const std::string& html) {
1853 WebViewDelegate* d = GetWebViewImpl()->delegate();
1854 if (!d)
1855 return;
1856 WebURLError error;
1857 error.unreachableURL = unreachable_url;
1858 d->LoadNavigationErrorPage(this, WebURLRequest(), error, html, true);
1859 }
OLDNEW
« no previous file with comments | « webkit/glue/webframe_impl.h ('k') | webkit/glue/webframeloaderclient_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698