a36ebc73465c50f4521d616bb4abd4e13f8cf392
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright 2016 Samsung Electronics. 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 EWK_EFL_INTEGRATION_RENDERER_PLUGINS_PLUGIN_PLACEHOLDER_HOLE_H_
6 #define EWK_EFL_INTEGRATION_RENDERER_PLUGINS_PLUGIN_PLACEHOLDER_HOLE_H_
7
8 #include <string>
9
10 #include "base/memory/weak_ptr.h"
11 #include "components/plugins/renderer/plugin_placeholder.h"
12
13 namespace cc_blink {
14 class WebLayerImpl;
15 }
16
17 class PluginPlaceholderHole : public plugins::PluginPlaceholderBase,
18                               public gin::Wrappable<PluginPlaceholderHole> {
19  public:
20   static gin::WrapperInfo kWrapperInfo;
21
22   static bool SupportsMimeType(blink::WebLocalFrame* frame,
23                                const std::string& mimetype);
24
25   static PluginPlaceholderHole* Create(content::RenderFrame* render_frame,
26                                        blink::WebLocalFrame* frame,
27                                        const blink::WebPluginParams& params);
28
29  private:
30   static void SetTransparentV8Impl(
31       const v8::FunctionCallbackInfo<v8::Value>& args);
32
33   PluginPlaceholderHole(content::RenderFrame* render_frame,
34                         blink::WebLocalFrame* frame,
35                         const blink::WebPluginParams& params);
36   ~PluginPlaceholderHole() override;
37
38   // WebViewPlugin::Delegate method.
39   void PluginDestroyed() override;
40   v8::Local<v8::Value> GetV8Handle(v8::Isolate*) override;
41   v8::Local<v8::Object> GetV8ScriptableObject(
42       v8::Isolate* isolate) const override;
43   void OnUnobscuredRectUpdate(const gfx::Rect& unobscured_rect) override;
44
45   // From v8 to c++.
46   void SetTransparentHelper(bool transparent);
47
48   // From c++ to v8.
49   void NotifyGeometryChanged();
50   void NotitfyAttributes() const;
51
52   scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
53   mutable v8::Persistent<v8::Object> v8_object_;
54   std::unique_ptr<cc_blink::WebLayerImpl> web_layer_;
55   gfx::Rect local_rect_;
56   gfx::Point local_position_in_root_frame_;
57
58   // Same life time.
59   blink::WebLocalFrame* main_frame_;
60
61   base::WeakPtrFactory<PluginPlaceholderHole> weak_factory_;
62
63   DISALLOW_COPY_AND_ASSIGN(PluginPlaceholderHole);
64 };
65
66 #endif  // EWK_EFL_INTEGRATION_RENDERER_PLUGINS_PLUGIN_PLACEHOLDER_HOLE_H_