summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_plugin/browser_plugin_guest_helper.cc
blob: b1de4d9a2ca9378c4d22eea87bed93ec3c5e2c3d (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) 2012 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 "content/browser/browser_plugin/browser_plugin_guest_helper.h"

#include "content/browser/browser_plugin/browser_plugin_guest.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/drag_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/render_view_host.h"

namespace content {

BrowserPluginGuestHelper::BrowserPluginGuestHelper(
    BrowserPluginGuest* guest,
    RenderViewHost* render_view_host)
    : RenderViewHostObserver(render_view_host),
      guest_(guest) {
}

BrowserPluginGuestHelper::~BrowserPluginGuestHelper() {
}

bool BrowserPluginGuestHelper::OnMessageReceived(
    const IPC::Message& message) {
  bool handled = true;
  IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuestHelper, message)
    IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
    IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
    IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnHandleInputEventAck)
    IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
    IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
    IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers,
                        OnMsgHasTouchEventHandlers)
    IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
    IPC_MESSAGE_UNHANDLED(handled = false)
  IPC_END_MESSAGE_MAP()
  return handled;
}

void BrowserPluginGuestHelper::OnUpdateDragCursor(
    WebKit::WebDragOperation current_op) {
  guest_->UpdateDragCursor(current_op);
}

void BrowserPluginGuestHelper::OnUpdateRect(
    const ViewHostMsg_UpdateRect_Params& params) {
  guest_->UpdateRect(render_view_host(), params);
}

void BrowserPluginGuestHelper::OnHandleInputEventAck(
    WebKit::WebInputEvent::Type event_type,
    bool processed) {
  guest_->HandleInputEventAck(render_view_host(), processed);
}

void BrowserPluginGuestHelper::OnTakeFocus(bool reverse) {
  guest_->ViewTakeFocus(reverse);
}

void BrowserPluginGuestHelper::OnShowWidget(int route_id,
                                            const gfx::Rect& initial_pos) {
  guest_->ShowWidget(render_view_host(), route_id, initial_pos);
}

void BrowserPluginGuestHelper::OnMsgHasTouchEventHandlers(bool has_handlers) {
  guest_->SetIsAcceptingTouchEvents(has_handlers);
}

void BrowserPluginGuestHelper::OnSetCursor(const WebCursor& cursor) {
  guest_->SetCursor(cursor);
}

}  // namespace content