| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // container. | 34 // container. |
| 35 bool OnMessageReceived(const IPC::Message& message); | 35 bool OnMessageReceived(const IPC::Message& message); |
| 36 | 36 |
| 37 // Destroys this GuestViewContainer after performing necessary cleanup. | 37 // Destroys this GuestViewContainer after performing necessary cleanup. |
| 38 // |embedder_frame_destroyed| is true if this destruction is due to the | 38 // |embedder_frame_destroyed| is true if this destruction is due to the |
| 39 // embedding frame of the container being destroyed. | 39 // embedding frame of the container being destroyed. |
| 40 void Destroy(bool embedder_frame_destroyed); | 40 void Destroy(bool embedder_frame_destroyed); |
| 41 | 41 |
| 42 void RegisterDestructionCallback(v8::Local<v8::Function> callback, | 42 void RegisterDestructionCallback(v8::Local<v8::Function> callback, |
| 43 v8::Isolate* isolate); | 43 v8::Isolate* isolate); |
| 44 void RegisterElementResizeCallback(v8::Local<v8::Function> callback, |
| 45 v8::Isolate* isolate); |
| 44 | 46 |
| 45 // Called when the embedding RenderFrame is destroyed. | 47 // Called when the embedding RenderFrame is destroyed. |
| 46 virtual void OnRenderFrameDestroyed() {} | 48 virtual void OnRenderFrameDestroyed() {} |
| 47 | 49 |
| 48 // Called to respond to IPCs from the browser process that have not been | 50 // Called to respond to IPCs from the browser process that have not been |
| 49 // handled by GuestViewContainer. | 51 // handled by GuestViewContainer. |
| 50 virtual bool OnMessage(const IPC::Message& message); | 52 virtual bool OnMessage(const IPC::Message& message); |
| 51 | 53 |
| 52 // Called to perform actions when a GuestViewContainer gets a geometry. | 54 // Called to perform actions when a GuestViewContainer gets a geometry. |
| 53 virtual void OnReady() {} | 55 virtual void OnReady() {} |
| 54 | 56 |
| 55 // Called to perform actions when a GuestViewContainer is about to be | 57 // Called to perform actions when a GuestViewContainer is about to be |
| 56 // destroyed. | 58 // destroyed. |
| 57 // Note that this should be called exactly once. | 59 // Note that this should be called exactly once. |
| 58 virtual void OnDestroy(bool embedder_frame_destroyed) {} | 60 virtual void OnDestroy(bool embedder_frame_destroyed) {} |
| 59 | 61 |
| 60 // BrowserPluginGuestDelegate public implementation. | 62 // BrowserPluginGuestDelegate public implementation. |
| 61 void SetElementInstanceID(int element_instance_id) final; | 63 void SetElementInstanceID(int element_instance_id) final; |
| 64 void DidResizeElement(const gfx::Size& new_size) override; |
| 62 | 65 |
| 63 protected: | 66 protected: |
| 64 ~GuestViewContainer() override; | 67 ~GuestViewContainer() override; |
| 65 | 68 |
| 66 bool ready_; | 69 bool ready_; |
| 67 | 70 |
| 68 void OnHandleCallback(const IPC::Message& message); | 71 void OnHandleCallback(const IPC::Message& message); |
| 69 | 72 |
| 70 private: | 73 private: |
| 71 class RenderFrameLifetimeObserver; | 74 class RenderFrameLifetimeObserver; |
| 72 friend class RenderFrameLifetimeObserver; | 75 friend class RenderFrameLifetimeObserver; |
| 73 | 76 |
| 74 void RenderFrameDestroyed(); | 77 void RenderFrameDestroyed(); |
| 75 | 78 |
| 76 void EnqueueRequest(std::unique_ptr<GuestViewRequest> request); | 79 void EnqueueRequest(std::unique_ptr<GuestViewRequest> request); |
| 77 void PerformPendingRequest(); | 80 void PerformPendingRequest(); |
| 78 void HandlePendingResponseCallback(const IPC::Message& message); | 81 void HandlePendingResponseCallback(const IPC::Message& message); |
| 79 void RunDestructionCallback(bool embedder_frame_destroyed); | 82 void RunDestructionCallback(bool embedder_frame_destroyed); |
| 83 void CallElementResizeCallback(const gfx::Size& new_size); |
| 80 | 84 |
| 81 // BrowserPluginDelegate implementation. | 85 // BrowserPluginDelegate implementation. |
| 82 void Ready() final; | 86 void Ready() final; |
| 83 void DidDestroyElement() final; | 87 void DidDestroyElement() final; |
| 84 base::WeakPtr<BrowserPluginDelegate> GetWeakPtr() final; | 88 base::WeakPtr<BrowserPluginDelegate> GetWeakPtr() final; |
| 85 | 89 |
| 86 int element_instance_id_; | 90 int element_instance_id_; |
| 87 content::RenderFrame* render_frame_; | 91 content::RenderFrame* render_frame_; |
| 88 std::unique_ptr<RenderFrameLifetimeObserver> render_frame_lifetime_observer_; | 92 std::unique_ptr<RenderFrameLifetimeObserver> render_frame_lifetime_observer_; |
| 89 | 93 |
| 90 bool in_destruction_; | 94 bool in_destruction_; |
| 91 | 95 |
| 92 std::deque<std::unique_ptr<GuestViewRequest>> pending_requests_; | 96 std::deque<std::unique_ptr<GuestViewRequest>> pending_requests_; |
| 93 std::unique_ptr<GuestViewRequest> pending_response_; | 97 std::unique_ptr<GuestViewRequest> pending_response_; |
| 94 | 98 |
| 95 v8::Global<v8::Function> destruction_callback_; | 99 v8::Global<v8::Function> destruction_callback_; |
| 96 v8::Isolate* destruction_isolate_; | 100 v8::Isolate* destruction_isolate_; |
| 97 | 101 |
| 102 v8::Global<v8::Function> element_resize_callback_; |
| 103 v8::Isolate* element_resize_isolate_; |
| 104 |
| 98 base::WeakPtrFactory<GuestViewContainer> weak_ptr_factory_; | 105 base::WeakPtrFactory<GuestViewContainer> weak_ptr_factory_; |
| 99 | 106 |
| 100 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); | 107 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); |
| 101 }; | 108 }; |
| 102 | 109 |
| 103 } // namespace guest_view | 110 } // namespace guest_view |
| 104 | 111 |
| 105 #endif // COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ | 112 #endif // COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ |
| OLD | NEW |