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 "base/memory/scoped_ptr.h" | |
9 #include "base/values.h" | |
8 #include "content/public/renderer/browser_plugin_delegate.h" | 10 #include "content/public/renderer/browser_plugin_delegate.h" |
9 | |
10 #include "content/public/renderer/render_frame_observer.h" | 11 #include "content/public/renderer/render_frame_observer.h" |
11 #include "ipc/ipc_listener.h" | 12 #include "extensions/renderer/scoped_persistent.h" |
12 | 13 |
13 namespace extensions { | 14 namespace extensions { |
14 | 15 |
15 // TODO(lazyboy): This should live under /extensions. | |
16 class GuestViewContainer : public content::BrowserPluginDelegate, | 16 class GuestViewContainer : public content::BrowserPluginDelegate, |
17 public content::RenderFrameObserver { | 17 public content::RenderFrameObserver { |
18 public: | 18 public: |
19 GuestViewContainer(content::RenderFrame* render_frame, | 19 GuestViewContainer(content::RenderFrame* render_frame, |
20 const std::string& mime_type); | 20 const std::string& mime_type); |
21 virtual ~GuestViewContainer(); | 21 virtual ~GuestViewContainer(); |
22 | 22 |
23 static GuestViewContainer* FromID(int render_view_routing_id, | |
24 int element_instance_id); | |
25 | |
26 void AttachGuest(int element_instance_id, | |
27 int guest_instance_id, | |
28 scoped_ptr<base::DictionaryValue> params, | |
29 v8::Handle<v8::Function> callback, | |
30 v8::Isolate* isolate); | |
31 | |
23 // BrowserPluginDelegate implementation. | 32 // BrowserPluginDelegate implementation. |
24 virtual void SetElementInstanceID(int element_instance_id) OVERRIDE; | 33 virtual void SetElementInstanceID(int element_instance_id) OVERRIDE; |
25 virtual void DidFinishLoading() OVERRIDE; | 34 virtual void DidFinishLoading() OVERRIDE; |
26 virtual void DidReceiveData(const char* data, int data_length) OVERRIDE; | 35 virtual void DidReceiveData(const char* data, int data_length) OVERRIDE; |
27 | 36 |
28 // RenderFrameObserver override. | 37 // RenderFrameObserver override. |
29 virtual void OnDestruct() OVERRIDE; | 38 virtual void OnDestruct() OVERRIDE; |
30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
31 | 40 |
32 private: | 41 private: |
33 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); | 42 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); |
43 void OnGuestAttached(int element_instance_id, int guest_routing_id); | |
44 | |
45 static bool ShouldHandleMessage(const IPC::Message& mesage); | |
34 | 46 |
35 const std::string mime_type_; | 47 const std::string mime_type_; |
36 int element_instance_id_; | 48 int element_instance_id_; |
37 std::string html_string_; | 49 std::string html_string_; |
38 | 50 |
51 bool attached_; | |
52 bool attach_pending_; | |
53 | |
54 ScopedPersistent<v8::Function> callback_; | |
55 v8::Isolate* isolate_; | |
lazyboy
2014/09/17 18:24:00
What about the lifetime of this?
I don't know much
Fady Samuel
2014/09/17 20:25:46
Acknowledged.
| |
56 | |
39 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); | 57 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); |
40 }; | 58 }; |
41 | 59 |
42 } // namespace extensions | 60 } // namespace extensions |
43 | 61 |
44 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ | 62 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ |
OLD | NEW |