Chromium Code Reviews| 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 CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ | 5 #ifndef CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ |
| 6 #define CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ | 6 #define CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ |
| 7 | 7 |
| 8 #include <queue> | |
| 9 | |
| 10 #include "base/memory/linked_ptr.h" | |
| 8 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 12 #include "base/values.h" |
| 10 #include "content/public/renderer/browser_plugin_delegate.h" | 13 #include "content/public/renderer/browser_plugin_delegate.h" |
| 11 #include "content/public/renderer/render_frame_observer.h" | 14 #include "content/public/renderer/render_frame_observer.h" |
| 12 #include "extensions/renderer/scoped_persistent.h" | 15 #include "extensions/renderer/scoped_persistent.h" |
| 13 | 16 |
| 14 namespace extensions { | 17 namespace extensions { |
| 15 | 18 |
| 16 class GuestViewContainer : public content::BrowserPluginDelegate, | 19 class GuestViewContainer : public content::BrowserPluginDelegate, |
| 17 public content::RenderFrameObserver { | 20 public content::RenderFrameObserver { |
| 18 public: | 21 public: |
| 22 class AttachRequest { | |
|
lazyboy
2014/10/03 20:30:05
Add a description on this since this is public.
Fady Samuel
2014/10/03 21:52:31
Done.
| |
| 23 public: | |
| 24 AttachRequest(int element_instance_id, | |
| 25 int guest_instance_id, | |
| 26 scoped_ptr<base::DictionaryValue> params, | |
| 27 v8::Handle<v8::Function> callback, | |
| 28 v8::Isolate* isolate); | |
| 29 ~AttachRequest(); | |
| 30 | |
| 31 int element_instance_id() const { return element_instance_id_; } | |
| 32 | |
| 33 int guest_instance_id() const { return guest_instance_id_; } | |
| 34 | |
| 35 base::DictionaryValue* attach_params() const { | |
| 36 return params_.get(); | |
| 37 } | |
| 38 | |
| 39 bool has_callback() const { return !callback_.IsEmpty(); } | |
|
lazyboy
2014/10/03 20:30:05
HasCallback() and define it in .cc file.
Fady Samuel
2014/10/03 21:52:31
Done.
| |
| 40 v8::Handle<v8::Function> GetCallback() const; | |
| 41 | |
| 42 v8::Isolate* isolate() const { return isolate_; } | |
| 43 | |
| 44 private: | |
| 45 const int element_instance_id_; | |
| 46 const int guest_instance_id_; | |
| 47 scoped_ptr<base::DictionaryValue> params_; | |
| 48 ScopedPersistent<v8::Function> callback_; | |
| 49 v8::Isolate* const isolate_; | |
| 50 }; | |
| 51 | |
| 19 GuestViewContainer(content::RenderFrame* render_frame, | 52 GuestViewContainer(content::RenderFrame* render_frame, |
| 20 const std::string& mime_type); | 53 const std::string& mime_type); |
| 21 virtual ~GuestViewContainer(); | 54 virtual ~GuestViewContainer(); |
| 22 | 55 |
| 23 static GuestViewContainer* FromID(int render_view_routing_id, | 56 static GuestViewContainer* FromID(int render_view_routing_id, |
| 24 int element_instance_id); | 57 int element_instance_id); |
| 25 | 58 |
| 26 void AttachGuest(int element_instance_id, | 59 void AttachGuest(linked_ptr<AttachRequest> request); |
| 27 int guest_instance_id, | |
| 28 scoped_ptr<base::DictionaryValue> params, | |
| 29 v8::Handle<v8::Function> callback, | |
| 30 v8::Isolate* isolate); | |
| 31 | 60 |
| 32 // BrowserPluginDelegate implementation. | 61 // BrowserPluginDelegate implementation. |
| 33 virtual void SetElementInstanceID(int element_instance_id) OVERRIDE; | 62 virtual void SetElementInstanceID(int element_instance_id) OVERRIDE; |
| 34 virtual void DidFinishLoading() OVERRIDE; | 63 virtual void DidFinishLoading() OVERRIDE; |
| 35 virtual void DidReceiveData(const char* data, int data_length) OVERRIDE; | 64 virtual void DidReceiveData(const char* data, int data_length) OVERRIDE; |
| 65 virtual void Ready() OVERRIDE; | |
| 36 | 66 |
| 37 // RenderFrameObserver override. | 67 // RenderFrameObserver override. |
| 38 virtual void OnDestruct() OVERRIDE; | 68 virtual void OnDestruct() OVERRIDE; |
| 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 69 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 40 | 70 |
| 41 private: | 71 private: |
| 42 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); | 72 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); |
| 43 void OnGuestAttached(int element_instance_id, int guest_routing_id); | 73 void OnGuestAttached(int element_instance_id, int guest_routing_id); |
| 44 | 74 |
| 75 void AttachGuestInternal(linked_ptr<AttachRequest> request); | |
| 76 | |
| 45 static bool ShouldHandleMessage(const IPC::Message& mesage); | 77 static bool ShouldHandleMessage(const IPC::Message& mesage); |
| 46 | 78 |
| 47 const std::string mime_type_; | 79 const std::string mime_type_; |
| 48 int element_instance_id_; | 80 int element_instance_id_; |
| 49 std::string html_string_; | 81 std::string html_string_; |
| 50 // Save the RenderView RoutingID here so that we can use it during | 82 // Save the RenderView RoutingID here so that we can use it during |
| 51 // destruction. | 83 // destruction. |
| 52 int render_view_routing_id_; | 84 int render_view_routing_id_; |
| 53 | 85 |
| 54 bool attached_; | 86 bool attached_; |
| 55 bool attach_pending_; | 87 bool ready_; |
| 56 | 88 |
| 57 ScopedPersistent<v8::Function> callback_; | 89 std::deque<linked_ptr<AttachRequest> > pending_requests_; |
| 58 v8::Isolate* isolate_; | 90 linked_ptr<AttachRequest> pending_response_; |
| 59 | 91 |
| 60 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); | 92 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); |
| 61 }; | 93 }; |
| 62 | 94 |
| 63 } // namespace extensions | 95 } // namespace extensions |
| 64 | 96 |
| 65 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ | 97 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ |
| OLD | NEW |