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

Side by Side Diff: chrome/browser/guestview/guestview.h

Issue 258373002: Towards moving guest management to chrome: Introduce GuestViewManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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_BROWSER_GUESTVIEW_GUESTVIEW_H_ 5 #ifndef CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_
6 #define CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ 6 #define CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 28 matching lines...) Expand all
39 39
40 private: 40 private:
41 const std::string name_; 41 const std::string name_;
42 scoped_ptr<base::DictionaryValue> args_; 42 scoped_ptr<base::DictionaryValue> args_;
43 }; 43 };
44 44
45 static Type GetViewTypeFromString(const std::string& api_type); 45 static Type GetViewTypeFromString(const std::string& api_type);
46 46
47 static GuestView* Create(content::WebContents* guest_web_contents, 47 static GuestView* Create(content::WebContents* guest_web_contents,
48 const std::string& embedder_extension_id, 48 const std::string& embedder_extension_id,
49 Type view_type); 49 Type view_type,
50 const base::WeakPtr<GuestView>& opener);
50 51
51 static GuestView* FromWebContents(content::WebContents* web_contents); 52 static GuestView* FromWebContents(content::WebContents* web_contents);
52 53
53 static GuestView* From(int embedder_process_id, int instance_id); 54 static GuestView* From(int embedder_process_id, int instance_id);
54 55
55 // For GuestViews, we create special guest processes, which host the 56 // For GuestViews, we create special guest processes, which host the
56 // tag content separately from the main application that embeds the tag. 57 // tag content separately from the main application that embeds the tag.
57 // A GuestView can specify both the partition name and whether the storage 58 // A GuestView can specify both the partition name and whether the storage
58 // for that partition should be persisted. Each tag gets a SiteInstance with 59 // for that partition should be persisted. Each tag gets a SiteInstance with
59 // a specially formatted URL, based on the application it is hosted by and 60 // a specially formatted URL, based on the application it is hosted by and
(...skipping 15 matching lines...) Expand all
75 return embedder_web_contents_; 76 return embedder_web_contents_;
76 } 77 }
77 78
78 // Returns the guest WebContents. 79 // Returns the guest WebContents.
79 content::WebContents* guest_web_contents() const { 80 content::WebContents* guest_web_contents() const {
80 return guest_web_contents_; 81 return guest_web_contents_;
81 } 82 }
82 83
83 virtual Type GetViewType() const; 84 virtual Type GetViewType() const;
84 85
86 base::WeakPtr<GuestView> AsWeakPtr();
87
85 // Returns a WebViewGuest if this GuestView belongs to a <webview>. 88 // Returns a WebViewGuest if this GuestView belongs to a <webview>.
86 virtual WebViewGuest* AsWebView() = 0; 89 virtual WebViewGuest* AsWebView() = 0;
87 90
88 // Returns an AdViewGuest if the GuestView belongs to an <adview>. 91 // Returns an AdViewGuest if the GuestView belongs to an <adview>.
89 virtual AdViewGuest* AsAdView() = 0; 92 virtual AdViewGuest* AsAdView() = 0;
90 93
91 // Returns whether this guest has an associated embedder. 94 // Returns whether this guest has an associated embedder.
92 bool attached() const { return !!embedder_web_contents_; } 95 bool attached() const { return !!embedder_web_contents_; }
93 96
94 // Returns the instance ID of the <*view> element. 97 // Returns the instance ID of the <*view> element.
(...skipping 11 matching lines...) Expand all
106 bool in_extension() const { 109 bool in_extension() const {
107 return !embedder_extension_id_.empty(); 110 return !embedder_extension_id_.empty();
108 } 111 }
109 112
110 // Returns the user browser context of the embedder. 113 // Returns the user browser context of the embedder.
111 content::BrowserContext* browser_context() const { return browser_context_; } 114 content::BrowserContext* browser_context() const { return browser_context_; }
112 115
113 // Returns the embedder's process ID. 116 // Returns the embedder's process ID.
114 int embedder_render_process_id() const { return embedder_render_process_id_; } 117 int embedder_render_process_id() const { return embedder_render_process_id_; }
115 118
119 // BrowserPluginGuestDelegate implementation.
120 virtual content::WebContents* GetOpener() const OVERRIDE;
121 virtual void SetOpener(content::WebContents* opener) OVERRIDE;
122
116 protected: 123 protected:
117 GuestView(content::WebContents* guest_web_contents, 124 GuestView(content::WebContents* guest_web_contents,
118 const std::string& embedder_extension_id); 125 const std::string& embedder_extension_id,
126 const base::WeakPtr<GuestView>& opener);
119 virtual ~GuestView(); 127 virtual ~GuestView();
120 128
121 // Dispatches an event |event_name| to the embedder with the |event| fields. 129 // Dispatches an event |event_name| to the embedder with the |event| fields.
122 void DispatchEvent(Event* event); 130 void DispatchEvent(Event* event);
123 131
124 private: 132 private:
125 void SendQueuedEvents(); 133 void SendQueuedEvents();
126 134
127 content::WebContents* const guest_web_contents_; 135 content::WebContents* const guest_web_contents_;
128 content::WebContents* embedder_web_contents_; 136 content::WebContents* embedder_web_contents_;
129 const std::string embedder_extension_id_; 137 const std::string embedder_extension_id_;
130 int embedder_render_process_id_; 138 int embedder_render_process_id_;
131 content::BrowserContext* const browser_context_; 139 content::BrowserContext* const browser_context_;
132 // |guest_instance_id_| is a profile-wide unique identifier for a guest 140 // |guest_instance_id_| is a profile-wide unique identifier for a guest
133 // WebContents. 141 // WebContents.
134 const int guest_instance_id_; 142 const int guest_instance_id_;
135 // |view_instance_id_| is an identifier that's unique within a particular 143 // |view_instance_id_| is an identifier that's unique within a particular
136 // embedder RenderViewHost for a particular <*view> instance. 144 // embedder RenderViewHost for a particular <*view> instance.
137 int view_instance_id_; 145 int view_instance_id_;
138 146
139 // This is a queue of Events that are destined to be sent to the embedder once 147 // This is a queue of Events that are destined to be sent to the embedder once
140 // the guest is attached to a particular embedder. 148 // the guest is attached to a particular embedder.
141 std::deque<linked_ptr<Event> > pending_events_; 149 std::deque<linked_ptr<Event> > pending_events_;
142 150
151 // Returns a WeakPtr to this GuestView.
lazyboy 2014/04/30 08:40:15 This is the opener web_content's guest? not the th
152 base::WeakPtr<GuestView> opener_;
153
143 // This is used to ensure pending tasks will not fire after this object is 154 // This is used to ensure pending tasks will not fire after this object is
144 // destroyed. 155 // destroyed.
145 base::WeakPtrFactory<GuestView> weak_ptr_factory_; 156 base::WeakPtrFactory<GuestView> weak_ptr_factory_;
146 157
147 DISALLOW_COPY_AND_ASSIGN(GuestView); 158 DISALLOW_COPY_AND_ASSIGN(GuestView);
148 }; 159 };
149 160
150 #endif // CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ 161 #endif // CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698