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_WEB_VIEW_CONTAINER_H_ |
|
Fady Samuel
2014/11/03 11:03:38
This should be updated to say extensions.
raymes
2014/11/03 22:51:32
Done.
| |
| 6 #define CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ | 6 #define CHROME_RENDERER_GUEST_VIEW_WEB_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 "content/public/renderer/browser_plugin_delegate.h" | 13 #include "extensions/renderer/guest_view/guest_view_container.h" |
| 14 #include "content/public/renderer/render_frame_observer.h" | |
| 15 #include "extensions/renderer/scoped_persistent.h" | 14 #include "extensions/renderer/scoped_persistent.h" |
| 16 | 15 |
| 17 namespace extensions { | 16 namespace extensions { |
| 18 | 17 |
| 19 class GuestViewContainer : public content::BrowserPluginDelegate, | 18 class WebViewContainer : public GuestViewContainer { |
|
Fady Samuel
2014/11/03 11:03:38
Multiple guest types need this container type. I w
raymes
2014/11/03 22:51:32
Done.
| |
| 20 public content::RenderFrameObserver { | |
| 21 public: | 19 public: |
| 22 // This class represents an AttachGuest request from Javascript. It includes | 20 // This class represents an AttachGuest request from Javascript. It includes |
| 23 // the input parameters and the callback function. The Attach operation may | 21 // 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 | 22 // not execute immediately, if the container is not ready or if there are |
| 25 // other attach operations in flight. | 23 // other attach operations in flight. |
| 26 class AttachRequest { | 24 class AttachRequest { |
| 27 public: | 25 public: |
| 28 AttachRequest(int element_instance_id, | 26 AttachRequest(int element_instance_id, |
| 29 int guest_instance_id, | 27 int guest_instance_id, |
| 30 scoped_ptr<base::DictionaryValue> params, | 28 scoped_ptr<base::DictionaryValue> params, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 47 v8::Isolate* isolate() const { return isolate_; } | 45 v8::Isolate* isolate() const { return isolate_; } |
| 48 | 46 |
| 49 private: | 47 private: |
| 50 const int element_instance_id_; | 48 const int element_instance_id_; |
| 51 const int guest_instance_id_; | 49 const int guest_instance_id_; |
| 52 scoped_ptr<base::DictionaryValue> params_; | 50 scoped_ptr<base::DictionaryValue> params_; |
| 53 ScopedPersistent<v8::Function> callback_; | 51 ScopedPersistent<v8::Function> callback_; |
| 54 v8::Isolate* const isolate_; | 52 v8::Isolate* const isolate_; |
| 55 }; | 53 }; |
| 56 | 54 |
| 57 GuestViewContainer(content::RenderFrame* render_frame, | 55 explicit WebViewContainer(content::RenderFrame* render_frame); |
| 58 const std::string& mime_type); | 56 ~WebViewContainer() override; |
| 59 ~GuestViewContainer() override; | |
| 60 | 57 |
| 61 static GuestViewContainer* FromID(int render_view_routing_id, | 58 static WebViewContainer* FromID(int render_view_routing_id, |
| 62 int element_instance_id); | 59 int element_instance_id); |
| 63 | 60 |
| 64 void AttachGuest(linked_ptr<AttachRequest> request); | 61 void AttachGuest(linked_ptr<AttachRequest> request); |
| 65 | 62 |
| 66 // BrowserPluginDelegate implementation. | 63 // BrowserPluginDelegate implementation. |
| 67 void SetElementInstanceID(int element_instance_id) override; | 64 void SetElementInstanceID(int element_instance_id) override; |
| 68 void DidFinishLoading() override; | |
| 69 void DidReceiveData(const char* data, int data_length) override; | |
| 70 void Ready() override; | 65 void Ready() override; |
| 71 | 66 |
| 72 // RenderFrameObserver override. | 67 // GuestViewContainer override. |
| 73 void OnDestruct() override; | 68 bool HandlesMessage(const IPC::Message& message) override; |
| 74 bool OnMessageReceived(const IPC::Message& message) override; | 69 bool OnMessage(const IPC::Message& message) override; |
| 75 | 70 |
| 76 private: | 71 private: |
| 77 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); | 72 void OnGuestAttached(int guest_proxy_routing_id); |
| 78 void OnGuestAttached(int element_instance_id, int guest_proxy_routing_id); | |
| 79 | 73 |
| 80 void AttachGuestInternal(linked_ptr<AttachRequest> request); | 74 void AttachGuestInternal(linked_ptr<AttachRequest> request); |
| 81 void EnqueueAttachRequest(linked_ptr<AttachRequest> request); | 75 void EnqueueAttachRequest(linked_ptr<AttachRequest> request); |
| 82 void PerformPendingAttachRequest(); | 76 void PerformPendingAttachRequest(); |
| 83 void HandlePendingResponseCallback(int guest_proxy_routing_id); | 77 void HandlePendingResponseCallback(int guest_proxy_routing_id); |
| 84 | 78 |
| 85 static bool ShouldHandleMessage(const IPC::Message& mesage); | |
| 86 | |
| 87 const std::string mime_type_; | |
| 88 int element_instance_id_; | |
| 89 std::string html_string_; | |
| 90 // Save the RenderView RoutingID here so that we can use it during | |
| 91 // destruction. | |
| 92 int render_view_routing_id_; | |
| 93 | |
| 94 bool attached_; | |
| 95 bool ready_; | 79 bool ready_; |
| 96 | 80 |
| 97 std::deque<linked_ptr<AttachRequest> > pending_requests_; | 81 std::deque<linked_ptr<AttachRequest> > pending_requests_; |
| 98 linked_ptr<AttachRequest> pending_response_; | 82 linked_ptr<AttachRequest> pending_response_; |
| 99 | 83 |
| 100 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); | 84 DISALLOW_COPY_AND_ASSIGN(WebViewContainer); |
| 101 }; | 85 }; |
| 102 | 86 |
| 103 } // namespace extensions | 87 } // namespace extensions |
| 104 | 88 |
| 105 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ | 89 #endif // CHROME_RENDERER_GUEST_VIEW_WEB_VIEW_CONTAINER_H_ |
| OLD | NEW |