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

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

Issue 200054: Hook up WebFrameClient, replacing many WebViewDelegate methods.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 #include "base/logging.h" 140 #include "base/logging.h"
141 #include "base/message_loop.h" 141 #include "base/message_loop.h"
142 #include "base/stats_counters.h" 142 #include "base/stats_counters.h"
143 #include "base/string_util.h" 143 #include "base/string_util.h"
144 #include "net/base/net_errors.h" 144 #include "net/base/net_errors.h"
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/WebFrameClient.h"
150 #include "webkit/api/public/WebHistoryItem.h" 151 #include "webkit/api/public/WebHistoryItem.h"
151 #include "webkit/api/public/WebRange.h" 152 #include "webkit/api/public/WebRange.h"
152 #include "webkit/api/public/WebRect.h" 153 #include "webkit/api/public/WebRect.h"
153 #include "webkit/api/public/WebScriptSource.h" 154 #include "webkit/api/public/WebScriptSource.h"
154 #include "webkit/api/public/WebSize.h" 155 #include "webkit/api/public/WebSize.h"
155 #include "webkit/api/public/WebURLError.h" 156 #include "webkit/api/public/WebURLError.h"
156 #include "webkit/api/public/WebVector.h" 157 #include "webkit/api/public/WebVector.h"
157 #include "webkit/api/src/WebDataSourceImpl.h" 158 #include "webkit/api/src/WebDataSourceImpl.h"
158 #include "webkit/glue/chrome_client_impl.h" 159 #include "webkit/glue/chrome_client_impl.h"
159 #include "webkit/glue/dom_operations.h" 160 #include "webkit/glue/dom_operations.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 using WebCore::VisiblePosition; 211 using WebCore::VisiblePosition;
211 using WebCore::XPathResult; 212 using WebCore::XPathResult;
212 213
213 using WebKit::WebCanvas; 214 using WebKit::WebCanvas;
214 using WebKit::WebConsoleMessage; 215 using WebKit::WebConsoleMessage;
215 using WebKit::WebData; 216 using WebKit::WebData;
216 using WebKit::WebDataSource; 217 using WebKit::WebDataSource;
217 using WebKit::WebDataSourceImpl; 218 using WebKit::WebDataSourceImpl;
218 using WebKit::WebFindOptions; 219 using WebKit::WebFindOptions;
219 using WebKit::WebFrame; 220 using WebKit::WebFrame;
221 using WebKit::WebFrameClient;
220 using WebKit::WebHistoryItem; 222 using WebKit::WebHistoryItem;
221 using WebKit::WebForm; 223 using WebKit::WebForm;
222 using WebKit::WebRange; 224 using WebKit::WebRange;
223 using WebKit::WebRect; 225 using WebKit::WebRect;
224 using WebKit::WebScriptSource; 226 using WebKit::WebScriptSource;
225 using WebKit::WebSize; 227 using WebKit::WebSize;
226 using WebKit::WebString; 228 using WebKit::WebString;
227 using WebKit::WebURL; 229 using WebKit::WebURL;
228 using WebKit::WebURLError; 230 using WebKit::WebURLError;
229 using WebKit::WebURLRequest; 231 using WebKit::WebURLRequest;
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 frame_->loader()->setEncoding(encoding, user_chosen); 893 frame_->loader()->setEncoding(encoding, user_chosen);
892 894
893 // NOTE: mac only does this if there is a document 895 // NOTE: mac only does this if there is a document
894 frame_->loader()->addData(data, data_len); 896 frame_->loader()->addData(data, data_len);
895 } 897 }
896 898
897 unsigned WebFrameImpl::unloadListenerCount() const { 899 unsigned WebFrameImpl::unloadListenerCount() const {
898 return frame()->domWindow()->pendingUnloadEventListeners(); 900 return frame()->domWindow()->pendingUnloadEventListeners();
899 } 901 }
900 902
903 bool WebFrameImpl::isProcessingUserGesture() const {
904 return frame()->loader()->isProcessingUserGesture();
905 }
906
901 void WebFrameImpl::replaceSelection(const WebString& wtext) { 907 void WebFrameImpl::replaceSelection(const WebString& wtext) {
902 String text = webkit_glue::WebStringToString(wtext); 908 String text = webkit_glue::WebStringToString(wtext);
903 RefPtr<DocumentFragment> fragment = createFragmentFromText( 909 RefPtr<DocumentFragment> fragment = createFragmentFromText(
904 frame()->selection()->toNormalizedRange().get(), text); 910 frame()->selection()->toNormalizedRange().get(), text);
905 WebCore::applyCommand(WebCore::ReplaceSelectionCommand::create( 911 WebCore::applyCommand(WebCore::ReplaceSelectionCommand::create(
906 frame()->document(), fragment.get(), false, true, true)); 912 frame()->document(), fragment.get(), false, true, true));
907 } 913 }
908 914
909 void WebFrameImpl::insertText(const WebString& text) { 915 void WebFrameImpl::insertText(const WebString& text) {
910 frame()->editor()->insertText(webkit_glue::WebStringToString(text), NULL); 916 frame()->editor()->insertText(webkit_glue::WebStringToString(text), NULL);
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 active_match_index_ = -1; 1399 active_match_index_ = -1;
1394 } 1400 }
1395 1401
1396 void WebFrameImpl::increaseMatchCount(int count, int request_id) { 1402 void WebFrameImpl::increaseMatchCount(int count, int request_id) {
1397 // This function should only be called on the mainframe. 1403 // This function should only be called on the mainframe.
1398 DCHECK(!parent()); 1404 DCHECK(!parent());
1399 1405
1400 total_matchcount_ += count; 1406 total_matchcount_ += count;
1401 1407
1402 // Update the UI with the latest findings. 1408 // Update the UI with the latest findings.
1403 WebViewDelegate* webview_delegate = GetWebViewImpl()->GetDelegate(); 1409 WebViewDelegate* webview_delegate = GetWebViewImpl()->delegate();
1404 DCHECK(webview_delegate); 1410 DCHECK(webview_delegate);
1405 if (webview_delegate) 1411 if (webview_delegate)
1406 webview_delegate->ReportFindInPageMatchCount(total_matchcount_, request_id, 1412 webview_delegate->ReportFindInPageMatchCount(total_matchcount_, request_id,
1407 frames_scoping_count_ == 0); 1413 frames_scoping_count_ == 0);
1408 } 1414 }
1409 1415
1410 void WebFrameImpl::reportFindInPageSelection(const WebRect& selection_rect, 1416 void WebFrameImpl::reportFindInPageSelection(const WebRect& selection_rect,
1411 int active_match_ordinal, 1417 int active_match_ordinal,
1412 int request_id) { 1418 int request_id) {
1413 // Update the UI with the latest selection rect. 1419 // Update the UI with the latest selection rect.
1414 WebViewDelegate* webview_delegate = GetWebViewImpl()->GetDelegate(); 1420 WebViewDelegate* webview_delegate = GetWebViewImpl()->delegate();
1415 DCHECK(webview_delegate); 1421 DCHECK(webview_delegate);
1416 if (webview_delegate) { 1422 if (webview_delegate) {
1417 webview_delegate->ReportFindInPageSelection( 1423 webview_delegate->ReportFindInPageSelection(
1418 request_id, 1424 request_id,
1419 OrdinalOfFirstMatchForFrame(this) + active_match_ordinal, 1425 OrdinalOfFirstMatchForFrame(this) + active_match_ordinal,
1420 selection_rect); 1426 selection_rect);
1421 } 1427 }
1422 } 1428 }
1423 1429
1424 void WebFrameImpl::resetMatchCount() { 1430 void WebFrameImpl::resetMatchCount() {
(...skipping 20 matching lines...) Expand all
1445 } 1451 }
1446 1452
1447 WebString WebFrameImpl::contentAsMarkup() const { 1453 WebString WebFrameImpl::contentAsMarkup() const {
1448 return webkit_glue::StringToWebString(createFullMarkup(frame_->document())); 1454 return webkit_glue::StringToWebString(createFullMarkup(frame_->document()));
1449 } 1455 }
1450 1456
1451 // WebFrameImpl public --------------------------------------------------------- 1457 // WebFrameImpl public ---------------------------------------------------------
1452 1458
1453 int WebFrameImpl::live_object_count_ = 0; 1459 int WebFrameImpl::live_object_count_ = 0;
1454 1460
1455 WebFrameImpl::WebFrameImpl() 1461 WebFrameImpl::WebFrameImpl(WebFrameClient* client)
1456 : ALLOW_THIS_IN_INITIALIZER_LIST(frame_loader_client_(this)), 1462 : ALLOW_THIS_IN_INITIALIZER_LIST(frame_loader_client_(this)),
1457 ALLOW_THIS_IN_INITIALIZER_LIST(scope_matches_factory_(this)), 1463 ALLOW_THIS_IN_INITIALIZER_LIST(scope_matches_factory_(this)),
1464 client_(client),
1458 active_match_frame_(NULL), 1465 active_match_frame_(NULL),
1459 active_match_index_(-1), 1466 active_match_index_(-1),
1460 locating_active_rect_(false), 1467 locating_active_rect_(false),
1461 resume_scoping_from_range_(NULL), 1468 resume_scoping_from_range_(NULL),
1462 last_match_count_(-1), 1469 last_match_count_(-1),
1463 total_matchcount_(-1), 1470 total_matchcount_(-1),
1464 frames_scoping_count_(-1), 1471 frames_scoping_count_(-1),
1465 scoping_complete_(false), 1472 scoping_complete_(false),
1466 next_invalidate_after_(0) { 1473 next_invalidate_after_(0) {
1467 StatsCounter(kWebFrameActiveCount).Increment(); 1474 StatsCounter(kWebFrameActiveCount).Increment();
(...skipping 19 matching lines...) Expand all
1487 1494
1488 // We must call init() after frame_ is assigned because it is referenced 1495 // We must call init() after frame_ is assigned because it is referenced
1489 // during init(). 1496 // during init().
1490 frame_->init(); 1497 frame_->init();
1491 } 1498 }
1492 1499
1493 PassRefPtr<Frame> WebFrameImpl::CreateChildFrame( 1500 PassRefPtr<Frame> WebFrameImpl::CreateChildFrame(
1494 const FrameLoadRequest& request, HTMLFrameOwnerElement* owner_element) { 1501 const FrameLoadRequest& request, HTMLFrameOwnerElement* owner_element) {
1495 // TODO(darin): share code with initWithName() 1502 // TODO(darin): share code with initWithName()
1496 1503
1497 scoped_refptr<WebFrameImpl> webframe = new WebFrameImpl(); 1504 scoped_refptr<WebFrameImpl> webframe = new WebFrameImpl(client());
1498 1505
1499 // Add an extra ref on behalf of the Frame/FrameLoader, which references the 1506 // Add an extra ref on behalf of the Frame/FrameLoader, which references the
1500 // WebFrame via the FrameLoaderClient interface. See the comment at the top 1507 // WebFrame via the FrameLoaderClient interface. See the comment at the top
1501 // of this file for more info. 1508 // of this file for more info.
1502 webframe->AddRef(); 1509 webframe->AddRef();
1503 1510
1504 RefPtr<Frame> child_frame = Frame::create( 1511 RefPtr<Frame> child_frame = Frame::create(
1505 frame_->page(), owner_element, &webframe->frame_loader_client_); 1512 frame_->page(), owner_element, &webframe->frame_loader_client_);
1506 webframe->frame_ = child_frame.get(); 1513 webframe->frame_ = child_frame.get();
1507 1514
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 frame()->document()->setFocusedNode(node); 1684 frame()->document()->setFocusedNode(node);
1678 break; 1685 break;
1679 } 1686 }
1680 node = node->traverseNextNode(); 1687 node = node->traverseNextNode();
1681 } 1688 }
1682 } 1689 }
1683 } 1690 }
1684 } 1691 }
1685 1692
1686 void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) { 1693 void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) {
1687 WebViewImpl* web_view = GetWebViewImpl(); 1694 if (!client_)
1688 WebViewDelegate* delegate = web_view->delegate(); 1695 return;
1689 if (delegate) { 1696 const WebURLError& web_error =
1690 const WebURLError& web_error = 1697 webkit_glue::ResourceErrorToWebURLError(error);
1691 webkit_glue::ResourceErrorToWebURLError(error); 1698 if (was_provisional) {
1692 if (was_provisional) { 1699 client_->didFailProvisionalLoad(this, web_error);
1693 delegate->DidFailProvisionalLoadWithError(web_view, web_error, this); 1700 } else {
1694 } else { 1701 client_->didFailLoad(this, web_error);
1695 delegate->DidFailLoadWithError(web_view, web_error, this);
1696 }
1697 } 1702 }
1698 } 1703 }
1699 1704
1700 void WebFrameImpl::SetAllowsScrolling(bool flag) { 1705 void WebFrameImpl::SetAllowsScrolling(bool flag) {
1701 frame_->view()->setCanHaveScrollbars(flag); 1706 frame_->view()->setCanHaveScrollbars(flag);
1702 } 1707 }
1703 1708
1704 void WebFrameImpl::RegisterPasswordListener( 1709 void WebFrameImpl::RegisterPasswordListener(
1705 PassRefPtr<WebCore::HTMLInputElement> input_element, 1710 PassRefPtr<WebCore::HTMLInputElement> input_element,
1706 webkit_glue::PasswordAutocompleteListener* listener) { 1711 webkit_glue::PasswordAutocompleteListener* listener) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 1881
1877 SecurityOrigin* security_origin = frame_->document()->securityOrigin(); 1882 SecurityOrigin* security_origin = frame_->document()->securityOrigin();
1878 1883
1879 if (!frame_->loader()->isScheduledLocationChangePending()) { 1884 if (!frame_->loader()->isScheduledLocationChangePending()) {
1880 frame_->loader()->stopAllLoaders(); 1885 frame_->loader()->stopAllLoaders();
1881 frame_->loader()->begin(frame_->loader()->url(), true, security_origin); 1886 frame_->loader()->begin(frame_->loader()->url(), true, security_origin);
1882 frame_->loader()->write(script_result); 1887 frame_->loader()->write(script_result);
1883 frame_->loader()->end(); 1888 frame_->loader()->end();
1884 } 1889 }
1885 } 1890 }
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