OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ | 5 #ifndef COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ |
6 #define COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ | 6 #define COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ |
7 | 7 |
8 #include "base/memory/linked_ptr.h" | 8 #include "base/memory/linked_ptr.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/public/renderer/browser_plugin_delegate.h" | 10 #include "content/public/renderer/browser_plugin_delegate.h" |
11 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
12 | 12 |
13 namespace guest_view { | 13 namespace guest_view { |
14 | 14 |
15 class GuestViewRequest; | 15 class GuestViewRequest; |
16 | 16 |
17 class GuestViewContainer : public content::BrowserPluginDelegate { | 17 class GuestViewContainer : public content::BrowserPluginDelegate { |
18 public: | 18 public: |
19 explicit GuestViewContainer(content::RenderFrame* render_frame); | 19 explicit GuestViewContainer(content::RenderFrame* render_frame); |
20 ~GuestViewContainer() override; | |
21 | 20 |
22 static GuestViewContainer* FromID(int element_instance_id); | 21 static GuestViewContainer* FromID(int element_instance_id); |
23 | 22 |
24 // IssueRequest queues up a |request| until the container is ready and | 23 // IssueRequest queues up a |request| until the container is ready and |
25 // the browser process has responded to the last request if it's still | 24 // the browser process has responded to the last request if it's still |
26 // pending. | 25 // pending. |
27 void IssueRequest(linked_ptr<GuestViewRequest> request); | 26 void IssueRequest(linked_ptr<GuestViewRequest> request); |
28 | 27 |
29 int element_instance_id() const { return element_instance_id_; } | 28 int element_instance_id() const { return element_instance_id_; } |
30 content::RenderFrame* render_frame() const { return render_frame_; } | 29 content::RenderFrame* render_frame() const { return render_frame_; } |
31 | 30 |
32 // Called by GuestViewContainerDispatcher to dispatch message to this | 31 // Called by GuestViewContainerDispatcher to dispatch message to this |
33 // container. | 32 // container. |
34 bool OnMessageReceived(const IPC::Message& message); | 33 bool OnMessageReceived(const IPC::Message& message); |
35 | 34 |
35 // BrowserPluginDelegate public implementation. | |
36 // Note that DidDestroyElement currently destroys this container. | |
37 // This won't be necessary once GuestViewContainers run w/o plugin. | |
38 void DidDestroyElement() final; | |
Fady Samuel
2015/06/05 22:12:46
Does this need to be public?
lazyboy
2015/06/05 22:26:15
Since Destroy() is now public, made this private.
| |
39 | |
36 // Called when the embedding RenderFrame is destroyed. | 40 // Called when the embedding RenderFrame is destroyed. |
37 virtual void OnRenderFrameDestroyed() {} | 41 virtual void OnRenderFrameDestroyed() {} |
38 | 42 |
39 // Called to respond to IPCs from the browser process that have not been | 43 // Called to respond to IPCs from the browser process that have not been |
40 // handled by GuestViewContainer. | 44 // handled by GuestViewContainer. |
41 virtual bool OnMessage(const IPC::Message& message); | 45 virtual bool OnMessage(const IPC::Message& message); |
42 | 46 |
43 // Called to perform actions when a GuestViewContainer gets a geometry. | 47 // Called to perform actions when a GuestViewContainer gets a geometry. |
44 virtual void OnReady() {} | 48 virtual void OnReady() {} |
45 | 49 |
50 // Called to perform actions when a GuestViewContainer is about to be | |
51 // destroyed. | |
52 // Note that this should be called exactly once. | |
53 virtual void OnDestroy() {} | |
54 | |
55 protected: | |
56 ~GuestViewContainer() override; | |
57 | |
46 private: | 58 private: |
47 class RenderFrameLifetimeObserver; | 59 class RenderFrameLifetimeObserver; |
48 friend class RenderFrameLifetimeObserver; | 60 friend class RenderFrameLifetimeObserver; |
49 | 61 |
50 void RenderFrameDestroyed(); | 62 void RenderFrameDestroyed(); |
51 | 63 |
52 void EnqueueRequest(linked_ptr<GuestViewRequest> request); | 64 void EnqueueRequest(linked_ptr<GuestViewRequest> request); |
53 void PerformPendingRequest(); | 65 void PerformPendingRequest(); |
54 void HandlePendingResponseCallback(const IPC::Message& message); | 66 void HandlePendingResponseCallback(const IPC::Message& message); |
55 | 67 |
56 void OnHandleCallback(const IPC::Message& message); | 68 void OnHandleCallback(const IPC::Message& message); |
57 | 69 |
70 // Destroys this GuestViewContainer after performing necessary cleanup. | |
71 void Destroy(); | |
72 | |
58 // BrowserPluginDelegate implementation. | 73 // BrowserPluginDelegate implementation. |
59 void Ready() final; | 74 void Ready() final; |
60 void SetElementInstanceID(int element_instance_id) final; | 75 void SetElementInstanceID(int element_instance_id) final; |
61 | 76 |
62 int element_instance_id_; | 77 int element_instance_id_; |
63 content::RenderFrame* render_frame_; | 78 content::RenderFrame* render_frame_; |
64 scoped_ptr<RenderFrameLifetimeObserver> render_frame_lifetime_observer_; | 79 scoped_ptr<RenderFrameLifetimeObserver> render_frame_lifetime_observer_; |
65 | 80 |
66 bool ready_; | 81 bool ready_; |
82 bool in_destruction_; | |
67 | 83 |
68 std::deque<linked_ptr<GuestViewRequest> > pending_requests_; | 84 std::deque<linked_ptr<GuestViewRequest> > pending_requests_; |
69 linked_ptr<GuestViewRequest> pending_response_; | 85 linked_ptr<GuestViewRequest> pending_response_; |
70 | 86 |
71 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); | 87 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); |
72 }; | 88 }; |
73 | 89 |
74 } // namespace guest_view | 90 } // namespace guest_view |
75 | 91 |
76 #endif // COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ | 92 #endif // COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ |
OLD | NEW |