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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 584713002: Browser Plugin: Remove dependency on NPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_content_window
Patch Set: Updated histograms.xml Created 6 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
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/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 WebContentsImpl* web_contents, 73 WebContentsImpl* web_contents,
74 BrowserPluginGuestDelegate* delegate) 74 BrowserPluginGuestDelegate* delegate)
75 : WebContentsObserver(web_contents), 75 : WebContentsObserver(web_contents),
76 embedder_web_contents_(NULL), 76 embedder_web_contents_(NULL),
77 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), 77 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone),
78 guest_device_scale_factor_(1.0f), 78 guest_device_scale_factor_(1.0f),
79 focused_(false), 79 focused_(false),
80 mouse_locked_(false), 80 mouse_locked_(false),
81 pending_lock_request_(false), 81 pending_lock_request_(false),
82 guest_visible_(false), 82 guest_visible_(false),
83 guest_opaque_(true),
84 embedder_visible_(true), 83 embedder_visible_(true),
85 copy_request_id_(0), 84 copy_request_id_(0),
86 has_render_view_(has_render_view), 85 has_render_view_(has_render_view),
87 is_in_destruction_(false), 86 is_in_destruction_(false),
88 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 87 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
89 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 88 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
90 last_can_compose_inline_(true), 89 last_can_compose_inline_(true),
91 delegate_(delegate), 90 delegate_(delegate),
92 weak_ptr_factory_(this) { 91 weak_ptr_factory_(this) {
93 DCHECK(web_contents); 92 DCHECK(web_contents);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition, 175 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition,
177 OnImeSetComposition) 176 OnImeSetComposition)
178 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) 177 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck)
179 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) 178 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed)
180 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, 179 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources,
181 OnReclaimCompositorResources) 180 OnReclaimCompositorResources)
182 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 181 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
183 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, 182 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
184 OnSetEditCommandsForNextKeyEvent) 183 OnSetEditCommandsForNextKeyEvent)
185 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) 184 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus)
186 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetContentsOpaque,
187 OnSetContentsOpaque)
188 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) 185 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility)
189 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck) 186 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck)
190 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) 187 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry)
191 IPC_MESSAGE_UNHANDLED(handled = false) 188 IPC_MESSAGE_UNHANDLED(handled = false)
192 IPC_END_MESSAGE_MAP() 189 IPC_END_MESSAGE_MAP()
193 return handled; 190 return handled;
194 } 191 }
195 192
196 void BrowserPluginGuest::Initialize( 193 void BrowserPluginGuest::Initialize(
197 int browser_plugin_instance_id, 194 int browser_plugin_instance_id,
198 const BrowserPluginHostMsg_Attach_Params& params, 195 const BrowserPluginHostMsg_Attach_Params& params,
199 WebContentsImpl* embedder_web_contents) { 196 WebContentsImpl* embedder_web_contents) {
200 browser_plugin_instance_id_ = browser_plugin_instance_id; 197 browser_plugin_instance_id_ = browser_plugin_instance_id;
201 focused_ = params.focused; 198 focused_ = params.focused;
202 guest_visible_ = params.visible; 199 guest_visible_ = params.visible;
203 guest_opaque_ = params.opaque;
204 guest_window_rect_ = gfx::Rect(params.origin, 200 guest_window_rect_ = gfx::Rect(params.origin,
205 params.resize_guest_params.view_size); 201 params.resize_guest_params.view_size);
206 202
207 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to 203 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to
208 // be attached. 204 // be attached.
209 embedder_web_contents_ = embedder_web_contents; 205 embedder_web_contents_ = embedder_web_contents;
210 206
211 WebContentsViewGuest* new_view = 207 WebContentsViewGuest* new_view =
212 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 208 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
213 new_view->OnGuestInitialized(embedder_web_contents->GetView()); 209 new_view->OnGuestInitialized(embedder_web_contents->GetView());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 guest_params.output_surface_id = output_surface_id; 360 guest_params.output_surface_id = output_surface_id;
365 guest_params.producing_route_id = host_routing_id; 361 guest_params.producing_route_id = host_routing_id;
366 guest_params.producing_host_id = host_process_id; 362 guest_params.producing_host_id = host_process_id;
367 guest_params.shared_memory_handle = software_frame_handle; 363 guest_params.shared_memory_handle = software_frame_handle;
368 364
369 SendMessageToEmbedder( 365 SendMessageToEmbedder(
370 new BrowserPluginMsg_CompositorFrameSwapped( 366 new BrowserPluginMsg_CompositorFrameSwapped(
371 browser_plugin_instance_id(), guest_params)); 367 browser_plugin_instance_id(), guest_params));
372 } 368 }
373 369
370 void BrowserPluginGuest::SetContentsOpaque(bool opaque) {
371 SendMessageToEmbedder(
372 new BrowserPluginMsg_SetContentsOpaque(
373 browser_plugin_instance_id(), opaque));
374 }
375
374 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { 376 WebContentsImpl* BrowserPluginGuest::GetWebContents() const {
375 return static_cast<WebContentsImpl*>(web_contents()); 377 return static_cast<WebContentsImpl*>(web_contents());
376 } 378 }
377 379
378 gfx::Point BrowserPluginGuest::GetScreenCoordinates( 380 gfx::Point BrowserPluginGuest::GetScreenCoordinates(
379 const gfx::Point& relative_position) const { 381 const gfx::Point& relative_position) const {
380 if (!attached()) 382 if (!attached())
381 return relative_position; 383 return relative_position;
382 384
383 gfx::Point screen_pos(relative_position); 385 gfx::Point screen_pos(relative_position);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); 436 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate"));
435 } 437 }
436 438
437 void BrowserPluginGuest::RenderViewReady() { 439 void BrowserPluginGuest::RenderViewReady() {
438 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); 440 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost();
439 // TODO(fsamuel): Investigate whether it's possible to update state earlier 441 // TODO(fsamuel): Investigate whether it's possible to update state earlier
440 // here (see http://crbug.com/158151). 442 // here (see http://crbug.com/158151).
441 Send(new InputMsg_SetFocus(routing_id(), focused_)); 443 Send(new InputMsg_SetFocus(routing_id(), focused_));
442 UpdateVisibility(); 444 UpdateVisibility();
443 445
444 OnSetContentsOpaque(browser_plugin_instance_id(), guest_opaque_);
445
446 RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms( 446 RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms(
447 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)); 447 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs));
448 } 448 }
449 449
450 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) { 450 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) {
451 SendMessageToEmbedder( 451 SendMessageToEmbedder(
452 new BrowserPluginMsg_GuestGone(browser_plugin_instance_id())); 452 new BrowserPluginMsg_GuestGone(browser_plugin_instance_id()));
453 switch (status) { 453 switch (status) {
454 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: 454 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED:
455 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Killed")); 455 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Killed"));
(...skipping 21 matching lines...) Expand all
477 case BrowserPluginHostMsg_ExtendSelectionAndDelete::ID: 477 case BrowserPluginHostMsg_ExtendSelectionAndDelete::ID:
478 case BrowserPluginHostMsg_HandleInputEvent::ID: 478 case BrowserPluginHostMsg_HandleInputEvent::ID:
479 case BrowserPluginHostMsg_ImeConfirmComposition::ID: 479 case BrowserPluginHostMsg_ImeConfirmComposition::ID:
480 case BrowserPluginHostMsg_ImeSetComposition::ID: 480 case BrowserPluginHostMsg_ImeSetComposition::ID:
481 case BrowserPluginHostMsg_LockMouse_ACK::ID: 481 case BrowserPluginHostMsg_LockMouse_ACK::ID:
482 case BrowserPluginHostMsg_PluginDestroyed::ID: 482 case BrowserPluginHostMsg_PluginDestroyed::ID:
483 case BrowserPluginHostMsg_ReclaimCompositorResources::ID: 483 case BrowserPluginHostMsg_ReclaimCompositorResources::ID:
484 case BrowserPluginHostMsg_ResizeGuest::ID: 484 case BrowserPluginHostMsg_ResizeGuest::ID:
485 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID: 485 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID:
486 case BrowserPluginHostMsg_SetFocus::ID: 486 case BrowserPluginHostMsg_SetFocus::ID:
487 case BrowserPluginHostMsg_SetContentsOpaque::ID:
488 case BrowserPluginHostMsg_SetVisibility::ID: 487 case BrowserPluginHostMsg_SetVisibility::ID:
489 case BrowserPluginHostMsg_UnlockMouse_ACK::ID: 488 case BrowserPluginHostMsg_UnlockMouse_ACK::ID:
490 case BrowserPluginHostMsg_UpdateGeometry::ID: 489 case BrowserPluginHostMsg_UpdateGeometry::ID:
491 return true; 490 return true;
492 default: 491 default:
493 return false; 492 return false;
494 } 493 }
495 } 494 }
496 495
497 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { 496 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 SetFocus(rwh, focused); 722 SetFocus(rwh, focused);
724 } 723 }
725 724
726 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( 725 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent(
727 int browser_plugin_instance_id, 726 int browser_plugin_instance_id,
728 const std::vector<EditCommand>& edit_commands) { 727 const std::vector<EditCommand>& edit_commands) {
729 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), 728 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(),
730 edit_commands)); 729 edit_commands));
731 } 730 }
732 731
733 void BrowserPluginGuest::OnSetContentsOpaque(int browser_plugin_instance_id,
734 bool opaque) {
735 guest_opaque_ = opaque;
736 Send(new ViewMsg_SetBackgroundOpaque(routing_id(), guest_opaque_));
737 }
738
739 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, 732 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id,
740 bool visible) { 733 bool visible) {
741 guest_visible_ = visible; 734 guest_visible_ = visible;
742 if (embedder_visible_ && guest_visible_) 735 if (embedder_visible_ && guest_visible_)
743 GetWebContents()->WasShown(); 736 GetWebContents()->WasShown();
744 else 737 else
745 GetWebContents()->WasHidden(); 738 GetWebContents()->WasHidden();
746 } 739 }
747 740
748 void BrowserPluginGuest::OnUnlockMouse() { 741 void BrowserPluginGuest::OnUnlockMouse() {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 void BrowserPluginGuest::OnImeCompositionRangeChanged( 829 void BrowserPluginGuest::OnImeCompositionRangeChanged(
837 const gfx::Range& range, 830 const gfx::Range& range,
838 const std::vector<gfx::Rect>& character_bounds) { 831 const std::vector<gfx::Rect>& character_bounds) {
839 static_cast<RenderWidgetHostViewBase*>( 832 static_cast<RenderWidgetHostViewBase*>(
840 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 833 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
841 range, character_bounds); 834 range, character_bounds);
842 } 835 }
843 #endif 836 #endif
844 837
845 } // namespace content 838 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/frame_host/render_widget_host_view_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698