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

Side by Side Diff: content/renderer/npapi/webplugin_impl.cc

Issue 1815593002: Remove windowed NPAPI code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@make_test_plugin_windowless
Patch Set: rebase Created 4 years, 9 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 | « content/renderer/npapi/webplugin_impl.h ('k') | content/renderer/render_widget.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/npapi/webplugin_impl.h" 5 #include "content/renderer/npapi/webplugin_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/crash_logging.h" 9 #include "base/debug/crash_logging.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // Note that |canvas| is only used when in windowless mode. 185 // Note that |canvas| is only used when in windowless mode.
186 delegate_->Paint(canvas, paint_rect); 186 delegate_->Paint(canvas, paint_rect);
187 } 187 }
188 188
189 void WebPluginImpl::updateGeometry(const WebRect& window_rect, 189 void WebPluginImpl::updateGeometry(const WebRect& window_rect,
190 const WebRect& clip_rect, 190 const WebRect& clip_rect,
191 const WebRect& unobscured_rect, 191 const WebRect& unobscured_rect,
192 const WebVector<WebRect>& cut_outs_rects, 192 const WebVector<WebRect>& cut_outs_rects,
193 bool is_visible) { 193 bool is_visible) {
194 WebPluginGeometry new_geometry; 194 WebPluginGeometry new_geometry;
195 new_geometry.window = window_;
196 new_geometry.window_rect = window_rect; 195 new_geometry.window_rect = window_rect;
197 new_geometry.clip_rect = clip_rect; 196 new_geometry.clip_rect = clip_rect;
198 new_geometry.visible = is_visible; 197 new_geometry.visible = is_visible;
199 new_geometry.rects_valid = true; 198 new_geometry.rects_valid = true;
200 for (size_t i = 0; i < cut_outs_rects.size(); ++i) 199 for (size_t i = 0; i < cut_outs_rects.size(); ++i)
201 new_geometry.cutout_rects.push_back(cut_outs_rects[i]); 200 new_geometry.cutout_rects.push_back(cut_outs_rects[i]);
202 201
203 // Only send DidMovePlugin if the geometry changed in some way.
204 if (window_ && (first_geometry_update_ || !new_geometry.Equals(geometry_))) {
205 render_frame_->GetRenderWidget()->SchedulePluginMove(new_geometry);
206 // We invalidate windowed plugins during the first geometry update to
207 // ensure that they get reparented to the wrapper window in the browser.
208 // This ensures that they become visible and are painted by the OS. This is
209 // required as some pages don't invalidate when the plugin is added.
210 if (first_geometry_update_ && window_) {
211 InvalidateRect(window_rect);
212 }
213 }
214
215 // Only UpdateGeometry if either the window or clip rects have changed. 202 // Only UpdateGeometry if either the window or clip rects have changed.
216 if (delegate_ && (first_geometry_update_ || 203 if (delegate_ && (first_geometry_update_ ||
217 new_geometry.window_rect != geometry_.window_rect || 204 new_geometry.window_rect != geometry_.window_rect ||
218 new_geometry.clip_rect != geometry_.clip_rect)) { 205 new_geometry.clip_rect != geometry_.clip_rect)) {
219 // Notify the plugin that its parameters have changed. 206 // Notify the plugin that its parameters have changed.
220 delegate_->UpdateGeometry(new_geometry.window_rect, new_geometry.clip_rect); 207 delegate_->UpdateGeometry(new_geometry.window_rect, new_geometry.clip_rect);
221 } 208 }
222 209
223 #if defined(OS_WIN) 210 #if defined(OS_WIN)
224 // Don't cache the geometry during the first geometry update. The first 211 // Don't cache the geometry during the first geometry update. The first
225 // geometry update sequence is received when Widget::setParent is called. 212 // geometry update sequence is received when Widget::setParent is called.
226 // For plugins like media player which have a bug where they only honor 213 // For plugins like media player which have a bug where they only honor
227 // the first geometry update, we have a quirk which ignores the first 214 // the first geometry update, we have a quirk which ignores the first
228 // geometry update. To ensure that these plugins work correctly in cases 215 // geometry update. To ensure that these plugins work correctly in cases
229 // where we receive only one geometry update from webkit, we also force 216 // where we receive only one geometry update from webkit, we also force
230 // a geometry update during paint which should go out correctly as the 217 // a geometry update during paint which should go out correctly as the
231 // initial geometry update was not cached. 218 // initial geometry update was not cached.
232 if (!first_geometry_update_) 219 if (!first_geometry_update_)
233 geometry_ = new_geometry; 220 geometry_ = new_geometry;
234 #else // OS_WIN 221 #else // OS_WIN
235 geometry_ = new_geometry; 222 geometry_ = new_geometry;
236 #endif // OS_WIN 223 #endif // OS_WIN
237 first_geometry_update_ = false; 224 first_geometry_update_ = false;
238 } 225 }
239 226
240 void WebPluginImpl::updateFocus(bool focused, blink::WebFocusType focus_type) { 227 void WebPluginImpl::updateFocus(bool focused, blink::WebFocusType focus_type) {
241 if (accepts_input_events_) 228 delegate_->SetFocus(focused);
242 delegate_->SetFocus(focused);
243 } 229 }
244 230
245 void WebPluginImpl::updateVisibility(bool visible) { 231 void WebPluginImpl::updateVisibility(bool visible) {
246 if (!window_)
247 return;
248
249 WebPluginGeometry move;
250 move.window = window_;
251 move.window_rect = gfx::Rect();
252 move.clip_rect = gfx::Rect();
253 move.rects_valid = false;
254 move.visible = visible;
255
256 render_frame_->GetRenderWidget()->SchedulePluginMove(move);
257 } 232 }
258 233
259 bool WebPluginImpl::acceptsInputEvents() { 234 bool WebPluginImpl::acceptsInputEvents() {
260 return accepts_input_events_; 235 return true;
261 } 236 }
262 237
263 WebInputEventResult WebPluginImpl::handleInputEvent( 238 WebInputEventResult WebPluginImpl::handleInputEvent(
264 const WebInputEvent& event, 239 const WebInputEvent& event,
265 WebCursorInfo& cursor_info) { 240 WebCursorInfo& cursor_info) {
266 // Swallow context menu events in order to suppress the default context menu. 241 // Swallow context menu events in order to suppress the default context menu.
267 if (event.type == WebInputEvent::ContextMenu) 242 if (event.type == WebInputEvent::ContextMenu)
268 return WebInputEventResult::HandledSuppressed; 243 return WebInputEventResult::HandledSuppressed;
269 244
270 WebCursor::CursorInfo web_cursor_info; 245 WebCursor::CursorInfo web_cursor_info;
(...skipping 14 matching lines...) Expand all
285 } 260 }
286 261
287 // ----------------------------------------------------------------------------- 262 // -----------------------------------------------------------------------------
288 263
289 WebPluginImpl::WebPluginImpl( 264 WebPluginImpl::WebPluginImpl(
290 WebFrame* webframe, 265 WebFrame* webframe,
291 const WebPluginParams& params, 266 const WebPluginParams& params,
292 const base::FilePath& file_path, 267 const base::FilePath& file_path,
293 const base::WeakPtr<RenderViewImpl>& render_view, 268 const base::WeakPtr<RenderViewImpl>& render_view,
294 RenderFrameImpl* render_frame) 269 RenderFrameImpl* render_frame)
295 : windowless_(false), 270 : render_frame_(render_frame),
296 window_(gfx::kNullPluginWindow),
297 accepts_input_events_(false),
298 render_frame_(render_frame),
299 render_view_(render_view), 271 render_view_(render_view),
300 webframe_(webframe), 272 webframe_(webframe),
301 delegate_(NULL), 273 delegate_(NULL),
302 container_(NULL), 274 container_(NULL),
303 npp_(NULL), 275 npp_(NULL),
304 plugin_url_(params.url), 276 plugin_url_(params.url),
305 load_manually_(params.loadManually), 277 load_manually_(params.loadManually),
306 first_geometry_update_(true), 278 first_geometry_update_(true),
307 ignore_response_error_(false), 279 ignore_response_error_(false),
308 file_path_(file_path), 280 file_path_(file_path),
309 mime_type_(base::ToLowerASCII(base::UTF16ToASCII( 281 mime_type_(base::ToLowerASCII(base::UTF16ToASCII(
310 base::StringPiece16(params.mimeType)))) { 282 base::StringPiece16(params.mimeType)))) {
311 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); 283 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size());
312 284
313 for (size_t i = 0; i < params.attributeNames.size(); ++i) { 285 for (size_t i = 0; i < params.attributeNames.size(); ++i) {
314 arg_names_.push_back(params.attributeNames[i].utf8()); 286 arg_names_.push_back(params.attributeNames[i].utf8());
315 arg_values_.push_back(params.attributeValues[i].utf8()); 287 arg_values_.push_back(params.attributeValues[i].utf8());
316 } 288 }
317 289
318 // Set subresource URL for crash reporting. 290 // Set subresource URL for crash reporting.
319 base::debug::SetCrashKeyValue("subresource_url", plugin_url_.spec()); 291 base::debug::SetCrashKeyValue("subresource_url", plugin_url_.spec());
320 } 292 }
321 293
322 WebPluginImpl::~WebPluginImpl() { 294 WebPluginImpl::~WebPluginImpl() {
323 } 295 }
324 296
325 void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) {
326 if (window) {
327 DCHECK(!windowless_);
328 window_ = window;
329 #if defined(OS_MACOSX)
330 // TODO(kbr): remove. http://crbug.com/105344
331
332 // Lie to ourselves about being windowless even if we got a fake
333 // plugin window handle, so we continue to get input events.
334 windowless_ = true;
335 accepts_input_events_ = true;
336 // We do not really need to notify the page delegate that a plugin
337 // window was created -- so don't.
338 #else
339 accepts_input_events_ = false;
340
341 #endif // OS_MACOSX
342 } else {
343 DCHECK(!window_); // Make sure not called twice.
344 windowless_ = true;
345 accepts_input_events_ = true;
346 }
347 }
348
349 void WebPluginImpl::SetAcceptsInputEvents(bool accepts) {
350 accepts_input_events_ = accepts;
351 }
352
353 void WebPluginImpl::WillDestroyWindow(gfx::PluginWindowHandle window) {
354 DCHECK_EQ(window, window_);
355 window_ = gfx::kNullPluginWindow;
356 if (render_view_.get())
357 render_frame_->GetRenderWidget()->CleanupWindowInPluginMoves(window);
358 }
359
360 GURL WebPluginImpl::CompleteURL(const char* url) { 297 GURL WebPluginImpl::CompleteURL(const char* url) {
361 if (!webframe_) { 298 if (!webframe_) {
362 NOTREACHED(); 299 NOTREACHED();
363 return GURL(); 300 return GURL();
364 } 301 }
365 // TODO(darin): Is conversion from UTF8 correct here? 302 // TODO(darin): Is conversion from UTF8 correct here?
366 return webframe_->document().completeURL(WebString::fromUTF8(url)); 303 return webframe_->document().completeURL(WebString::fromUTF8(url));
367 } 304 }
368 305
369 bool WebPluginImpl::SetPostData(WebURLRequest* request, 306 bool WebPluginImpl::SetPostData(WebURLRequest* request,
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 case PLUGIN_SRC: 679 case PLUGIN_SRC:
743 webframe_->setReferrerForRequest(*request, plugin_url_); 680 webframe_->setReferrerForRequest(*request, plugin_url_);
744 break; 681 break;
745 682
746 default: 683 default:
747 break; 684 break;
748 } 685 }
749 } 686 }
750 687
751 } // namespace content 688 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/npapi/webplugin_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698