Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: extensions/renderer/guest_view/guest_view_container.h

Issue 702433002: Refactor GuestViewContainer to split out WebView related logic and MimeHandlerView related logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 EXTENSIONS_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_
6 #define CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ 6 #define EXTENSIONS_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_
7 7
8 #include <queue>
9
10 #include "base/memory/linked_ptr.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/values.h"
13 #include "content/public/renderer/browser_plugin_delegate.h" 8 #include "content/public/renderer/browser_plugin_delegate.h"
14 #include "content/public/renderer/render_frame_observer.h" 9 #include "content/public/renderer/render_frame_observer.h"
15 #include "extensions/renderer/scoped_persistent.h" 10 #include "ipc/ipc_message.h"
16 11
17 namespace extensions { 12 namespace extensions {
18 13
19 class GuestViewContainer : public content::BrowserPluginDelegate, 14 class GuestViewContainer : public content::BrowserPluginDelegate,
20 public content::RenderFrameObserver { 15 public content::RenderFrameObserver {
21 public: 16 public:
22 // This class represents an AttachGuest request from Javascript. It includes 17 explicit GuestViewContainer(content::RenderFrame* render_frame);
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
57 GuestViewContainer(content::RenderFrame* render_frame,
58 const std::string& mime_type);
59 ~GuestViewContainer() override; 18 ~GuestViewContainer() override;
60 19
61 static GuestViewContainer* FromID(int render_view_routing_id,
62 int element_instance_id);
63
64 void AttachGuest(linked_ptr<AttachRequest> request);
65
66 // BrowserPluginDelegate implementation. 20 // BrowserPluginDelegate implementation.
67 void SetElementInstanceID(int element_instance_id) override; 21 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;
71 22
72 // RenderFrameObserver override. 23 // RenderFrameObserver override.
73 void OnDestruct() override; 24 void OnDestruct() override;
74 bool OnMessageReceived(const IPC::Message& message) override; 25 bool OnMessageReceived(const IPC::Message& message) override;
75 26
76 private: 27 virtual bool HandlesMessage(const IPC::Message& message) = 0;
77 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); 28 virtual bool OnMessage(const IPC::Message& message) = 0;
78 void OnGuestAttached(int element_instance_id, int guest_proxy_routing_id);
79 29
80 void AttachGuestInternal(linked_ptr<AttachRequest> request); 30 protected:
Fady Samuel 2014/11/04 11:47:50 I'd prefer if these member variables are private a
raymes 2014/11/04 22:56:08 Done.
81 void EnqueueAttachRequest(linked_ptr<AttachRequest> request);
82 void PerformPendingAttachRequest();
83 void HandlePendingResponseCallback(int guest_proxy_routing_id);
84
85 static bool ShouldHandleMessage(const IPC::Message& mesage);
86
87 const std::string mime_type_;
88 int element_instance_id_; 31 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_; 32 int render_view_routing_id_;
93 33
94 bool attached_;
95 bool ready_;
96
97 std::deque<linked_ptr<AttachRequest> > pending_requests_;
98 linked_ptr<AttachRequest> pending_response_;
99
100 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); 34 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer);
101 }; 35 };
102 36
103 } // namespace extensions 37 } // namespace extensions
104 38
105 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ 39 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698