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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // This gives the derived class an opportunity to perform some cleanup prior | 96 // This gives the derived class an opportunity to perform some cleanup prior |
97 // to destruction. | 97 // to destruction. |
98 virtual void EmbedderDestroyed() {} | 98 virtual void EmbedderDestroyed() {} |
99 | 99 |
100 // This method is called when the guest WebContents has been destroyed. This | 100 // This method is called when the guest WebContents has been destroyed. This |
101 // object will be destroyed after this call returns. | 101 // object will be destroyed after this call returns. |
102 // | 102 // |
103 // This gives the derived class an opportunity to perform some cleanup. | 103 // This gives the derived class an opportunity to perform some cleanup. |
104 virtual void GuestDestroyed() {} | 104 virtual void GuestDestroyed() {} |
105 | 105 |
| 106 // This method is invoked when the guest RenderView is ready, e.g. because we |
| 107 // recreated it after a crash. |
| 108 // |
| 109 // This gives the derived class an opportunity to perform some initialization |
| 110 // work. |
| 111 virtual void GuestReady() {} |
| 112 |
| 113 // This method is invoked when the contents auto-resized to give the container |
| 114 // an opportunity to match it if it wishes. |
| 115 // |
| 116 // This gives the derived class an opportunity to inform its container element |
| 117 // or perform other actions. |
| 118 virtual void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, |
| 119 const gfx::Size& new_size) {} |
| 120 |
| 121 // This method queries whether autosize is supported for this particular view. |
| 122 // By default, autosize is not supported. Derived classes can override this |
| 123 // behavior to support autosize. |
| 124 virtual bool IsAutoSizeSupported() const; |
| 125 |
106 // This method queries whether drag-and-drop is enabled for this particular | 126 // This method queries whether drag-and-drop is enabled for this particular |
107 // view. By default, drag-and-drop is disabled. Derived classes can override | 127 // view. By default, drag-and-drop is disabled. Derived classes can override |
108 // this behavior to enable drag-and-drop. | 128 // this behavior to enable drag-and-drop. |
109 virtual bool IsDragAndDropEnabled() const; | 129 virtual bool IsDragAndDropEnabled() const; |
110 | 130 |
111 // This method is called immediately before suspended resource loads have been | 131 // This method is called immediately before suspended resource loads have been |
112 // resumed on attachment to an embedder. | 132 // resumed on attachment to an embedder. |
113 // | 133 // |
114 // This method can be overriden by subclasses. This gives the derived class | 134 // This method can be overriden by subclasses. This gives the derived class |
115 // an opportunity to perform setup actions before attachment. | 135 // an opportunity to perform setup actions before attachment. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 167 |
148 void InitWithWebContents( | 168 void InitWithWebContents( |
149 const std::string& embedder_extension_id, | 169 const std::string& embedder_extension_id, |
150 int embedder_render_process_id, | 170 int embedder_render_process_id, |
151 content::WebContents* guest_web_contents); | 171 content::WebContents* guest_web_contents); |
152 | 172 |
153 bool IsViewType(const char* const view_type) const { | 173 bool IsViewType(const char* const view_type) const { |
154 return !strcmp(GetViewType(), view_type); | 174 return !strcmp(GetViewType(), view_type); |
155 } | 175 } |
156 | 176 |
| 177 // Toggles autosize mode for this GuestView. |
| 178 void SetAutoSize(bool enabled, |
| 179 const gfx::Size& min_size, |
| 180 const gfx::Size& max_size); |
| 181 |
157 base::WeakPtr<GuestViewBase> AsWeakPtr(); | 182 base::WeakPtr<GuestViewBase> AsWeakPtr(); |
158 | 183 |
159 bool initialized() const { return initialized_; } | 184 bool initialized() const { return initialized_; } |
160 | 185 |
161 content::WebContents* embedder_web_contents() const { | 186 content::WebContents* embedder_web_contents() const { |
162 return embedder_web_contents_; | 187 return embedder_web_contents_; |
163 } | 188 } |
164 | 189 |
165 // Returns the guest WebContents. | 190 // Returns the guest WebContents. |
166 content::WebContents* guest_web_contents() const { | 191 content::WebContents* guest_web_contents() const { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 226 |
202 // RenderProcessHostObserver implementation | 227 // RenderProcessHostObserver implementation |
203 virtual void RenderProcessExited(content::RenderProcessHost* host, | 228 virtual void RenderProcessExited(content::RenderProcessHost* host, |
204 base::ProcessHandle handle, | 229 base::ProcessHandle handle, |
205 base::TerminationStatus status, | 230 base::TerminationStatus status, |
206 int exit_code) OVERRIDE; | 231 int exit_code) OVERRIDE; |
207 | 232 |
208 // BrowserPluginGuestDelegate implementation. | 233 // BrowserPluginGuestDelegate implementation. |
209 virtual void Destroy() OVERRIDE FINAL; | 234 virtual void Destroy() OVERRIDE FINAL; |
210 virtual void DidAttach() OVERRIDE FINAL; | 235 virtual void DidAttach() OVERRIDE FINAL; |
| 236 virtual void ElementSizeChanged(const gfx::Size& old_size, |
| 237 const gfx::Size& new_size) OVERRIDE FINAL; |
211 virtual int GetGuestInstanceID() const OVERRIDE; | 238 virtual int GetGuestInstanceID() const OVERRIDE; |
| 239 virtual void GuestSizeChanged(const gfx::Size& old_size, |
| 240 const gfx::Size& new_size) OVERRIDE FINAL; |
212 virtual void RegisterDestructionCallback( | 241 virtual void RegisterDestructionCallback( |
213 const DestructionCallback& callback) OVERRIDE FINAL; | 242 const DestructionCallback& callback) OVERRIDE FINAL; |
214 virtual void WillAttach( | 243 virtual void WillAttach( |
215 content::WebContents* embedder_web_contents, | 244 content::WebContents* embedder_web_contents, |
216 const base::DictionaryValue& extra_params) OVERRIDE FINAL; | 245 const base::DictionaryValue& extra_params) OVERRIDE FINAL; |
217 | 246 |
218 // Dispatches an event |event_name| to the embedder with the |event| fields. | 247 // Dispatches an event |event_name| to the embedder with the |event| fields. |
219 void DispatchEventToEmbedder(Event* event); | 248 void DispatchEventToEmbedder(Event* event); |
220 | 249 |
221 protected: | 250 protected: |
(...skipping 10 matching lines...) Expand all Loading... |
232 void CompleteInit(const std::string& embedder_extension_id, | 261 void CompleteInit(const std::string& embedder_extension_id, |
233 int embedder_render_process_id, | 262 int embedder_render_process_id, |
234 const WebContentsCreatedCallback& callback, | 263 const WebContentsCreatedCallback& callback, |
235 content::WebContents* guest_web_contents); | 264 content::WebContents* guest_web_contents); |
236 | 265 |
237 static void RegisterGuestViewTypes(); | 266 static void RegisterGuestViewTypes(); |
238 | 267 |
239 // WebContentsObserver implementation. | 268 // WebContentsObserver implementation. |
240 virtual void DidStopLoading( | 269 virtual void DidStopLoading( |
241 content::RenderViewHost* render_view_host) OVERRIDE FINAL; | 270 content::RenderViewHost* render_view_host) OVERRIDE FINAL; |
| 271 virtual void RenderViewReady() OVERRIDE FINAL; |
242 virtual void WebContentsDestroyed() OVERRIDE FINAL; | 272 virtual void WebContentsDestroyed() OVERRIDE FINAL; |
243 | 273 |
244 // WebContentsDelegate implementation. | 274 // WebContentsDelegate implementation. |
245 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; | 275 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; |
246 virtual bool PreHandleGestureEvent( | 276 virtual bool PreHandleGestureEvent( |
247 content::WebContents* source, | 277 content::WebContents* source, |
248 const blink::WebGestureEvent& event) OVERRIDE FINAL; | 278 const blink::WebGestureEvent& event) OVERRIDE FINAL; |
249 | 279 |
250 content::WebContents* embedder_web_contents_; | 280 content::WebContents* embedder_web_contents_; |
251 std::string embedder_extension_id_; | 281 std::string embedder_extension_id_; |
(...skipping 18 matching lines...) Expand all Loading... |
270 DestructionCallback destruction_callback_; | 300 DestructionCallback destruction_callback_; |
271 | 301 |
272 // The extra parameters associated with this GuestView passed | 302 // The extra parameters associated with this GuestView passed |
273 // in from JavaScript. This will typically be the view instance ID, | 303 // in from JavaScript. This will typically be the view instance ID, |
274 // the API to use, and view-specific parameters. These parameters | 304 // the API to use, and view-specific parameters. These parameters |
275 // are passed along to new guests that are created from this guest. | 305 // are passed along to new guests that are created from this guest. |
276 scoped_ptr<base::DictionaryValue> extra_params_; | 306 scoped_ptr<base::DictionaryValue> extra_params_; |
277 | 307 |
278 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 308 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
279 | 309 |
| 310 // The size of the container element. |
| 311 gfx::Size element_size_; |
| 312 |
| 313 // The size of the guest content. Note: In autosize mode, the container |
| 314 // element may not match the size of the guest. |
| 315 gfx::Size guest_size_; |
| 316 |
| 317 // Indicates whether autosize mode is enabled or not. |
| 318 bool auto_size_enabled_; |
| 319 |
| 320 // The maximum size constraints of the container element in autosize mode. |
| 321 gfx::Size max_auto_size_; |
| 322 |
| 323 // The minimum size constraints of the container element in autosize mode. |
| 324 gfx::Size min_auto_size_; |
| 325 |
280 // This is used to ensure pending tasks will not fire after this object is | 326 // This is used to ensure pending tasks will not fire after this object is |
281 // destroyed. | 327 // destroyed. |
282 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 328 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
283 | 329 |
284 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 330 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
285 }; | 331 }; |
286 | 332 |
287 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 333 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
OLD | NEW |