OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |