OLD | NEW |
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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 10 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 const IPC::Message& message) { | 66 const IPC::Message& message) { |
67 bool handled = true; | 67 bool handled = true; |
68 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) | 68 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
69 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, | 69 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, |
70 OnDragStatusUpdate) | 70 OnDragStatusUpdate) |
71 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Go, OnGo) | 71 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Go, OnGo) |
72 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, | 72 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, |
73 OnHandleInputEvent) | 73 OnHandleInputEvent) |
74 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) | 74 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) |
75 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) | 75 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) |
| 76 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) |
76 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize) | 77 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize) |
77 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) | |
78 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) | 78 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) |
79 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Stop, OnStop) | 79 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Stop, OnStop) |
80 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_TerminateGuest, OnTerminateGuest) | 80 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_TerminateGuest, OnTerminateGuest) |
81 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK) | 81 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK) |
82 IPC_MESSAGE_UNHANDLED(handled = false) | 82 IPC_MESSAGE_UNHANDLED(handled = false) |
83 IPC_END_MESSAGE_MAP() | 83 IPC_END_MESSAGE_MAP() |
84 return handled; | 84 return handled; |
85 } | 85 } |
86 | 86 |
87 void BrowserPluginGuest::Initialize( | 87 void BrowserPluginGuest::Initialize( |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 if (!base::SharedMemory::IsHandleValid(params.damage_buffer_handle)) { | 452 if (!base::SharedMemory::IsHandleValid(params.damage_buffer_handle)) { |
453 // Invalid damage buffer, so just resize the WebContents. | 453 // Invalid damage buffer, so just resize the WebContents. |
454 if (!params.view_size.IsEmpty()) | 454 if (!params.view_size.IsEmpty()) |
455 web_contents()->GetView()->SizeContents(params.view_size); | 455 web_contents()->GetView()->SizeContents(params.view_size); |
456 return; | 456 return; |
457 } | 457 } |
458 SetDamageBuffer(params); | 458 SetDamageBuffer(params); |
459 web_contents()->GetView()->SizeContents(params.view_size); | 459 web_contents()->GetView()->SizeContents(params.view_size); |
460 } | 460 } |
461 | 461 |
| 462 void BrowserPluginGuest::OnSetFocus(int instance_id, bool focused) { |
| 463 if (focused_ == focused) |
| 464 return; |
| 465 focused_ = focused; |
| 466 Send(new ViewMsg_SetFocus(routing_id(), focused)); |
| 467 } |
| 468 |
462 void BrowserPluginGuest::OnSetSize( | 469 void BrowserPluginGuest::OnSetSize( |
463 int instance_id, | 470 int instance_id, |
464 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, | 471 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, |
465 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params) { | 472 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params) { |
466 bool old_auto_size_enabled = auto_size_enabled_; | 473 bool old_auto_size_enabled = auto_size_enabled_; |
467 gfx::Size old_max_size = max_auto_size_; | 474 gfx::Size old_max_size = max_auto_size_; |
468 gfx::Size old_min_size = min_auto_size_; | 475 gfx::Size old_min_size = min_auto_size_; |
469 auto_size_enabled_ = auto_size_params.enable; | 476 auto_size_enabled_ = auto_size_params.enable; |
470 max_auto_size_ = auto_size_params.max_size; | 477 max_auto_size_ = auto_size_params.max_size; |
471 min_auto_size_ = auto_size_params.min_size; | 478 min_auto_size_ = auto_size_params.min_size; |
(...skipping 12 matching lines...) Expand all Loading... |
484 web_contents()->GetRenderViewHost()->Send(new ViewMsg_Repaint( | 491 web_contents()->GetRenderViewHost()->Send(new ViewMsg_Repaint( |
485 web_contents()->GetRenderViewHost()->GetRoutingID(), | 492 web_contents()->GetRenderViewHost()->GetRoutingID(), |
486 max_auto_size_)); | 493 max_auto_size_)); |
487 } else if (!auto_size_enabled_ && old_auto_size_enabled) { | 494 } else if (!auto_size_enabled_ && old_auto_size_enabled) { |
488 web_contents()->GetRenderViewHost()->DisableAutoResize( | 495 web_contents()->GetRenderViewHost()->DisableAutoResize( |
489 resize_guest_params.view_size); | 496 resize_guest_params.view_size); |
490 } | 497 } |
491 OnResizeGuest(instance_id_, resize_guest_params); | 498 OnResizeGuest(instance_id_, resize_guest_params); |
492 } | 499 } |
493 | 500 |
494 void BrowserPluginGuest::OnSetFocus(int instance_id, bool focused) { | |
495 if (focused_ == focused) | |
496 return; | |
497 focused_ = focused; | |
498 Send(new ViewMsg_SetFocus(routing_id(), focused)); | |
499 } | |
500 | |
501 void BrowserPluginGuest::OnSetVisibility(int instance_id, bool visible) { | 501 void BrowserPluginGuest::OnSetVisibility(int instance_id, bool visible) { |
502 visible_ = visible; | 502 visible_ = visible; |
503 BrowserPluginEmbedder* embedder = | 503 BrowserPluginEmbedder* embedder = |
504 embedder_web_contents_->GetBrowserPluginEmbedder(); | 504 embedder_web_contents_->GetBrowserPluginEmbedder(); |
505 if (embedder->visible() && visible) | 505 if (embedder->visible() && visible) |
506 web_contents()->WasShown(); | 506 web_contents()->WasShown(); |
507 else | 507 else |
508 web_contents()->WasHidden(); | 508 web_contents()->WasHidden(); |
509 } | 509 } |
510 | 510 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 relay_params.scroll_delta = params.scroll_delta; | 660 relay_params.scroll_delta = params.scroll_delta; |
661 relay_params.scroll_rect = params.scroll_rect; | 661 relay_params.scroll_rect = params.scroll_rect; |
662 relay_params.copy_rects = params.copy_rects; | 662 relay_params.copy_rects = params.copy_rects; |
663 | 663 |
664 SendMessageToEmbedder(new BrowserPluginMsg_UpdateRect(embedder_routing_id(), | 664 SendMessageToEmbedder(new BrowserPluginMsg_UpdateRect(embedder_routing_id(), |
665 instance_id(), | 665 instance_id(), |
666 relay_params)); | 666 relay_params)); |
667 } | 667 } |
668 | 668 |
669 } // namespace content | 669 } // namespace content |
OLD | NEW |