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

Side by Side Diff: chrome/browser/guest_view/guest_view_base.h

Issue 334923002: Remove ContentBrowserClient::GuestWebContentsAttached (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_adview
Patch Set: Added missing file Created 6 years, 6 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_GUEST_VIEW_GUEST_VIEW_BASE_H_ 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 static GuestViewBase* From(int embedder_process_id, int instance_id); 57 static GuestViewBase* From(int embedder_process_id, int instance_id);
58 58
59 static bool IsGuest(content::WebContents* web_contents); 59 static bool IsGuest(content::WebContents* web_contents);
60 60
61 // By default, JavaScript and images are enabled in guest content. 61 // By default, JavaScript and images are enabled in guest content.
62 static void GetDefaultContentSettingRules(RendererContentSettingRules* rules, 62 static void GetDefaultContentSettingRules(RendererContentSettingRules* rules,
63 bool incognito); 63 bool incognito);
64 64
65 virtual const char* GetViewType() const = 0; 65 virtual const char* GetViewType() const = 0;
66 66
67 // This method is called after the guest has been attached to an embedder.
68 //
69 // This method can be overriden by subclasses. This gives the derived class
70 // an opportunity to perform setup actions after attachment.
71 virtual void DidAttach() {}
72
67 // This method can be overridden by subclasses. This method is called when 73 // This method can be overridden by subclasses. This method is called when
68 // the initial set of frames within the page have completed loading. 74 // the initial set of frames within the page have completed loading.
69 virtual void DidStopLoading() {} 75 virtual void DidStopLoading() {}
70 76
71 // This method is called when the guest WebContents is about to be destroyed. 77 // This method is called when the guest WebContents is about to be destroyed.
72 // 78 //
73 // This method can be overridden by subclasses. This gives the derived class 79 // This method can be overridden by subclasses. This gives the derived class
74 // an opportunity to perform some cleanup prior to destruction. 80 // an opportunity to perform some cleanup prior to destruction.
75 virtual void WillDestroy() {} 81 virtual void WillDestroy() {}
76 82
77 // This method is called when the guest's embedder WebContents has been 83 // This method is called when the guest's embedder WebContents has been
78 // destroyed and the guest will be destroyed shortly. 84 // destroyed and the guest will be destroyed shortly.
79 // 85 //
80 // This method can be overridden by subclasses. This gives the derived class 86 // This method can be overridden by subclasses. This gives the derived class
81 // an opportunity to perform some cleanup prior to destruction. 87 // an opportunity to perform some cleanup prior to destruction.
82 virtual void EmbedderDestroyed() {} 88 virtual void EmbedderDestroyed() {}
83 89
84 // This method is called when the guest WebContents has been destroyed. This 90 // This method is called when the guest WebContents has been destroyed. This
85 // object will be destroyed after this call returns. 91 // object will be destroyed after this call returns.
86 // 92 //
87 // This method can be overridden by subclasses. This gives the derived class 93 // This method can be overridden by subclasses. This gives the derived class
88 // opportunity to perform some cleanup. 94 // opportunity to perform some cleanup.
89 virtual void GuestDestroyed() {} 95 virtual void GuestDestroyed() {}
90 96
91 // This method queries whether drag-and-drop is enabled for this particular 97 // This method queries whether drag-and-drop is enabled for this particular
92 // view. By default, drag-and-drop is disabled. Derived classes can override 98 // view. By default, drag-and-drop is disabled. Derived classes can override
93 // this behavior to enable drag-and-drop. 99 // this behavior to enable drag-and-drop.
94 virtual bool IsDragAndDropEnabled() const; 100 virtual bool IsDragAndDropEnabled() const;
95 101
102 void Init(content::WebContents* guest_web_contents,
103 const std::string& embedder_extension_id);
104
96 bool IsViewType(const char* const view_type) const { 105 bool IsViewType(const char* const view_type) const {
97 return !strcmp(GetViewType(), view_type); 106 return !strcmp(GetViewType(), view_type);
98 } 107 }
99 108
100 base::WeakPtr<GuestViewBase> AsWeakPtr(); 109 base::WeakPtr<GuestViewBase> AsWeakPtr();
101 110
102 virtual void Attach(content::WebContents* embedder_web_contents,
103 const base::DictionaryValue& args);
104
105 content::WebContents* embedder_web_contents() const { 111 content::WebContents* embedder_web_contents() const {
106 return embedder_web_contents_; 112 return embedder_web_contents_;
107 } 113 }
108 114
109 // Returns the guest WebContents. 115 // Returns the guest WebContents.
110 content::WebContents* guest_web_contents() const { 116 content::WebContents* guest_web_contents() const {
111 return web_contents(); 117 return web_contents();
112 } 118 }
113 119
114 // Returns the extra parameters associated with this GuestView passed 120 // Returns the extra parameters associated with this GuestView passed
(...skipping 26 matching lines...) Expand all
141 int embedder_render_process_id() const { return embedder_render_process_id_; } 147 int embedder_render_process_id() const { return embedder_render_process_id_; }
142 148
143 GuestViewBase* GetOpener() const { 149 GuestViewBase* GetOpener() const {
144 return opener_.get(); 150 return opener_.get();
145 } 151 }
146 152
147 void SetOpener(GuestViewBase* opener); 153 void SetOpener(GuestViewBase* opener);
148 154
149 // BrowserPluginGuestDelegate implementation. 155 // BrowserPluginGuestDelegate implementation.
150 virtual void Destroy() OVERRIDE FINAL; 156 virtual void Destroy() OVERRIDE FINAL;
157 virtual void DidAttach(
158 content::WebContents* embedder_web_contents,
159 const base::DictionaryValue& extra_params) OVERRIDE FINAL;
151 virtual void RegisterDestructionCallback( 160 virtual void RegisterDestructionCallback(
152 const DestructionCallback& callback) OVERRIDE FINAL; 161 const DestructionCallback& callback) OVERRIDE FINAL;
153 162
154 protected: 163 protected:
155 GuestViewBase(int guest_instance_id, 164 explicit GuestViewBase(int guest_instance_id);
156 content::WebContents* guest_web_contents, 165
157 const std::string& embedder_extension_id);
158 virtual ~GuestViewBase(); 166 virtual ~GuestViewBase();
159 167
160 // Dispatches an event |event_name| to the embedder with the |event| fields. 168 // Dispatches an event |event_name| to the embedder with the |event| fields.
161 void DispatchEvent(Event* event); 169 void DispatchEvent(Event* event);
162 170
163 private: 171 private:
164 class EmbedderWebContentsObserver; 172 class EmbedderWebContentsObserver;
165 173
166 void SendQueuedEvents(); 174 void SendQueuedEvents();
167 175
168 // WebContentsObserver implementation. 176 // WebContentsObserver implementation.
169 virtual void DidStopLoading( 177 virtual void DidStopLoading(
170 content::RenderViewHost* render_view_host) OVERRIDE FINAL; 178 content::RenderViewHost* render_view_host) OVERRIDE FINAL;
171 virtual void WebContentsDestroyed() OVERRIDE FINAL; 179 virtual void WebContentsDestroyed() OVERRIDE FINAL;
172 180
173 // WebContentsDelegate implementation. 181 // WebContentsDelegate implementation.
174 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; 182 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL;
175 virtual bool PreHandleGestureEvent( 183 virtual bool PreHandleGestureEvent(
176 content::WebContents* source, 184 content::WebContents* source,
177 const blink::WebGestureEvent& event) OVERRIDE FINAL; 185 const blink::WebGestureEvent& event) OVERRIDE FINAL;
178 186
179 content::WebContents* embedder_web_contents_; 187 content::WebContents* embedder_web_contents_;
180 const std::string embedder_extension_id_; 188 std::string embedder_extension_id_;
181 int embedder_render_process_id_; 189 int embedder_render_process_id_;
182 content::BrowserContext* const browser_context_; 190 content::BrowserContext* browser_context_;
183 // |guest_instance_id_| is a profile-wide unique identifier for a guest 191 // |guest_instance_id_| is a profile-wide unique identifier for a guest
184 // WebContents. 192 // WebContents.
185 const int guest_instance_id_; 193 const int guest_instance_id_;
186 // |view_instance_id_| is an identifier that's unique within a particular 194 // |view_instance_id_| is an identifier that's unique within a particular
187 // embedder RenderViewHost for a particular <*view> instance. 195 // embedder RenderViewHost for a particular <*view> instance.
188 int view_instance_id_; 196 int view_instance_id_;
189 197
198 bool initialized_;
199
190 // This is a queue of Events that are destined to be sent to the embedder once 200 // This is a queue of Events that are destined to be sent to the embedder once
191 // the guest is attached to a particular embedder. 201 // the guest is attached to a particular embedder.
192 std::deque<linked_ptr<Event> > pending_events_; 202 std::deque<linked_ptr<Event> > pending_events_;
193 203
194 // The opener guest view. 204 // The opener guest view.
195 base::WeakPtr<GuestViewBase> opener_; 205 base::WeakPtr<GuestViewBase> opener_;
196 206
197 DestructionCallback destruction_callback_; 207 DestructionCallback destruction_callback_;
198 208
199 // The extra parameters associated with this GuestView passed 209 // The extra parameters associated with this GuestView passed
200 // in from JavaScript. This will typically be the view instance ID, 210 // in from JavaScript. This will typically be the view instance ID,
201 // the API to use, and view-specific parameters. These parameters 211 // the API to use, and view-specific parameters. These parameters
202 // are passed along to new guests that are created from this guest. 212 // are passed along to new guests that are created from this guest.
203 scoped_ptr<base::DictionaryValue> extra_params_; 213 scoped_ptr<base::DictionaryValue> extra_params_;
204 214
205 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; 215 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_;
206 216
207 // This is used to ensure pending tasks will not fire after this object is 217 // This is used to ensure pending tasks will not fire after this object is
208 // destroyed. 218 // destroyed.
209 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; 219 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
210 220
211 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); 221 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
212 }; 222 };
213 223
214 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 224 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698