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_impl.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 bool BrowserPluginGuestImpl::OnMessageReceivedFromEmbedder( | 116 bool BrowserPluginGuestImpl::OnMessageReceivedFromEmbedder( |
117 const IPC::Message& message) { | 117 const IPC::Message& message) { |
118 bool handled = true; | 118 bool handled = true; |
119 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuestImpl, message) | 119 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuestImpl, message) |
120 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, | 120 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, |
121 OnSwapBuffersACK) | 121 OnSwapBuffersACK) |
122 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, | 122 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, |
123 OnDragStatusUpdate) | 123 OnDragStatusUpdate) |
124 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ForwardMessage, | 124 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ForwardMessage, |
125 OnForwardMessage) | 125 OnForwardMessage) |
126 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Go, OnGo) | |
127 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, | 126 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, |
128 OnHandleInputEvent) | 127 OnHandleInputEvent) |
129 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, OnNavigateGuest) | 128 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, OnNavigateGuest) |
130 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) | 129 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) |
131 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) | 130 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) |
132 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) | 131 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) |
133 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_RespondPermission, | 132 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_RespondPermission, |
134 OnRespondPermission) | 133 OnRespondPermission) |
135 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize) | 134 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize) |
136 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) | 135 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 instance_id_, guest_routing_id)); | 174 instance_id_, guest_routing_id)); |
176 | 175 |
177 if (!params.src.empty()) | 176 if (!params.src.empty()) |
178 OnNavigateGuest(instance_id_, params.src); | 177 OnNavigateGuest(instance_id_, params.src); |
179 | 178 |
180 embedder_web_contents_->GetBrowserPluginEmbedder()->AddGuest(instance_id_, | 179 embedder_web_contents_->GetBrowserPluginEmbedder()->AddGuest(instance_id_, |
181 web_contents()); | 180 web_contents()); |
182 | 181 |
183 GetContentClient()->browser()->GuestWebContentsCreated( | 182 GetContentClient()->browser()->GuestWebContentsCreated( |
184 web_contents(), embedder_web_contents_); | 183 web_contents(), embedder_web_contents_); |
| 184 |
| 185 GetContentClient()->browser()->BrowserPluginGuestCreated(this); |
185 } | 186 } |
186 | 187 |
187 BrowserPluginGuestImpl::~BrowserPluginGuestImpl() { | 188 BrowserPluginGuestImpl::~BrowserPluginGuestImpl() { |
188 FOR_EACH_OBSERVER(BrowserPluginGuestObserver, observers_, | 189 FOR_EACH_OBSERVER(BrowserPluginGuestObserver, observers_, |
189 BrowserPluginGuestGone()); | 190 BrowserPluginGuestGone()); |
190 FOR_EACH_OBSERVER(BrowserPluginGuestObserver, observers_, OnDestruct()); | 191 FOR_EACH_OBSERVER(BrowserPluginGuestObserver, observers_, OnDestruct()); |
191 } | 192 } |
192 | 193 |
193 // static | 194 // static |
194 BrowserPluginGuestImpl* BrowserPluginGuestImpl::Create( | 195 BrowserPluginGuestImpl* BrowserPluginGuestImpl::Create( |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 if (!observers_.might_have_observers()) | 564 if (!observers_.might_have_observers()) |
564 return; | 565 return; |
565 ObserverListBase<BrowserPluginGuestObserver>::Iterator it(observers_); | 566 ObserverListBase<BrowserPluginGuestObserver>::Iterator it(observers_); |
566 BrowserPluginGuestObserver* observer; | 567 BrowserPluginGuestObserver* observer; |
567 while ((observer = it.GetNext()) != NULL) { | 568 while ((observer = it.GetNext()) != NULL) { |
568 if (observer->OnMessageReceivedFromEmbedder(msg)) | 569 if (observer->OnMessageReceivedFromEmbedder(msg)) |
569 return; | 570 return; |
570 } | 571 } |
571 } | 572 } |
572 | 573 |
573 void BrowserPluginGuestImpl::OnGo(int instance_id, int relative_index) { | |
574 web_contents()->GetController().GoToOffset(relative_index); | |
575 } | |
576 | |
577 void BrowserPluginGuestImpl::OnHandleInputEvent( | 574 void BrowserPluginGuestImpl::OnHandleInputEvent( |
578 int instance_id, | 575 int instance_id, |
579 const gfx::Rect& guest_window_rect, | 576 const gfx::Rect& guest_window_rect, |
580 const WebKit::WebInputEvent* event) { | 577 const WebKit::WebInputEvent* event) { |
581 guest_window_rect_ = guest_window_rect; | 578 guest_window_rect_ = guest_window_rect; |
582 guest_screen_rect_ = guest_window_rect; | 579 guest_screen_rect_ = guest_window_rect; |
583 guest_screen_rect_.Offset( | 580 guest_screen_rect_.Offset( |
584 embedder_web_contents_->GetRenderViewHost()->GetView()-> | 581 embedder_web_contents_->GetRenderViewHost()->GetView()-> |
585 GetViewBounds().OffsetFromOrigin()); | 582 GetViewBounds().OffsetFromOrigin()); |
586 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 583 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 relay_params.bitmap_rect = params.bitmap_rect; | 952 relay_params.bitmap_rect = params.bitmap_rect; |
956 relay_params.scroll_delta = params.scroll_delta; | 953 relay_params.scroll_delta = params.scroll_delta; |
957 relay_params.scroll_rect = params.scroll_rect; | 954 relay_params.scroll_rect = params.scroll_rect; |
958 relay_params.copy_rects = params.copy_rects; | 955 relay_params.copy_rects = params.copy_rects; |
959 | 956 |
960 SendMessageToEmbedderInternal( | 957 SendMessageToEmbedderInternal( |
961 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); | 958 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); |
962 } | 959 } |
963 | 960 |
964 } // namespace content | 961 } // namespace content |
OLD | NEW |