Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: components/plugins/renderer/plugin_placeholder.h

Issue 2855123003: Remove rendundant WebLocalFrame parameter in various plugin code. (Closed)
Patch Set: Fix Android Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "components/plugins/renderer/webview_plugin.h" 10 #include "components/plugins/renderer/webview_plugin.h"
11 #include "content/public/renderer/render_frame_observer.h" 11 #include "content/public/renderer/render_frame_observer.h"
12 #include "gin/handle.h" 12 #include "gin/handle.h"
13 #include "gin/wrappable.h" 13 #include "gin/wrappable.h"
14 #include "third_party/WebKit/public/web/WebKit.h" 14 #include "third_party/WebKit/public/web/WebKit.h"
15 #include "third_party/WebKit/public/web/WebPluginParams.h" 15 #include "third_party/WebKit/public/web/WebPluginParams.h"
16 16
17 namespace plugins { 17 namespace plugins {
18 18
19 // This abstract class is the base class of all plugin placeholders. 19 // This abstract class is the base class of all plugin placeholders.
20 class PluginPlaceholderBase : public content::RenderFrameObserver, 20 class PluginPlaceholderBase : public content::RenderFrameObserver,
21 public WebViewPlugin::Delegate { 21 public WebViewPlugin::Delegate {
22 public: 22 public:
23 // |render_frame| and |frame| are weak pointers. If either one is going away, 23 // |render_frame| is a weak pointer. If it is going away, our |plugin_| will
24 // our |plugin_| will be destroyed as well and will notify us. 24 // be destroyed as well and will notify us.
25 PluginPlaceholderBase(content::RenderFrame* render_frame, 25 PluginPlaceholderBase(content::RenderFrame* render_frame,
26 blink::WebLocalFrame* frame,
27 const blink::WebPluginParams& params, 26 const blink::WebPluginParams& params,
28 const std::string& html_data); 27 const std::string& html_data);
29
30 ~PluginPlaceholderBase() override; 28 ~PluginPlaceholderBase() override;
31 29
32 WebViewPlugin* plugin() { return plugin_; } 30 WebViewPlugin* plugin() { return plugin_; }
33 31
34 protected: 32 protected:
35 blink::WebLocalFrame* GetFrame();
36 const blink::WebPluginParams& GetPluginParams() const; 33 const blink::WebPluginParams& GetPluginParams() const;
37 34
38 // WebViewPlugin::Delegate methods: 35 // WebViewPlugin::Delegate methods:
39 void ShowContextMenu(const blink::WebMouseEvent&) override; 36 void ShowContextMenu(const blink::WebMouseEvent&) override;
40 void PluginDestroyed() override; 37 void PluginDestroyed() override;
41 v8::Local<v8::Object> GetV8ScriptableObject( 38 v8::Local<v8::Object> GetV8ScriptableObject(
42 v8::Isolate* isolate) const override; 39 v8::Isolate* isolate) const override;
43 bool IsErrorPlaceholder() override; 40 bool IsErrorPlaceholder() override;
44 41
45 protected: 42 protected:
46 // Hide this placeholder. 43 // Hide this placeholder.
47 void HidePlugin(); 44 void HidePlugin();
48 bool hidden() { return hidden_; } 45 bool hidden() const { return hidden_; }
49 46
50 // JavaScript callbacks: 47 // JavaScript callbacks:
51 void HideCallback(); 48 void HideCallback();
52 49
53 private: 50 private:
54 // RenderFrameObserver methods: 51 // RenderFrameObserver methods:
55 void OnDestruct() override; 52 void OnDestruct() override;
56 53
57 blink::WebLocalFrame* frame_;
58 blink::WebPluginParams plugin_params_; 54 blink::WebPluginParams plugin_params_;
59 WebViewPlugin* plugin_; 55 WebViewPlugin* plugin_;
60 56
61 bool hidden_; 57 bool hidden_;
62 58
63 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholderBase); 59 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholderBase);
64 }; 60 };
65 61
66 // A basic placeholder that supports only hiding. 62 // A basic placeholder that supports only hiding.
67 class PluginPlaceholder final : public PluginPlaceholderBase, 63 class PluginPlaceholder final : public PluginPlaceholderBase,
68 public gin::Wrappable<PluginPlaceholder> { 64 public gin::Wrappable<PluginPlaceholder> {
69 public: 65 public:
70 static gin::WrapperInfo kWrapperInfo; 66 static gin::WrapperInfo kWrapperInfo;
71 67
72 PluginPlaceholder(content::RenderFrame* render_frame, 68 PluginPlaceholder(content::RenderFrame* render_frame,
73 blink::WebLocalFrame* frame,
74 const blink::WebPluginParams& params, 69 const blink::WebPluginParams& params,
75 const std::string& html_data); 70 const std::string& html_data);
76 ~PluginPlaceholder() override; 71 ~PluginPlaceholder() override;
77 72
78 private: 73 private:
79 // WebViewPlugin::Delegate methods: 74 // WebViewPlugin::Delegate methods:
80 v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) final; 75 v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) final;
81 76
82 // gin::Wrappable method: 77 // gin::Wrappable method:
83 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( 78 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
84 v8::Isolate* isolate) override; 79 v8::Isolate* isolate) override;
85 }; 80 };
86 81
87 } // namespace plugins 82 } // namespace plugins
88 83
89 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ 84 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698