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 // This class represents an AttachGuest request from Javascript. It includes | |
| 23 // the input parameters and the callback function. The Attach operation may | |
| 24 // not execute immediately, if the container is not ready or if there are | |
| 25 // other attach operations in flight. | |
| 26 class AttachRequest { | |
| 27 public: | |
| 28 AttachRequest(int element_instance_id, | |
| 29 int guest_instance_id, | |
| 30 scoped_ptr<base::DictionaryValue> params, | |
| 31 v8::Handle<v8::Function> callback, | |
| 32 v8::Isolate* isolate); | |
| 33 ~AttachRequest(); | |
| 34 | |
| 35 int element_instance_id() const { return element_instance_id_; } | |
| 36 | |
| 37 int guest_instance_id() const { return guest_instance_id_; } | |
| 38 | |
| 39 base::DictionaryValue* attach_params() const { | |
| 40 return params_.get(); | |
| 41 } | |
| 42 | |
| 43 bool HasCallback() const; | |
| 44 | |
| 45 v8::Handle<v8::Function> GetCallback() const; | |
| 46 | |
| 47 v8::Isolate* isolate() const { return isolate_; } | |
| 48 | |
| 49 private: | |
| 50 const int element_instance_id_; | |
| 51 const int guest_instance_id_; | |
| 52 scoped_ptr<base::DictionaryValue> params_; | |
| 53 ScopedPersistent<v8::Function> callback_; | |
| 54 v8::Isolate* const isolate_; | |
| 55 }; | |
| 56 | |
| 19 GuestViewContainer(content::RenderFrame* render_frame, | 57 GuestViewContainer(content::RenderFrame* render_frame, |
| 20 const std::string& mime_type); | 58 const std::string& mime_type); |
| 21 virtual ~GuestViewContainer(); | 59 virtual ~GuestViewContainer(); |
| 22 | 60 |
| 23 static GuestViewContainer* FromID(int render_view_routing_id, | 61 static GuestViewContainer* FromID(int render_view_routing_id, |
| 24 int element_instance_id); | 62 int element_instance_id); |
| 25 | 63 |
| 26 void AttachGuest(int element_instance_id, | 64 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 | 65 |
| 32 // BrowserPluginDelegate implementation. | 66 // BrowserPluginDelegate implementation. |
| 33 virtual void SetElementInstanceID(int element_instance_id) override; | 67 virtual void SetElementInstanceID(int element_instance_id) OVERRIDE; |
|
lazyboy
2014/10/03 22:10:19
I'm not sure why OVERRIDEs didn't change to overri
Fady Samuel
2014/10/03 22:23:59
Done.
| |
| 34 virtual void DidFinishLoading() override; | 68 virtual void DidFinishLoading() OVERRIDE; |
| 35 virtual void DidReceiveData(const char* data, int data_length) override; | 69 virtual void DidReceiveData(const char* data, int data_length) OVERRIDE; |
| 70 virtual void Ready() OVERRIDE; | |
| 36 | 71 |
| 37 // RenderFrameObserver override. | 72 // RenderFrameObserver override. |
| 38 virtual void OnDestruct() override; | 73 virtual void OnDestruct() override; |
| 39 virtual bool OnMessageReceived(const IPC::Message& message) override; | 74 virtual bool OnMessageReceived(const IPC::Message& message) override; |
| 40 | 75 |
| 41 private: | 76 private: |
| 42 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); | 77 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); |
| 43 void OnGuestAttached(int element_instance_id, int guest_routing_id); | 78 void OnGuestAttached(int element_instance_id, int guest_routing_id); |
| 44 | 79 |
| 80 void AttachGuestInternal(linked_ptr<AttachRequest> request); | |
| 81 void EnqueueAttachRequest(linked_ptr<AttachRequest> request); | |
| 82 void PerformPendingAttachRequest(); | |
| 83 | |
| 45 static bool ShouldHandleMessage(const IPC::Message& mesage); | 84 static bool ShouldHandleMessage(const IPC::Message& mesage); |
| 46 | 85 |
| 47 const std::string mime_type_; | 86 const std::string mime_type_; |
| 48 int element_instance_id_; | 87 int element_instance_id_; |
| 49 std::string html_string_; | 88 std::string html_string_; |
| 50 // Save the RenderView RoutingID here so that we can use it during | 89 // Save the RenderView RoutingID here so that we can use it during |
| 51 // destruction. | 90 // destruction. |
| 52 int render_view_routing_id_; | 91 int render_view_routing_id_; |
| 53 | 92 |
| 54 bool attached_; | 93 bool attached_; |
| 55 bool attach_pending_; | 94 bool ready_; |
| 56 | 95 |
| 57 ScopedPersistent<v8::Function> callback_; | 96 std::deque<linked_ptr<AttachRequest> > pending_requests_; |
| 58 v8::Isolate* isolate_; | 97 linked_ptr<AttachRequest> pending_response_; |
| 59 | 98 |
| 60 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); | 99 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); |
| 61 }; | 100 }; |
| 62 | 101 |
| 63 } // namespace extensions | 102 } // namespace extensions |
| 64 | 103 |
| 65 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ | 104 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ |
| OLD | NEW |