| 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 EXTENSIONS_RENDERER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_CONTAINER_H_ | 5 #ifndef EXTENSIONS_RENDERER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_CONTAINER_H_ |
| 6 #define EXTENSIONS_RENDERER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_CONTAINER_H_ | 6 #define EXTENSIONS_RENDERER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_CONTAINER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "extensions/renderer/guest_view/guest_view_container.h" | 13 #include "extensions/renderer/guest_view/guest_view_container.h" |
| 14 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 class Size; | 17 class Size; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 | 21 |
| 22 class ExtensionsGuestViewContainer : public GuestViewContainer { | 22 class ExtensionsGuestViewContainer : public GuestViewContainer { |
| 23 public: | 23 public: |
| 24 | 24 |
| 25 class Request { | 25 class Request { |
| 26 public: | 26 public: |
| 27 Request(GuestViewContainer* container, | 27 Request(GuestViewContainer* container, |
| 28 v8::Handle<v8::Function> callback, | 28 v8::Local<v8::Function> callback, |
| 29 v8::Isolate* isolate); | 29 v8::Isolate* isolate); |
| 30 virtual ~Request(); | 30 virtual ~Request(); |
| 31 | 31 |
| 32 virtual void PerformRequest() = 0; | 32 virtual void PerformRequest() = 0; |
| 33 virtual void HandleResponse(const IPC::Message& message) = 0; | 33 virtual void HandleResponse(const IPC::Message& message) = 0; |
| 34 | 34 |
| 35 void ExecuteCallbackIfAvailable(int argc, | 35 void ExecuteCallbackIfAvailable(int argc, |
| 36 scoped_ptr<v8::Handle<v8::Value>[]> argv); | 36 scoped_ptr<v8::Local<v8::Value>[]> argv); |
| 37 | 37 |
| 38 GuestViewContainer* container() const { return container_; } | 38 GuestViewContainer* container() const { return container_; } |
| 39 | 39 |
| 40 bool HasCallback() const; | 40 bool HasCallback() const; |
| 41 | 41 |
| 42 v8::Handle<v8::Function> GetCallback() const; | 42 v8::Local<v8::Function> GetCallback() const; |
| 43 | 43 |
| 44 v8::Isolate* isolate() const { return isolate_; } | 44 v8::Isolate* isolate() const { return isolate_; } |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 GuestViewContainer* container_; | 47 GuestViewContainer* container_; |
| 48 v8::Global<v8::Function> callback_; | 48 v8::Global<v8::Function> callback_; |
| 49 v8::Isolate* const isolate_; | 49 v8::Isolate* const isolate_; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // This class represents an AttachGuest request from Javascript. It includes | 52 // This class represents an AttachGuest request from Javascript. It includes |
| 53 // the input parameters and the callback function. The Attach operation may | 53 // the input parameters and the callback function. The Attach operation may |
| 54 // not execute immediately, if the container is not ready or if there are | 54 // not execute immediately, if the container is not ready or if there are |
| 55 // other attach operations in flight. | 55 // other attach operations in flight. |
| 56 class AttachRequest : public Request { | 56 class AttachRequest : public Request { |
| 57 public: | 57 public: |
| 58 AttachRequest(GuestViewContainer* container, | 58 AttachRequest(GuestViewContainer* container, |
| 59 int guest_instance_id, | 59 int guest_instance_id, |
| 60 scoped_ptr<base::DictionaryValue> params, | 60 scoped_ptr<base::DictionaryValue> params, |
| 61 v8::Handle<v8::Function> callback, | 61 v8::Local<v8::Function> callback, |
| 62 v8::Isolate* isolate); | 62 v8::Isolate* isolate); |
| 63 ~AttachRequest() override; | 63 ~AttachRequest() override; |
| 64 | 64 |
| 65 void PerformRequest() override; | 65 void PerformRequest() override; |
| 66 void HandleResponse(const IPC::Message& message) override; | 66 void HandleResponse(const IPC::Message& message) override; |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 const int guest_instance_id_; | 69 const int guest_instance_id_; |
| 70 scoped_ptr<base::DictionaryValue> params_; | 70 scoped_ptr<base::DictionaryValue> params_; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class DetachRequest : public Request { | 73 class DetachRequest : public Request { |
| 74 public: | 74 public: |
| 75 DetachRequest(GuestViewContainer* container, | 75 DetachRequest(GuestViewContainer* container, |
| 76 v8::Handle<v8::Function> callback, | 76 v8::Local<v8::Function> callback, |
| 77 v8::Isolate* isolate); | 77 v8::Isolate* isolate); |
| 78 ~DetachRequest() override; | 78 ~DetachRequest() override; |
| 79 | 79 |
| 80 void PerformRequest() override; | 80 void PerformRequest() override; |
| 81 void HandleResponse(const IPC::Message& message) override; | 81 void HandleResponse(const IPC::Message& message) override; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 explicit ExtensionsGuestViewContainer(content::RenderFrame* render_frame); | 84 explicit ExtensionsGuestViewContainer(content::RenderFrame* render_frame); |
| 85 ~ExtensionsGuestViewContainer() override; | 85 ~ExtensionsGuestViewContainer() override; |
| 86 | 86 |
| 87 static ExtensionsGuestViewContainer* FromID(int element_instance_id); | 87 static ExtensionsGuestViewContainer* FromID(int element_instance_id); |
| 88 | 88 |
| 89 void IssueRequest(linked_ptr<Request> request); | 89 void IssueRequest(linked_ptr<Request> request); |
| 90 void RegisterDestructionCallback(v8::Handle<v8::Function> callback, | 90 void RegisterDestructionCallback(v8::Local<v8::Function> callback, |
| 91 v8::Isolate* isolate); | 91 v8::Isolate* isolate); |
| 92 void RegisterElementResizeCallback(v8::Handle<v8::Function> callback, | 92 void RegisterElementResizeCallback(v8::Local<v8::Function> callback, |
| 93 v8::Isolate* isolate); | 93 v8::Isolate* isolate); |
| 94 | 94 |
| 95 // BrowserPluginDelegate implementation. | 95 // BrowserPluginDelegate implementation. |
| 96 bool OnMessageReceived(const IPC::Message& message) override; | 96 bool OnMessageReceived(const IPC::Message& message) override; |
| 97 void SetElementInstanceID(int element_instance_id) override; | 97 void SetElementInstanceID(int element_instance_id) override; |
| 98 void Ready() override; | 98 void Ready() override; |
| 99 void DidResizeElement(const gfx::Size& old_size, | 99 void DidResizeElement(const gfx::Size& old_size, |
| 100 const gfx::Size& new_size) override; | 100 const gfx::Size& new_size) override; |
| 101 | 101 |
| 102 private: | 102 private: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 121 | 121 |
| 122 // Weak pointer factory used for calling the element resize callback. | 122 // Weak pointer factory used for calling the element resize callback. |
| 123 base::WeakPtrFactory<ExtensionsGuestViewContainer> weak_ptr_factory_; | 123 base::WeakPtrFactory<ExtensionsGuestViewContainer> weak_ptr_factory_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(ExtensionsGuestViewContainer); | 125 DISALLOW_COPY_AND_ASSIGN(ExtensionsGuestViewContainer); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace extensions | 128 } // namespace extensions |
| 129 | 129 |
| 130 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_CONTAINER_H_ | 130 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_CONTAINER_H_ |
| OLD | NEW |