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_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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 // By default, JavaScript and images are enabled in guest content. | 73 // By default, JavaScript and images are enabled in guest content. |
74 static void GetDefaultContentSettingRules(RendererContentSettingRules* rules, | 74 static void GetDefaultContentSettingRules(RendererContentSettingRules* rules, |
75 bool incognito); | 75 bool incognito); |
76 | 76 |
77 virtual const char* GetViewType() const = 0; | 77 virtual const char* GetViewType() const = 0; |
78 | 78 |
79 // This method can be overriden by subclasses. This method is called when | 79 // This method can be overriden by subclasses. This method is called when |
80 // the initial set of frames within the page have completed loading. | 80 // the initial set of frames within the page have completed loading. |
81 virtual void DidStopLoading() {} | 81 virtual void DidStopLoading() {} |
82 | 82 |
83 // This method can be overriden by subclasses. This method is called when | |
lazyboy
2014/06/03 18:11:34
s/overriden/overridden, here and in other places.
Fady Samuel
2014/06/04 00:43:00
Done.
| |
84 // the guest WebContents is about to be destroyed. This gives the derived | |
lazyboy
2014/06/03 18:11:34
// Called when guest WC is about to be destroyed s
Fady Samuel
2014/06/04 00:43:00
Done.
| |
85 // class an opportunity to perform some cleanup. | |
86 virtual void WillBeDestroyed() {} | |
lazyboy
2014/06/03 18:11:34
nit: "WillDestroy" is more common in chromium code
Fady Samuel
2014/06/04 00:43:00
Done.
| |
87 | |
83 // This method can be overridden by subclasses. It indicates that this guest's | 88 // This method can be overridden by subclasses. It indicates that this guest's |
84 // embedder has been destroyed and the guest will be destroyed shortly. This | 89 // embedder has been destroyed and the guest will be destroyed shortly. This |
85 // method gives derived classes the opportunity to perform some cleanup. | 90 // method gives derived classes the opportunity to perform some cleanup. |
86 virtual void EmbedderDestroyed() {} | 91 virtual void EmbedderDestroyed() {} |
87 | 92 |
93 // This method can be overriden by subclasses. It indicates that the guest | |
94 // WebContents has been destroyed. This gives subclasses an opportunity | |
95 // to perform some cleanup. | |
96 virtual void GuestDestroyed() {} | |
97 | |
88 // This method queries whether drag-and-drop is enabled for this particular | 98 // This method queries whether drag-and-drop is enabled for this particular |
89 // view. By default, drag-and-drop is disabled. Derived classes can override | 99 // view. By default, drag-and-drop is disabled. Derived classes can override |
90 // this behavior to enable drag-and-drop. | 100 // this behavior to enable drag-and-drop. |
91 virtual bool IsDragAndDropEnabled() const; | 101 virtual bool IsDragAndDropEnabled() const; |
92 | 102 |
93 bool IsViewType(const char* const view_type) const { | 103 bool IsViewType(const char* const view_type) const { |
94 return !strcmp(GetViewType(), view_type); | 104 return !strcmp(GetViewType(), view_type); |
95 } | 105 } |
96 | 106 |
97 base::WeakPtr<GuestViewBase> AsWeakPtr(); | 107 base::WeakPtr<GuestViewBase> AsWeakPtr(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 | 146 |
137 // Returns the embedder's process ID. | 147 // Returns the embedder's process ID. |
138 int embedder_render_process_id() const { return embedder_render_process_id_; } | 148 int embedder_render_process_id() const { return embedder_render_process_id_; } |
139 | 149 |
140 GuestViewBase* GetOpener() const { | 150 GuestViewBase* GetOpener() const { |
141 return opener_.get(); | 151 return opener_.get(); |
142 } | 152 } |
143 | 153 |
144 void SetOpener(GuestViewBase* opener); | 154 void SetOpener(GuestViewBase* opener); |
145 | 155 |
146 // WebContentsObserver implementation. | 156 // BrowserPluginGuestDelegate implementation. |
147 virtual void DidStopLoading( | 157 virtual void Destroy() OVERRIDE FINAL; |
148 content::RenderViewHost* render_view_host) OVERRIDE FINAL; | 158 virtual void RegisterDestructionCallback( |
149 virtual void WebContentsDestroyed() OVERRIDE; | 159 const DestructionCallback& callback) OVERRIDE FINAL; |
150 | 160 |
151 // WebContentsDelegate implementation. | |
152 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; | |
153 virtual bool PreHandleGestureEvent( | |
154 content::WebContents* source, | |
155 const blink::WebGestureEvent& event) OVERRIDE; | |
156 | |
157 // BrowserPluginGuestDelegate implementation. | |
158 virtual void Destroy() OVERRIDE; | |
159 virtual void RegisterDestructionCallback( | |
160 const DestructionCallback& callback) OVERRIDE; | |
161 protected: | 161 protected: |
162 GuestViewBase(int guest_instance_id, | 162 GuestViewBase(int guest_instance_id, |
163 content::WebContents* guest_web_contents, | 163 content::WebContents* guest_web_contents, |
164 const std::string& embedder_extension_id); | 164 const std::string& embedder_extension_id); |
165 virtual ~GuestViewBase(); | 165 virtual ~GuestViewBase(); |
166 | 166 |
167 // Dispatches an event |event_name| to the embedder with the |event| fields. | 167 // Dispatches an event |event_name| to the embedder with the |event| fields. |
168 void DispatchEvent(Event* event); | 168 void DispatchEvent(Event* event); |
169 | 169 |
170 private: | 170 private: |
171 class EmbedderWebContentsObserver; | 171 class EmbedderWebContentsObserver; |
172 | 172 |
173 void SendQueuedEvents(); | 173 void SendQueuedEvents(); |
174 | 174 |
175 // WebContentsObserver implementation. | |
176 virtual void DidStopLoading( | |
177 content::RenderViewHost* render_view_host) OVERRIDE FINAL; | |
178 virtual void WebContentsDestroyed() OVERRIDE FINAL; | |
179 | |
180 // WebContentsDelegate implementation. | |
181 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; | |
182 virtual bool PreHandleGestureEvent( | |
183 content::WebContents* source, | |
184 const blink::WebGestureEvent& event) OVERRIDE FINAL; | |
185 | |
175 content::WebContents* embedder_web_contents_; | 186 content::WebContents* embedder_web_contents_; |
176 const std::string embedder_extension_id_; | 187 const std::string embedder_extension_id_; |
177 int embedder_render_process_id_; | 188 int embedder_render_process_id_; |
178 content::BrowserContext* const browser_context_; | 189 content::BrowserContext* const browser_context_; |
179 // |guest_instance_id_| is a profile-wide unique identifier for a guest | 190 // |guest_instance_id_| is a profile-wide unique identifier for a guest |
180 // WebContents. | 191 // WebContents. |
181 const int guest_instance_id_; | 192 const int guest_instance_id_; |
182 // |view_instance_id_| is an identifier that's unique within a particular | 193 // |view_instance_id_| is an identifier that's unique within a particular |
183 // embedder RenderViewHost for a particular <*view> instance. | 194 // embedder RenderViewHost for a particular <*view> instance. |
184 int view_instance_id_; | 195 int view_instance_id_; |
(...skipping 16 matching lines...) Expand all Loading... | |
201 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 212 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
202 | 213 |
203 // This is used to ensure pending tasks will not fire after this object is | 214 // This is used to ensure pending tasks will not fire after this object is |
204 // destroyed. | 215 // destroyed. |
205 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 216 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
206 | 217 |
207 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 218 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
208 }; | 219 }; |
209 | 220 |
210 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 221 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
OLD | NEW |