| OLD | NEW |
| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 using WebKit::WebForm; | 217 using WebKit::WebForm; |
| 218 using WebKit::WebRect; | 218 using WebKit::WebRect; |
| 219 using WebKit::WebScriptSource; | 219 using WebKit::WebScriptSource; |
| 220 using WebKit::WebSize; | 220 using WebKit::WebSize; |
| 221 using WebKit::WebString; | 221 using WebKit::WebString; |
| 222 using WebKit::WebURL; | 222 using WebKit::WebURL; |
| 223 using WebKit::WebURLError; | 223 using WebKit::WebURLError; |
| 224 using WebKit::WebURLRequest; | 224 using WebKit::WebURLRequest; |
| 225 using WebKit::WebURLResponse; | 225 using WebKit::WebURLResponse; |
| 226 | 226 |
| 227 using webkit_glue::AltErrorPageResourceFetcher; | |
| 228 | |
| 229 // Key for a StatsCounter tracking how many WebFrames are active. | 227 // Key for a StatsCounter tracking how many WebFrames are active. |
| 230 static const char* const kWebFrameActiveCount = "WebFrameActiveCount"; | 228 static const char* const kWebFrameActiveCount = "WebFrameActiveCount"; |
| 231 | 229 |
| 232 static const char* const kOSDType = "application/opensearchdescription+xml"; | 230 static const char* const kOSDType = "application/opensearchdescription+xml"; |
| 233 static const char* const kOSDRel = "search"; | 231 static const char* const kOSDRel = "search"; |
| 234 | 232 |
| 235 // The separator between frames when the frames are converted to plain text. | 233 // The separator between frames when the frames are converted to plain text. |
| 236 static const wchar_t kFrameSeparator[] = L"\n\n"; | 234 static const wchar_t kFrameSeparator[] = L"\n\n"; |
| 237 static const int kFrameSeparatorLen = arraysize(kFrameSeparator) - 1; | 235 static const int kFrameSeparatorLen = arraysize(kFrameSeparator) - 1; |
| 238 | 236 |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 } else { | 1504 } else { |
| 1507 gc.fillRect(dirty_rect, Color::white); | 1505 gc.fillRect(dirty_rect, Color::white); |
| 1508 } | 1506 } |
| 1509 } | 1507 } |
| 1510 } | 1508 } |
| 1511 | 1509 |
| 1512 void WebFrameImpl::Closing() { | 1510 void WebFrameImpl::Closing() { |
| 1513 frame_ = NULL; | 1511 frame_ = NULL; |
| 1514 } | 1512 } |
| 1515 | 1513 |
| 1516 void WebFrameImpl::DidReceiveData(DocumentLoader* loader, | |
| 1517 const char* data, int length) { | |
| 1518 // Set the text encoding. This calls begin() for us. It is safe to call | |
| 1519 // this multiple times (Mac does: page/mac/WebCoreFrameBridge.mm). | |
| 1520 bool user_chosen = true; | |
| 1521 String encoding = frame_->loader()->documentLoader()->overrideEncoding(); | |
| 1522 if (encoding.isNull()) { | |
| 1523 user_chosen = false; | |
| 1524 encoding = loader->response().textEncodingName(); | |
| 1525 } | |
| 1526 frame_->loader()->setEncoding(encoding, user_chosen); | |
| 1527 | |
| 1528 // NOTE: mac only does this if there is a document | |
| 1529 frame_->loader()->addData(data, length); | |
| 1530 } | |
| 1531 | |
| 1532 void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) { | 1514 void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) { |
| 1533 WebViewImpl* web_view = GetWebViewImpl(); | 1515 WebViewImpl* web_view = GetWebViewImpl(); |
| 1534 WebViewDelegate* delegate = web_view->delegate(); | 1516 WebViewDelegate* delegate = web_view->delegate(); |
| 1535 if (delegate) { | 1517 if (delegate) { |
| 1536 const WebURLError& web_error = | 1518 const WebURLError& web_error = |
| 1537 webkit_glue::ResourceErrorToWebURLError(error); | 1519 webkit_glue::ResourceErrorToWebURLError(error); |
| 1538 if (was_provisional) { | 1520 if (was_provisional) { |
| 1539 delegate->DidFailProvisionalLoadWithError(web_view, web_error, this); | 1521 delegate->DidFailProvisionalLoadWithError(web_view, web_error, this); |
| 1540 } else { | 1522 } else { |
| 1541 delegate->DidFailLoadWithError(web_view, web_error, this); | 1523 delegate->DidFailLoadWithError(web_view, web_error, this); |
| 1542 } | 1524 } |
| 1543 } | 1525 } |
| 1544 } | 1526 } |
| 1545 | 1527 |
| 1546 void WebFrameImpl::DispatchWillSendRequest(WebURLRequest* request) { | 1528 void WebFrameImpl::DispatchWillSendRequest(WebURLRequest* request) { |
| 1547 ResourceResponse response; | 1529 ResourceResponse response; |
| 1548 frame_->loader()->client()->dispatchWillSendRequest(NULL, 0, | 1530 frame_->loader()->client()->dispatchWillSendRequest(NULL, 0, |
| 1549 *webkit_glue::WebURLRequestToMutableResourceRequest(request), | 1531 *webkit_glue::WebURLRequestToMutableResourceRequest(request), |
| 1550 response); | 1532 response); |
| 1551 } | 1533 } |
| 1552 | 1534 |
| 1535 void WebFrameImpl::CommitDocumentData(const char* data, size_t data_len) { |
| 1536 DocumentLoader* document_loader = frame_->loader()->documentLoader(); |
| 1537 |
| 1538 // Set the text encoding. This calls begin() for us. It is safe to call |
| 1539 // this multiple times (Mac does: page/mac/WebCoreFrameBridge.mm). |
| 1540 bool user_chosen = true; |
| 1541 String encoding = document_loader->overrideEncoding(); |
| 1542 if (encoding.isNull()) { |
| 1543 user_chosen = false; |
| 1544 encoding = document_loader->response().textEncodingName(); |
| 1545 } |
| 1546 frame_->loader()->setEncoding(encoding, user_chosen); |
| 1547 |
| 1548 // NOTE: mac only does this if there is a document |
| 1549 frame_->loader()->addData(data, data_len); |
| 1550 } |
| 1551 |
| 1553 void WebFrameImpl::ExecuteScript(const WebScriptSource& source) { | 1552 void WebFrameImpl::ExecuteScript(const WebScriptSource& source) { |
| 1554 frame_->loader()->executeScript( | 1553 frame_->loader()->executeScript( |
| 1555 WebCore::ScriptSourceCode( | 1554 WebCore::ScriptSourceCode( |
| 1556 webkit_glue::WebStringToString(source.code), | 1555 webkit_glue::WebStringToString(source.code), |
| 1557 webkit_glue::WebURLToKURL(source.url), | 1556 webkit_glue::WebURLToKURL(source.url), |
| 1558 source.startLine)); | 1557 source.startLine)); |
| 1559 } | 1558 } |
| 1560 | 1559 |
| 1561 bool WebFrameImpl::InsertCSSStyles(const std::string& css) { | 1560 bool WebFrameImpl::InsertCSSStyles(const std::string& css) { |
| 1562 Document* document = frame()->document(); | 1561 Document* document = frame()->document(); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 | 1814 |
| 1816 SecurityOrigin* security_origin = frame_->document()->securityOrigin(); | 1815 SecurityOrigin* security_origin = frame_->document()->securityOrigin(); |
| 1817 | 1816 |
| 1818 if (!frame_->loader()->isScheduledLocationChangePending()) { | 1817 if (!frame_->loader()->isScheduledLocationChangePending()) { |
| 1819 frame_->loader()->stopAllLoaders(); | 1818 frame_->loader()->stopAllLoaders(); |
| 1820 frame_->loader()->begin(frame_->loader()->url(), true, security_origin); | 1819 frame_->loader()->begin(frame_->loader()->url(), true, security_origin); |
| 1821 frame_->loader()->write(script_result); | 1820 frame_->loader()->write(script_result); |
| 1822 frame_->loader()->end(); | 1821 frame_->loader()->end(); |
| 1823 } | 1822 } |
| 1824 } | 1823 } |
| OLD | NEW |