Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / pepper / pepper_webplugin_impl.h
blob31688a621537d08f01edd279ad44465c8150c029
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.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_WEBPLUGIN_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_WEBPLUGIN_IMPL_H_
8 #include <string>
9 #include <vector>
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/geometry/rect.h"
18 struct _NPP;
20 namespace blink {
21 struct WebPluginParams;
22 struct WebPrintParams;
25 namespace content {
27 class PepperPluginInstanceImpl;
28 class PluginInstanceThrottlerImpl;
29 class PluginModule;
30 class PPB_URLLoader_Impl;
31 class RenderFrameImpl;
33 class PepperWebPluginImpl : public blink::WebPlugin {
34 public:
35 PepperWebPluginImpl(PluginModule* module,
36 const blink::WebPluginParams& params,
37 RenderFrameImpl* render_frame,
38 scoped_ptr<PluginInstanceThrottlerImpl> throttler);
40 PepperPluginInstanceImpl* instance() { return instance_.get(); }
42 // blink::WebPlugin implementation.
43 virtual blink::WebPluginContainer* container() const;
44 virtual bool initialize(blink::WebPluginContainer* container);
45 virtual void destroy();
46 virtual v8::Local<v8::Object> v8ScriptableObject(
47 v8::Isolate* isolate) override;
48 virtual bool getFormValue(blink::WebString& value);
49 virtual void layoutIfNeeded() override { }
50 virtual void paint(blink::WebCanvas* canvas, const blink::WebRect& rect);
51 virtual void updateGeometry(
52 const blink::WebRect& window_rect,
53 const blink::WebRect& clip_rect,
54 const blink::WebRect& unobscured_rect,
55 const blink::WebVector<blink::WebRect>& cut_outs_rects,
56 bool is_visible);
57 virtual void updateFocus(bool focused, blink::WebFocusType focus_type);
58 virtual void updateVisibility(bool visible);
59 virtual bool acceptsInputEvents();
60 virtual bool handleInputEvent(const blink::WebInputEvent& event,
61 blink::WebCursorInfo& cursor_info);
62 virtual void didReceiveResponse(const blink::WebURLResponse& response);
63 virtual void didReceiveData(const char* data, int data_length);
64 virtual void didFinishLoading();
65 virtual void didFailLoading(const blink::WebURLError&);
66 virtual void didFinishLoadingFrameRequest(const blink::WebURL& url,
67 void* notify_data);
68 virtual void didFailLoadingFrameRequest(const blink::WebURL& url,
69 void* notify_data,
70 const blink::WebURLError& error);
71 virtual bool hasSelection() const;
72 virtual blink::WebString selectionAsText() const;
73 virtual blink::WebString selectionAsMarkup() const;
74 virtual blink::WebURL linkAtPosition(const blink::WebPoint& position) const;
75 virtual bool getPrintPresetOptionsFromDocument(
76 blink::WebPrintPresetOptions* preset_options);
77 virtual bool startFind(const blink::WebString& search_text,
78 bool case_sensitive,
79 int identifier);
80 virtual void selectFindResult(bool forward);
81 virtual void stopFind();
82 virtual bool supportsPaginatedPrint() override;
83 virtual bool isPrintScalingDisabled() override;
85 virtual int printBegin(const blink::WebPrintParams& print_params) override;
86 void printPage(int page_number, blink::WebCanvas* canvas) override;
87 virtual void printEnd() override;
89 virtual bool canRotateView() override;
90 virtual void rotateView(RotationType type) override;
91 virtual bool isPlaceholder() override;
93 private:
94 friend class base::DeleteHelper<PepperWebPluginImpl>;
96 virtual ~PepperWebPluginImpl();
97 struct InitData;
99 scoped_ptr<InitData> init_data_; // Cleared upon successful initialization.
100 // True if the instance represents the entire document in a frame instead of
101 // being an embedded resource.
102 bool full_frame_;
103 scoped_ptr<PluginInstanceThrottlerImpl> throttler_;
104 scoped_refptr<PepperPluginInstanceImpl> instance_;
105 gfx::Rect plugin_rect_;
106 PP_Var instance_object_;
107 blink::WebPluginContainer* container_;
108 base::WeakPtrFactory<PepperWebPluginImpl> weak_factory_;
110 DISALLOW_COPY_AND_ASSIGN(PepperWebPluginImpl);
113 } // namespace content
115 #endif // CONTENT_RENDERER_PEPPER_PEPPER_WEBPLUGIN_IMPL_H_