summaryrefslogtreecommitdiffstats
path: root/content/renderer/render_view_pepper_helper.h
blob: 3449ccc9ec8b596c66faf5f58e11a6b80196223d (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// 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.

// This interface is used by RenderView to talk to the pepper plugin delegate.
#ifndef CONTENT_RENDERER_RENDER_VIEW_PEPPER_HELPER_H
#define CONTENT_RENDERER_RENDER_VIEW_PEPPER_HELPER_H

#include <string>
#include <vector>

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/platform_file.h"
#include "base/process.h"
#include "ui/base/ime/text_input_type.h"

class TransportDIB;

namespace gfx {
class Rect;
}

namespace IPC {
struct ChannelHandle;
}

namespace ui {
class Range;
}

namespace webkit {
struct WebPluginInfo;
namespace ppapi {
class PluginInstance;
}
}

namespace WebKit {
struct WebCompositionUnderline;
struct WebPluginParams;
class WebPlugin;
}

namespace content {

class RenderViewPepperHelper {
 public:
  RenderViewPepperHelper() {}
  virtual ~RenderViewPepperHelper();

  virtual WebKit::WebPlugin* CreatePepperWebPlugin(
      const webkit::WebPluginInfo& webplugin_info,
      const WebKit::WebPluginParams& params);

  // Called by RenderView to implement the corresponding function in its base
  // class RenderWidget (see that for more).
  virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
      const gfx::Rect& paint_bounds,
      TransportDIB** dib,
      gfx::Rect* location,
      gfx::Rect* clip,
      float* scale_factor);

  // Called by RenderView to tell us about painting events, these two functions
  // just correspond to the WillInitiatePaint, DidInitiatePaint and
  // DidFlushPaint hooks in RenderView.
  virtual void ViewWillInitiatePaint() {}
  virtual void ViewInitiatedPaint() {}
  virtual void ViewFlushedPaint() {}

  // Called by RenderView when ViewMsg_AsyncOpenFile_ACK.
  virtual void OnAsyncFileOpened(base::PlatformFileError error_code,
                                 base::PlatformFile file,
                                 int message_id) {}

  // Called by RenderView when ViewMsg_PpapiBrokerChannelCreated.
  virtual void OnPpapiBrokerChannelCreated(int request_id,
                                           base::ProcessId broker_pid,
                                           const IPC::ChannelHandle& handle) {}

  // Called when we know whether permission to access the PPAPI broker was
  // granted.
  virtual void OnPpapiBrokerPermissionResult(int request_id, bool result) {}

  // Notification that the render view has been focused or defocused. This
  // notifies all of the plugins.
  virtual void OnSetFocus(bool has_focus) {}

  // Notification that the page visibility has changed. The default is visible.
  virtual void PageVisibilityChanged(bool is_visible) {}

  // IME status.
  virtual bool IsPluginFocused() const;
  virtual gfx::Rect GetCaretBounds() const;
  virtual ui::TextInputType GetTextInputType() const;
  virtual bool IsPluginAcceptingCompositionEvents() const;
  virtual bool CanComposeInline() const;
  virtual void GetSurroundingText(string16* text, ui::Range* range) const {}

  // IME events.
  virtual void OnImeSetComposition(
      const string16& text,
      const std::vector<WebKit::WebCompositionUnderline>& underlines,
      int selection_start,
      int selection_end) {}
  virtual void OnImeConfirmComposition(const string16& text) {}

  // Notification that a mouse event has arrived at the render view.
  virtual void WillHandleMouseEvent() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(RenderViewPepperHelper);
};

}  // namespace content

#endif  // CONTENT_RENDERER_RENDER_VIEW_PEPPER_HELPER_H