summaryrefslogtreecommitdiffstats
path: root/components/guest_view/renderer/guest_view_container_dispatcher.cc
blob: 23a5b51958a74f90c5591946400d157fbff25809 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/guest_view/renderer/guest_view_container_dispatcher.h"

#include "components/guest_view/common/guest_view_constants.h"
#include "components/guest_view/renderer/guest_view_container.h"
#include "ipc/ipc_message_macros.h"

namespace guest_view {

GuestViewContainerDispatcher::GuestViewContainerDispatcher() {
}

GuestViewContainerDispatcher::~GuestViewContainerDispatcher() {
}

bool GuestViewContainerDispatcher::HandlesMessage(const IPC::Message& message) {
  return IPC_MESSAGE_CLASS(message) == GuestViewMsgStart;
}

bool GuestViewContainerDispatcher::OnControlMessageReceived(
    const IPC::Message& message) {
  if (!HandlesMessage(message))
    return false;

  int element_instance_id = kInstanceIDNone;
  base::PickleIterator iter(message);
  bool success = iter.ReadInt(&element_instance_id);
  DCHECK(success);

  auto* container = GuestViewContainer::FromID(element_instance_id);
  if (!container)
    return false;

  return container->OnMessageReceived(message);
}

}  // namespace guest_view