• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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.
4 
5 #ifndef CONTENT_RENDERER_PEPPER_PPEPPER_WEBPLUGIN_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PPEPPER_WEBPLUGIN_IMPL_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/sequenced_task_runner_helpers.h"
14 #include "ppapi/c/pp_var.h"
15 #include "third_party/WebKit/public/web/WebPlugin.h"
16 #include "ui/gfx/rect.h"
17 
18 struct _NPP;
19 
20 namespace blink {
21 struct WebPluginParams;
22 struct WebPrintParams;
23 }
24 
25 namespace content {
26 
27 class PepperPluginInstanceImpl;
28 class PluginModule;
29 class PPB_URLLoader_Impl;
30 class RenderFrame;
31 class RenderViewImpl;
32 
33 class PepperWebPluginImpl : public blink::WebPlugin {
34  public:
35   PepperWebPluginImpl(PluginModule* module,
36                       const blink::WebPluginParams& params,
37                       const base::WeakPtr<RenderViewImpl>& render_view,
38                       RenderFrame* render_frame);
39 
instance()40   PepperPluginInstanceImpl* instance() { return instance_.get(); }
41 
42   // blink::WebPlugin implementation.
43   virtual blink::WebPluginContainer* container() const;
44   virtual bool initialize(blink::WebPluginContainer* container);
45   virtual void destroy();
46   virtual NPObject* scriptableObject();
47   virtual struct _NPP* pluginNPP();
48   virtual bool getFormValue(blink::WebString& value);
49   virtual void paint(blink::WebCanvas* canvas, const blink::WebRect& rect);
50   virtual void updateGeometry(
51       const blink::WebRect& frame_rect,
52       const blink::WebRect& clip_rect,
53       const blink::WebVector<blink::WebRect>& cut_outs_rects,
54       bool is_visible);
55   virtual void updateFocus(bool focused);
56   virtual void updateVisibility(bool visible);
57   virtual bool acceptsInputEvents();
58   virtual bool handleInputEvent(const blink::WebInputEvent& event,
59                                 blink::WebCursorInfo& cursor_info);
60   virtual void didReceiveResponse(const blink::WebURLResponse& response);
61   virtual void didReceiveData(const char* data, int data_length);
62   virtual void didFinishLoading();
63   virtual void didFailLoading(const blink::WebURLError&);
64   virtual void didFinishLoadingFrameRequest(const blink::WebURL& url,
65                                             void* notify_data);
66   virtual void didFailLoadingFrameRequest(const blink::WebURL& url,
67                                           void* notify_data,
68                                           const blink::WebURLError& error);
69   virtual bool hasSelection() const;
70   virtual blink::WebString selectionAsText() const;
71   virtual blink::WebString selectionAsMarkup() const;
72   virtual blink::WebURL linkAtPosition(const blink::WebPoint& position) const;
73   virtual void setZoomLevel(double level, bool text_only);
74   virtual bool startFind(const blink::WebString& search_text,
75                          bool case_sensitive,
76                          int identifier);
77   virtual void selectFindResult(bool forward);
78   virtual void stopFind();
79   virtual bool supportsPaginatedPrint() OVERRIDE;
80   virtual bool isPrintScalingDisabled() OVERRIDE;
81 
82   virtual int printBegin(const blink::WebPrintParams& print_params) OVERRIDE;
83   virtual bool printPage(int page_number, blink::WebCanvas* canvas) OVERRIDE;
84   virtual void printEnd() OVERRIDE;
85 
86   virtual bool canRotateView() OVERRIDE;
87   virtual void rotateView(RotationType type) OVERRIDE;
88   virtual bool isPlaceholder() OVERRIDE;
89 
90  private:
91   friend class base::DeleteHelper<PepperWebPluginImpl>;
92 
93   virtual ~PepperWebPluginImpl();
94   struct InitData;
95 
96   scoped_ptr<InitData> init_data_;  // Cleared upon successful initialization.
97   // True if the instance represents the entire document in a frame instead of
98   // being an embedded resource.
99   bool full_frame_;
100   scoped_refptr<PepperPluginInstanceImpl> instance_;
101   gfx::Rect plugin_rect_;
102   PP_Var instance_object_;
103   blink::WebPluginContainer* container_;
104 
105   DISALLOW_COPY_AND_ASSIGN(PepperWebPluginImpl);
106 };
107 
108 }  // namespace content
109 
110 #endif  // CONTENT_RENDERER_PEPPER_PPEPPER_WEBPLUGIN_IMPL_H_
111