ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / extensions / renderer / guest_view / guest_view_container.cc
blob90e94c8e96f1e8ad586cb630203bef0d5ec59bc1
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/renderer/guest_view/guest_view_container.h"
7 #include "content/public/renderer/render_frame.h"
8 #include "content/public/renderer/render_frame_observer.h"
9 #include "content/public/renderer/render_view.h"
10 #include "extensions/common/guest_view/guest_view_constants.h"
11 #include "extensions/common/guest_view/guest_view_messages.h"
13 namespace extensions {
15 class GuestViewContainer::RenderFrameLifetimeObserver
16 : public content::RenderFrameObserver {
17 public:
18 RenderFrameLifetimeObserver(GuestViewContainer* container,
19 content::RenderFrame* render_frame);
21 // content::RenderFrameObserver overrides.
22 void OnDestruct() override;
24 private:
25 GuestViewContainer* container_;
27 DISALLOW_COPY_AND_ASSIGN(RenderFrameLifetimeObserver);
30 GuestViewContainer::RenderFrameLifetimeObserver::RenderFrameLifetimeObserver(
31 GuestViewContainer* container,
32 content::RenderFrame* render_frame)
33 : content::RenderFrameObserver(render_frame),
34 container_(container) {}
36 void GuestViewContainer::RenderFrameLifetimeObserver::OnDestruct() {
37 container_->RenderFrameDestroyed();
40 GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame)
41 : element_instance_id_(guestview::kInstanceIDNone),
42 render_frame_(render_frame) {
43 render_frame_lifetime_observer_.reset(
44 new RenderFrameLifetimeObserver(this, render_frame_));
47 GuestViewContainer::~GuestViewContainer() {}
49 // static.
50 bool GuestViewContainer::HandlesMessage(const IPC::Message& msg) {
51 switch (msg.type()) {
52 case GuestViewMsg_CreateMimeHandlerViewGuestACK::ID:
53 case GuestViewMsg_GuestAttached::ID:
54 case GuestViewMsg_GuestDetached::ID:
55 case GuestViewMsg_MimeHandlerViewGuestOnLoadCompleted::ID:
56 return true;
57 default:
58 return false;
62 void GuestViewContainer::RenderFrameDestroyed() {
63 OnRenderFrameDestroyed();
64 render_frame_ = nullptr;
67 void GuestViewContainer::SetElementInstanceID(int element_instance_id) {
68 DCHECK_EQ(element_instance_id_, guestview::kInstanceIDNone);
69 element_instance_id_ = element_instance_id;
72 } // namespace extensions