| 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 | |
| 126 // This method queries whether drag-and-drop is enabled for this particular | 106 // This method queries whether drag-and-drop is enabled for this particular |
| 127 // view. By default, drag-and-drop is disabled. Derived classes can override | 107 // view. By default, drag-and-drop is disabled. Derived classes can override |
| 128 // this behavior to enable drag-and-drop. | 108 // this behavior to enable drag-and-drop. |
| 129 virtual bool IsDragAndDropEnabled() const; | 109 virtual bool IsDragAndDropEnabled() const; |
| 130 | 110 |
| 131 // This method is called immediately before suspended resource loads have been | 111 // This method is called immediately before suspended resource loads have been |
| 132 // resumed on attachment to an embedder. | 112 // resumed on attachment to an embedder. |
| 133 // | 113 // |
| 134 // This method can be overriden by subclasses. This gives the derived class | 114 // This method can be overriden by subclasses. This gives the derived class |
| 135 // an opportunity to perform setup actions before attachment. | 115 // an opportunity to perform setup actions before attachment. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 147 |
| 168 void InitWithWebContents( | 148 void InitWithWebContents( |
| 169 const std::string& embedder_extension_id, | 149 const std::string& embedder_extension_id, |
| 170 int embedder_render_process_id, | 150 int embedder_render_process_id, |
| 171 content::WebContents* guest_web_contents); | 151 content::WebContents* guest_web_contents); |
| 172 | 152 |
| 173 bool IsViewType(const char* const view_type) const { | 153 bool IsViewType(const char* const view_type) const { |
| 174 return !strcmp(GetViewType(), view_type); | 154 return !strcmp(GetViewType(), view_type); |
| 175 } | 155 } |
| 176 | 156 |
| 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 | |
| 182 base::WeakPtr<GuestViewBase> AsWeakPtr(); | 157 base::WeakPtr<GuestViewBase> AsWeakPtr(); |
| 183 | 158 |
| 184 bool initialized() const { return initialized_; } | 159 bool initialized() const { return initialized_; } |
| 185 | 160 |
| 186 content::WebContents* embedder_web_contents() const { | 161 content::WebContents* embedder_web_contents() const { |
| 187 return embedder_web_contents_; | 162 return embedder_web_contents_; |
| 188 } | 163 } |
| 189 | 164 |
| 190 // Returns the guest WebContents. | 165 // Returns the guest WebContents. |
| 191 content::WebContents* guest_web_contents() const { | 166 content::WebContents* guest_web_contents() const { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 201 |
| 227 // RenderProcessHostObserver implementation | 202 // RenderProcessHostObserver implementation |
| 228 virtual void RenderProcessExited(content::RenderProcessHost* host, | 203 virtual void RenderProcessExited(content::RenderProcessHost* host, |
| 229 base::ProcessHandle handle, | 204 base::ProcessHandle handle, |
| 230 base::TerminationStatus status, | 205 base::TerminationStatus status, |
| 231 int exit_code) OVERRIDE; | 206 int exit_code) OVERRIDE; |
| 232 | 207 |
| 233 // BrowserPluginGuestDelegate implementation. | 208 // BrowserPluginGuestDelegate implementation. |
| 234 virtual void Destroy() OVERRIDE FINAL; | 209 virtual void Destroy() OVERRIDE FINAL; |
| 235 virtual void DidAttach() OVERRIDE FINAL; | 210 virtual void DidAttach() OVERRIDE FINAL; |
| 236 virtual void ElementSizeChanged(const gfx::Size& old_size, | |
| 237 const gfx::Size& new_size) OVERRIDE FINAL; | |
| 238 virtual int GetGuestInstanceID() const OVERRIDE; | 211 virtual int GetGuestInstanceID() const OVERRIDE; |
| 239 virtual void GuestSizeChanged(const gfx::Size& old_size, | |
| 240 const gfx::Size& new_size) OVERRIDE FINAL; | |
| 241 virtual void RegisterDestructionCallback( | 212 virtual void RegisterDestructionCallback( |
| 242 const DestructionCallback& callback) OVERRIDE FINAL; | 213 const DestructionCallback& callback) OVERRIDE FINAL; |
| 243 virtual void WillAttach( | 214 virtual void WillAttach( |
| 244 content::WebContents* embedder_web_contents, | 215 content::WebContents* embedder_web_contents, |
| 245 const base::DictionaryValue& extra_params) OVERRIDE FINAL; | 216 const base::DictionaryValue& extra_params) OVERRIDE FINAL; |
| 246 | 217 |
| 247 // Dispatches an event |event_name| to the embedder with the |event| fields. | 218 // Dispatches an event |event_name| to the embedder with the |event| fields. |
| 248 void DispatchEventToEmbedder(Event* event); | 219 void DispatchEventToEmbedder(Event* event); |
| 249 | 220 |
| 250 protected: | 221 protected: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 261 void CompleteInit(const std::string& embedder_extension_id, | 232 void CompleteInit(const std::string& embedder_extension_id, |
| 262 int embedder_render_process_id, | 233 int embedder_render_process_id, |
| 263 const WebContentsCreatedCallback& callback, | 234 const WebContentsCreatedCallback& callback, |
| 264 content::WebContents* guest_web_contents); | 235 content::WebContents* guest_web_contents); |
| 265 | 236 |
| 266 static void RegisterGuestViewTypes(); | 237 static void RegisterGuestViewTypes(); |
| 267 | 238 |
| 268 // WebContentsObserver implementation. | 239 // WebContentsObserver implementation. |
| 269 virtual void DidStopLoading( | 240 virtual void DidStopLoading( |
| 270 content::RenderViewHost* render_view_host) OVERRIDE FINAL; | 241 content::RenderViewHost* render_view_host) OVERRIDE FINAL; |
| 271 virtual void RenderViewReady() OVERRIDE FINAL; | |
| 272 virtual void WebContentsDestroyed() OVERRIDE FINAL; | 242 virtual void WebContentsDestroyed() OVERRIDE FINAL; |
| 273 | 243 |
| 274 // WebContentsDelegate implementation. | 244 // WebContentsDelegate implementation. |
| 275 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; | 245 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; |
| 276 virtual bool PreHandleGestureEvent( | 246 virtual bool PreHandleGestureEvent( |
| 277 content::WebContents* source, | 247 content::WebContents* source, |
| 278 const blink::WebGestureEvent& event) OVERRIDE FINAL; | 248 const blink::WebGestureEvent& event) OVERRIDE FINAL; |
| 279 | 249 |
| 280 content::WebContents* embedder_web_contents_; | 250 content::WebContents* embedder_web_contents_; |
| 281 std::string embedder_extension_id_; | 251 std::string embedder_extension_id_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 300 DestructionCallback destruction_callback_; | 270 DestructionCallback destruction_callback_; |
| 301 | 271 |
| 302 // The extra parameters associated with this GuestView passed | 272 // The extra parameters associated with this GuestView passed |
| 303 // in from JavaScript. This will typically be the view instance ID, | 273 // in from JavaScript. This will typically be the view instance ID, |
| 304 // the API to use, and view-specific parameters. These parameters | 274 // the API to use, and view-specific parameters. These parameters |
| 305 // are passed along to new guests that are created from this guest. | 275 // are passed along to new guests that are created from this guest. |
| 306 scoped_ptr<base::DictionaryValue> extra_params_; | 276 scoped_ptr<base::DictionaryValue> extra_params_; |
| 307 | 277 |
| 308 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 278 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
| 309 | 279 |
| 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 | |
| 326 // This is used to ensure pending tasks will not fire after this object is | 280 // This is used to ensure pending tasks will not fire after this object is |
| 327 // destroyed. | 281 // destroyed. |
| 328 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 282 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
| 329 | 283 |
| 330 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 284 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
| 331 }; | 285 }; |
| 332 | 286 |
| 333 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 287 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| OLD | NEW |