| 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 "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" | 9 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (delegate_) { | 98 if (delegate_) { |
| 99 delegate_->WillDestroyPlugin(); | 99 delegate_->WillDestroyPlugin(); |
| 100 delegate_ = NULL; | 100 delegate_ = NULL; |
| 101 } | 101 } |
| 102 if (container_) | 102 if (container_) |
| 103 container_->element().setAttribute("title", old_title_); | 103 container_->element().setAttribute("title", old_title_); |
| 104 container_ = NULL; | 104 container_ = NULL; |
| 105 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 105 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 106 } | 106 } |
| 107 | 107 |
| 108 NPObject* WebViewPlugin::scriptableObject() { |
| 109 return NULL; |
| 110 } |
| 111 |
| 108 void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { | 112 void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { |
| 109 gfx::Rect paintRect(rect_.Intersect(rect)); | 113 gfx::Rect paintRect(rect_.Intersect(rect)); |
| 110 if (paintRect.IsEmpty()) | 114 if (paintRect.IsEmpty()) |
| 111 return; | 115 return; |
| 112 | 116 |
| 113 paintRect.Offset(-rect_.x(), -rect_.y()); | 117 paintRect.Offset(-rect_.x(), -rect_.y()); |
| 114 | 118 |
| 115 #if WEBKIT_USING_CG | 119 #if WEBKIT_USING_CG |
| 116 CGContextRef context = canvas; | 120 CGContextRef context = canvas; |
| 117 CGContextTranslateCTM(context, rect_.x(), rect_.y()); | 121 CGContextTranslateCTM(context, rect_.x(), rect_.y()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 136 // Coordinates are relative to the containing window. | 140 // Coordinates are relative to the containing window. |
| 137 void WebViewPlugin::updateGeometry( | 141 void WebViewPlugin::updateGeometry( |
| 138 const WebRect& frame_rect, const WebRect& clip_rect, | 142 const WebRect& frame_rect, const WebRect& clip_rect, |
| 139 const WebVector<WebRect>& cut_out_rects, bool is_visible) { | 143 const WebVector<WebRect>& cut_out_rects, bool is_visible) { |
| 140 if (frame_rect != rect_) { | 144 if (frame_rect != rect_) { |
| 141 rect_ = frame_rect; | 145 rect_ = frame_rect; |
| 142 web_view_->resize(WebSize(frame_rect.width, frame_rect.height)); | 146 web_view_->resize(WebSize(frame_rect.width, frame_rect.height)); |
| 143 } | 147 } |
| 144 } | 148 } |
| 145 | 149 |
| 150 bool WebViewPlugin::acceptsInputEvents() { |
| 151 return true; |
| 152 } |
| 153 |
| 146 bool WebViewPlugin::handleInputEvent(const WebInputEvent& event, | 154 bool WebViewPlugin::handleInputEvent(const WebInputEvent& event, |
| 147 WebCursorInfo& cursor) { | 155 WebCursorInfo& cursor) { |
| 148 if (event.type == WebInputEvent::ContextMenu) { | 156 if (event.type == WebInputEvent::ContextMenu) { |
| 149 if (delegate_) { | 157 if (delegate_) { |
| 150 const WebMouseEvent& mouse_event = | 158 const WebMouseEvent& mouse_event = |
| 151 reinterpret_cast<const WebMouseEvent&>(event); | 159 reinterpret_cast<const WebMouseEvent&>(event); |
| 152 delegate_->ShowContextMenu(mouse_event); | 160 delegate_->ShowContextMenu(mouse_event); |
| 153 } | 161 } |
| 154 return true; | 162 return true; |
| 155 } | 163 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 171 void WebViewPlugin::didFinishLoading() { | 179 void WebViewPlugin::didFinishLoading() { |
| 172 DCHECK(!finished_loading_); | 180 DCHECK(!finished_loading_); |
| 173 finished_loading_ = true; | 181 finished_loading_ = true; |
| 174 } | 182 } |
| 175 | 183 |
| 176 void WebViewPlugin::didFailLoading(const WebURLError& error) { | 184 void WebViewPlugin::didFailLoading(const WebURLError& error) { |
| 177 DCHECK(!error_.get()); | 185 DCHECK(!error_.get()); |
| 178 error_.reset(new WebURLError(error)); | 186 error_.reset(new WebURLError(error)); |
| 179 } | 187 } |
| 180 | 188 |
| 189 bool WebViewPlugin::acceptsLoadDrops() { |
| 190 return false; |
| 191 } |
| 192 |
| 181 void WebViewPlugin::setToolTipText(const WebKit::WebString& text, | 193 void WebViewPlugin::setToolTipText(const WebKit::WebString& text, |
| 182 WebKit::WebTextDirection hint) { | 194 WebKit::WebTextDirection hint) { |
| 183 if (container_) | 195 if (container_) |
| 184 container_->element().setAttribute("title", text); | 196 container_->element().setAttribute("title", text); |
| 185 } | 197 } |
| 186 | 198 |
| 187 void WebViewPlugin::startDragging(const WebDragData&, | 199 void WebViewPlugin::startDragging(const WebDragData&, |
| 188 WebDragOperationsMask, | 200 WebDragOperationsMask, |
| 189 const WebImage&, | 201 const WebImage&, |
| 190 const WebPoint&) { | 202 const WebPoint&) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 214 WebURLError WebViewPlugin::cancelledError(WebFrame* frame, | 226 WebURLError WebViewPlugin::cancelledError(WebFrame* frame, |
| 215 const WebURLRequest& request) { | 227 const WebURLRequest& request) { |
| 216 // Return an error with a non-zero reason so isNull() on the corresponding | 228 // Return an error with a non-zero reason so isNull() on the corresponding |
| 217 // ResourceError is false. | 229 // ResourceError is false. |
| 218 WebURLError error; | 230 WebURLError error; |
| 219 error.domain = "WebViewPlugin"; | 231 error.domain = "WebViewPlugin"; |
| 220 error.reason = -1; | 232 error.reason = -1; |
| 221 error.unreachableURL = request.url(); | 233 error.unreachableURL = request.url(); |
| 222 return error; | 234 return error; |
| 223 } | 235 } |
| OLD | NEW |