summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/pepper_widget.h
blob: 1cc84f6c9096390b522a4adbc8793526b00393a6 (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
// Copyright (c) 2010 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.

#ifndef CHROME_RENDERER_PEPPER_WIDGET_H_
#define CHROME_RENDERER_PEPPER_WIDGET_H_

#include "base/basictypes.h"
#include "third_party/npapi/bindings/npapi_extensions.h"

class Graphics2DDeviceContext;

// Every class that implements a Pepper widget derives from this.
class PepperWidget {
 public:
  static NPWidgetExtensions* GetWidgetExtensions();

  PepperWidget();
  void Init(NPP instance, int id);

  // Called as a result of the corresponding Pepper functions.
  virtual void Destroy() = 0;
  virtual void Paint(Graphics2DDeviceContext* context, const NPRect& dirty) = 0;
  virtual bool HandleEvent(const NPPepperEvent& event) = 0;
  virtual void GetProperty(NPWidgetProperty property, void* value) = 0;
  virtual void SetProperty(NPWidgetProperty property, void* value) = 0;

 protected:
  ~PepperWidget();

  // Tells the plugin that a property changed.
  void WidgetPropertyChanged(NPWidgetProperty property);

 private:
  NPP instance_;
  int id_;

  DISALLOW_COPY_AND_ASSIGN(PepperWidget);
};

#endif  // CHROME_RENDERER_PEPPER_WIDGET_H_