| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ | 5 #ifndef COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ |
| 6 #define COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ | 6 #define COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "components/plugins/renderer/webview_plugin.h" | 9 #include "components/plugins/renderer/webview_plugin.h" |
| 10 #include "content/public/renderer/render_frame_observer.h" | 10 #include "content/public/renderer/render_frame_observer.h" |
| 11 #include "gin/handle.h" |
| 11 #include "gin/wrappable.h" | 12 #include "gin/wrappable.h" |
| 13 #include "third_party/WebKit/public/web/WebKit.h" |
| 12 #include "third_party/WebKit/public/web/WebPluginParams.h" | 14 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| 13 | 15 |
| 14 namespace plugins { | 16 namespace plugins { |
| 15 | 17 |
| 16 class PluginPlaceholder : public content::RenderFrameObserver, | 18 class PluginPlaceholder : public content::RenderFrameObserver, |
| 17 public WebViewPlugin::Delegate, | 19 public WebViewPlugin::Delegate, |
| 18 public gin::Wrappable<PluginPlaceholder> { | 20 public gin::Wrappable<PluginPlaceholder> { |
| 19 public: | 21 public: |
| 20 static gin::WrapperInfo kWrapperInfo; | 22 static gin::WrapperInfo kWrapperInfo; |
| 21 | 23 |
| 22 WebViewPlugin* plugin() { return plugin_; } | |
| 23 | |
| 24 protected: | |
| 25 // |render_frame| and |frame| are weak pointers. If either one is going away, | 24 // |render_frame| and |frame| are weak pointers. If either one is going away, |
| 26 // our |plugin_| will be destroyed as well and will notify us. | 25 // our |plugin_| will be destroyed as well and will notify us. |
| 27 PluginPlaceholder(content::RenderFrame* render_frame, | 26 PluginPlaceholder(content::RenderFrame* render_frame, |
| 28 blink::WebLocalFrame* frame, | 27 blink::WebLocalFrame* frame, |
| 29 const blink::WebPluginParams& params, | 28 const blink::WebPluginParams& params, |
| 30 const std::string& html_data, | 29 const std::string& html_data); |
| 31 GURL placeholderDataUrl); | |
| 32 | 30 |
| 33 ~PluginPlaceholder() override; | 31 ~PluginPlaceholder() override; |
| 34 | 32 |
| 33 WebViewPlugin* plugin() { return plugin_; } |
| 34 |
| 35 protected: |
| 35 blink::WebLocalFrame* GetFrame(); | 36 blink::WebLocalFrame* GetFrame(); |
| 36 const blink::WebPluginParams& GetPluginParams() const; | 37 const blink::WebPluginParams& GetPluginParams() const; |
| 37 | 38 |
| 38 // WebViewPlugin::Delegate methods: | 39 // WebViewPlugin::Delegate methods: |
| 40 void BindWebFrame(blink::WebFrame* frame) override; |
| 39 void ShowContextMenu(const blink::WebMouseEvent&) override; | 41 void ShowContextMenu(const blink::WebMouseEvent&) override; |
| 40 void PluginDestroyed() override; | 42 void PluginDestroyed() override; |
| 43 |
| 41 v8::Local<v8::Object> GetV8ScriptableObject( | 44 v8::Local<v8::Object> GetV8ScriptableObject( |
| 42 v8::Isolate* isolate) const override; | 45 v8::Isolate* isolate) const override; |
| 43 | 46 |
| 47 // gin::Wrappable method: |
| 48 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 49 v8::Isolate* isolate) override; |
| 50 |
| 51 protected: |
| 52 // Hide this placeholder. |
| 53 void HidePlugin(); |
| 54 bool hidden() { return hidden_; } |
| 55 |
| 44 private: | 56 private: |
| 45 // RenderFrameObserver methods: | 57 // RenderFrameObserver methods: |
| 46 void OnDestruct() override; | 58 void OnDestruct() override; |
| 47 | 59 |
| 60 // JavaScript callbacks: |
| 61 void HideCallback(); |
| 62 |
| 48 blink::WebLocalFrame* frame_; | 63 blink::WebLocalFrame* frame_; |
| 49 blink::WebPluginParams plugin_params_; | 64 blink::WebPluginParams plugin_params_; |
| 50 WebViewPlugin* plugin_; | 65 WebViewPlugin* plugin_; |
| 51 | 66 |
| 67 bool hidden_; |
| 68 |
| 52 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder); | 69 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder); |
| 53 }; | 70 }; |
| 54 | 71 |
| 55 } // namespace plugins | 72 } // namespace plugins |
| 56 | 73 |
| 57 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ | 74 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ |
| OLD | NEW |