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

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

Issue 624063002: <webview>: resizing with display:none set should resize on attachment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Istiaque's comments Created 6 years, 2 months 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 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;
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_proxy_routing_id);
79
80 void AttachGuestInternal(linked_ptr<AttachRequest> request);
81 void EnqueueAttachRequest(linked_ptr<AttachRequest> request);
82 void PerformPendingAttachRequest();
83 void HandlePendingResponseCallback(int guest_proxy_routing_id);
44 84
45 static bool ShouldHandleMessage(const IPC::Message& mesage); 85 static bool ShouldHandleMessage(const IPC::Message& mesage);
46 86
47 const std::string mime_type_; 87 const std::string mime_type_;
48 int element_instance_id_; 88 int element_instance_id_;
49 std::string html_string_; 89 std::string html_string_;
50 // Save the RenderView RoutingID here so that we can use it during 90 // Save the RenderView RoutingID here so that we can use it during
51 // destruction. 91 // destruction.
52 int render_view_routing_id_; 92 int render_view_routing_id_;
53 93
54 bool attached_; 94 bool attached_;
55 bool attach_pending_; 95 bool ready_;
56 96
57 ScopedPersistent<v8::Function> callback_; 97 std::deque<linked_ptr<AttachRequest> > pending_requests_;
58 v8::Isolate* isolate_; 98 linked_ptr<AttachRequest> pending_response_;
59 99
60 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); 100 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer);
61 }; 101 };
62 102
63 } // namespace extensions 103 } // namespace extensions
64 104
65 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_ 105 #endif // CHROME_RENDERER_GUEST_VIEW_GUEST_VIEW_CONTAINER_H_
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.cc ('k') | extensions/renderer/guest_view/guest_view_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698