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

Side by Side Diff: webkit/glue/plugins/webview_plugin.cc

Issue 3020031: Watch out for invalid delegate and container after destroying the WebViewPlugin. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/glue/plugins/webview_plugin.h" 5 #include "webkit/glue/plugins/webview_plugin.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" 8 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 bool WebViewPlugin::initialize(WebPluginContainer* container) { 50 bool WebViewPlugin::initialize(WebPluginContainer* container) {
51 container_ = container; 51 container_ = container;
52 return true; 52 return true;
53 } 53 }
54 54
55 void WebViewPlugin::destroy() { 55 void WebViewPlugin::destroy() {
56 delegate_->WillDestroyPlugin(); 56 delegate_->WillDestroyPlugin();
57 delegate_ = NULL; 57 delegate_ = NULL;
58 container_ = NULL;
58 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 59 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
59 } 60 }
60 61
61 void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { 62 void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
62 gfx::Rect paintRect(rect_.Intersect(rect)); 63 gfx::Rect paintRect(rect_.Intersect(rect));
63 if (paintRect.IsEmpty()) 64 if (paintRect.IsEmpty())
64 return; 65 return;
65 66
66 paintRect.Offset(-rect_.x(), -rect_.y()); 67 paintRect.Offset(-rect_.x(), -rect_.y());
67 68
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 void WebViewPlugin::startDragging(const WebDragData&, 108 void WebViewPlugin::startDragging(const WebDragData&,
108 WebDragOperationsMask, 109 WebDragOperationsMask,
109 const WebImage&, 110 const WebImage&,
110 const WebPoint&) { 111 const WebPoint&) {
111 // Immediately stop dragging. 112 // Immediately stop dragging.
112 web_view_->dragSourceSystemDragEnded(); 113 web_view_->dragSourceSystemDragEnded();
113 } 114 }
114 115
115 void WebViewPlugin::didInvalidateRect(const WebRect& rect) { 116 void WebViewPlugin::didInvalidateRect(const WebRect& rect) {
116 if (container_) 117 if (container_)
117 container_->invalidateRect(WebRect(rect)); 118 container_->invalidateRect(rect);
118 } 119 }
119 120
120 void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) { 121 void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) {
121 current_cursor_ = cursor; 122 current_cursor_ = cursor;
122 } 123 }
123 124
124 void WebViewPlugin::didClearWindowObject(WebFrame* frame) { 125 void WebViewPlugin::didClearWindowObject(WebFrame* frame) {
125 delegate_->BindWebFrame(frame); 126 if (delegate_)
127 delegate_->BindWebFrame(frame);
126 } 128 }
127 129
128 bool WebViewPlugin::canHandleRequest(WebFrame* frame, 130 bool WebViewPlugin::canHandleRequest(WebFrame* frame,
129 const WebURLRequest& request) { 131 const WebURLRequest& request) {
130 return GURL(request.url()).SchemeIs("chrome"); 132 return GURL(request.url()).SchemeIs("chrome");
131 } 133 }
132 134
133 WebURLError WebViewPlugin::cancelledError(WebFrame* frame, 135 WebURLError WebViewPlugin::cancelledError(WebFrame* frame,
134 const WebURLRequest& request) { 136 const WebURLRequest& request) {
135 // Return an error with a non-zero reason so isNull() on the corresponding 137 // Return an error with a non-zero reason so isNull() on the corresponding
136 // ResourceError is false. 138 // ResourceError is false.
137 WebURLError error; 139 WebURLError error;
138 error.domain = "WebViewPlugin"; 140 error.domain = "WebViewPlugin";
139 error.reason = -1; 141 error.reason = -1;
140 error.unreachableURL = request.url(); 142 error.unreachableURL = request.url();
141 return error; 143 return error;
142 } 144 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698