Update comments of TabObserver#onLoadStarted and rename onContentChanged
[chromium-blink-merge.git] / components / plugins / renderer / plugin_placeholder.h
blobe5fff232372473d5137c52c4247625a142a57e15
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_
6 #define COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "components/plugins/renderer/webview_plugin.h"
10 #include "content/public/renderer/render_frame_observer.h"
11 #include "gin/handle.h"
12 #include "gin/wrappable.h"
13 #include "third_party/WebKit/public/web/WebKit.h"
14 #include "third_party/WebKit/public/web/WebPluginParams.h"
16 namespace plugins {
18 class PluginPlaceholder : public content::RenderFrameObserver,
19 public WebViewPlugin::Delegate,
20 public gin::Wrappable<PluginPlaceholder> {
21 public:
22 static gin::WrapperInfo kWrapperInfo;
24 // |render_frame| and |frame| are weak pointers. If either one is going away,
25 // our |plugin_| will be destroyed as well and will notify us.
26 PluginPlaceholder(content::RenderFrame* render_frame,
27 blink::WebLocalFrame* frame,
28 const blink::WebPluginParams& params,
29 const std::string& html_data);
31 ~PluginPlaceholder() override;
33 WebViewPlugin* plugin() { return plugin_; }
35 protected:
36 blink::WebLocalFrame* GetFrame();
37 const blink::WebPluginParams& GetPluginParams() const;
39 // WebViewPlugin::Delegate methods:
40 void BindWebFrame(blink::WebFrame* frame) override;
41 void ShowContextMenu(const blink::WebMouseEvent&) override;
42 void PluginDestroyed() override;
44 v8::Local<v8::Object> GetV8ScriptableObject(
45 v8::Isolate* isolate) const override;
47 // gin::Wrappable method:
48 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
49 v8::Isolate* isolate) override;
51 protected:
52 // Hide this placeholder.
53 void HidePlugin();
54 bool hidden() { return hidden_; }
56 private:
57 // RenderFrameObserver methods:
58 void OnDestruct() override;
60 // JavaScript callbacks:
61 void HideCallback();
63 blink::WebLocalFrame* frame_;
64 blink::WebPluginParams plugin_params_;
65 WebViewPlugin* plugin_;
67 bool hidden_;
69 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder);
72 } // namespace plugins
74 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_