OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/framelet/renderer/framelet_container.h" | 5 #include "components/framelet/renderer/framelet_container.h" |
6 | 6 |
| 7 #include "components/framelet/common/framelet_messages.h" |
| 8 #include "components/guest_view/common/guest_view_constants.h" |
| 9 #include "components/guest_view/common/guest_view_messages.h" |
| 10 #include "content/public/renderer/render_frame.h" |
| 11 #include "content/public/renderer/render_view.h" |
| 12 #include "third_party/WebKit/public/web/WebDocument.h" |
| 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 14 |
7 namespace guest_view { | 15 namespace guest_view { |
8 | 16 |
9 FrameletContainer::FrameletContainer(content::RenderFrame* render_frame) | 17 FrameletContainer::FrameletContainer(content::RenderFrame* render_frame) |
10 : GuestViewContainer(render_frame) {} | 18 : GuestViewContainer(render_frame), |
| 19 guest_proxy_routing_id_(-1) { |
| 20 is_embedded_ = !render_frame->GetWebFrame()->document().isPluginDocument(); |
| 21 } |
| 22 |
| 23 bool FrameletContainer::OnMessage(const IPC::Message& message) { |
| 24 bool handled = true; |
| 25 IPC_BEGIN_MESSAGE_MAP(FrameletContainer, message); |
| 26 IPC_MESSAGE_HANDLER(FrameletGuestViewMsg_CreateFrameletGuestACK, |
| 27 OnCreateFrameletGuestACK); |
| 28 IPC_MESSAGE_HANDLER(GuestViewMsg_GuestAttached, |
| 29 OnGuestAttached); |
| 30 IPC_MESSAGE_UNHANDLED(handled = false); |
| 31 IPC_END_MESSAGE_MAP(); |
| 32 return handled; |
| 33 } |
| 34 |
| 35 void FrameletContainer::OnCreateFrameletGuestACK(int element_instance_id) { |
| 36 DCHECK_NE(this->element_instance_id(), guest_view::kInstanceIDNone); |
| 37 DCHECK_EQ(this->element_instance_id(), element_instance_id); |
| 38 |
| 39 if (!render_frame()) |
| 40 return; |
| 41 |
| 42 render_frame()->AttachGuest(element_instance_id); |
| 43 } |
| 44 |
| 45 void FrameletContainer::OnGuestAttached(int /* unused */, |
| 46 int guest_proxy_routing_id) { |
| 47 guest_proxy_routing_id_ = guest_proxy_routing_id; |
| 48 } |
| 49 |
| 50 void FrameletContainer::DidResizeElement(const gfx::Size& new_size) { |
| 51 element_size_ = new_size; |
| 52 // TODO(wjmaclean): MimeHandlerViewGuest sends a message to the viewhost to |
| 53 // notify when the size has changed. Should we? |
| 54 } |
| 55 |
| 56 void FrameletContainer::DidFinishLoading() { |
| 57 DCHECK(!is_embedded_); |
| 58 CreateFrameletGuest(); |
| 59 } |
| 60 |
| 61 void FrameletContainer::CreateFrameletGuest() { |
| 62 // TODO(wjmaclean): figure out how to get url_ and element_size_. |
| 63 DCHECK_NE(element_instance_id(), guest_view::kInstanceIDNone); |
| 64 |
| 65 if (!render_frame()) |
| 66 return; |
| 67 |
| 68 render_frame()->Send(new FrameletGuestViewHostMsg_CreateFrameletGuest( |
| 69 render_frame()->GetRoutingID(), url_, |
| 70 element_instance_id(), element_size_)); |
| 71 } |
11 | 72 |
12 } // namespace guest_view | 73 } // namespace guest_view |
OLD | NEW |