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

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

Issue 427883002: <webview>: Move autosize from content to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_frame_url
Patch Set: Code cleanup Created 6 years, 4 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
106 // This method queries whether drag-and-drop is enabled for this particular 121 // 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 122 // view. By default, drag-and-drop is disabled. Derived classes can override
108 // this behavior to enable drag-and-drop. 123 // this behavior to enable drag-and-drop.
109 virtual bool IsDragAndDropEnabled() const; 124 virtual bool IsDragAndDropEnabled() const;
110 125
111 // This method is called immediately before suspended resource loads have been 126 // This method is called immediately before suspended resource loads have been
112 // resumed on attachment to an embedder. 127 // resumed on attachment to an embedder.
113 // 128 //
114 // This method can be overriden by subclasses. This gives the derived class 129 // This method can be overriden by subclasses. This gives the derived class
115 // an opportunity to perform setup actions before attachment. 130 // an opportunity to perform setup actions before attachment.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 162
148 void InitWithWebContents( 163 void InitWithWebContents(
149 const std::string& embedder_extension_id, 164 const std::string& embedder_extension_id,
150 int embedder_render_process_id, 165 int embedder_render_process_id,
151 content::WebContents* guest_web_contents); 166 content::WebContents* guest_web_contents);
152 167
153 bool IsViewType(const char* const view_type) const { 168 bool IsViewType(const char* const view_type) const {
154 return !strcmp(GetViewType(), view_type); 169 return !strcmp(GetViewType(), view_type);
155 } 170 }
156 171
172 // Toggles autosize mode for this GuestView.
173 void SetAutoSize(bool enabled,
174 const gfx::Size& min_size,
175 const gfx::Size& max_size);
176
157 base::WeakPtr<GuestViewBase> AsWeakPtr(); 177 base::WeakPtr<GuestViewBase> AsWeakPtr();
158 178
159 bool initialized() const { return initialized_; } 179 bool initialized() const { return initialized_; }
160 180
161 content::WebContents* embedder_web_contents() const { 181 content::WebContents* embedder_web_contents() const {
162 return embedder_web_contents_; 182 return embedder_web_contents_;
163 } 183 }
164 184
165 // Returns the guest WebContents. 185 // Returns the guest WebContents.
166 content::WebContents* guest_web_contents() const { 186 content::WebContents* guest_web_contents() const {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 221
202 // RenderProcessHostObserver implementation 222 // RenderProcessHostObserver implementation
203 virtual void RenderProcessExited(content::RenderProcessHost* host, 223 virtual void RenderProcessExited(content::RenderProcessHost* host,
204 base::ProcessHandle handle, 224 base::ProcessHandle handle,
205 base::TerminationStatus status, 225 base::TerminationStatus status,
206 int exit_code) OVERRIDE; 226 int exit_code) OVERRIDE;
207 227
208 // BrowserPluginGuestDelegate implementation. 228 // BrowserPluginGuestDelegate implementation.
209 virtual void Destroy() OVERRIDE FINAL; 229 virtual void Destroy() OVERRIDE FINAL;
210 virtual void DidAttach() OVERRIDE FINAL; 230 virtual void DidAttach() OVERRIDE FINAL;
231 virtual void ElementSizeChanged(const gfx::Size& old_size,
232 const gfx::Size& new_size) OVERRIDE FINAL;
211 virtual int GetGuestInstanceID() const OVERRIDE; 233 virtual int GetGuestInstanceID() const OVERRIDE;
234 virtual void GuestSizeChanged(const gfx::Size& old_size,
235 const gfx::Size& new_size) OVERRIDE FINAL;
212 virtual void RegisterDestructionCallback( 236 virtual void RegisterDestructionCallback(
213 const DestructionCallback& callback) OVERRIDE FINAL; 237 const DestructionCallback& callback) OVERRIDE FINAL;
214 virtual void WillAttach( 238 virtual void WillAttach(
215 content::WebContents* embedder_web_contents, 239 content::WebContents* embedder_web_contents,
216 const base::DictionaryValue& extra_params) OVERRIDE FINAL; 240 const base::DictionaryValue& extra_params) OVERRIDE FINAL;
217 241
218 // Dispatches an event |event_name| to the embedder with the |event| fields. 242 // Dispatches an event |event_name| to the embedder with the |event| fields.
219 void DispatchEventToEmbedder(Event* event); 243 void DispatchEventToEmbedder(Event* event);
220 244
221 protected: 245 protected:
(...skipping 10 matching lines...) Expand all
232 void CompleteInit(const std::string& embedder_extension_id, 256 void CompleteInit(const std::string& embedder_extension_id,
233 int embedder_render_process_id, 257 int embedder_render_process_id,
234 const WebContentsCreatedCallback& callback, 258 const WebContentsCreatedCallback& callback,
235 content::WebContents* guest_web_contents); 259 content::WebContents* guest_web_contents);
236 260
237 static void RegisterGuestViewTypes(); 261 static void RegisterGuestViewTypes();
238 262
239 // WebContentsObserver implementation. 263 // WebContentsObserver implementation.
240 virtual void DidStopLoading( 264 virtual void DidStopLoading(
241 content::RenderViewHost* render_view_host) OVERRIDE FINAL; 265 content::RenderViewHost* render_view_host) OVERRIDE FINAL;
266 virtual void RenderViewReady() OVERRIDE FINAL;
242 virtual void WebContentsDestroyed() OVERRIDE FINAL; 267 virtual void WebContentsDestroyed() OVERRIDE FINAL;
243 268
244 // WebContentsDelegate implementation. 269 // WebContentsDelegate implementation.
245 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; 270 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL;
246 virtual bool PreHandleGestureEvent( 271 virtual bool PreHandleGestureEvent(
247 content::WebContents* source, 272 content::WebContents* source,
248 const blink::WebGestureEvent& event) OVERRIDE FINAL; 273 const blink::WebGestureEvent& event) OVERRIDE FINAL;
249 274
250 content::WebContents* embedder_web_contents_; 275 content::WebContents* embedder_web_contents_;
251 std::string embedder_extension_id_; 276 std::string embedder_extension_id_;
(...skipping 18 matching lines...) Expand all
270 DestructionCallback destruction_callback_; 295 DestructionCallback destruction_callback_;
271 296
272 // The extra parameters associated with this GuestView passed 297 // The extra parameters associated with this GuestView passed
273 // in from JavaScript. This will typically be the view instance ID, 298 // in from JavaScript. This will typically be the view instance ID,
274 // the API to use, and view-specific parameters. These parameters 299 // the API to use, and view-specific parameters. These parameters
275 // are passed along to new guests that are created from this guest. 300 // are passed along to new guests that are created from this guest.
276 scoped_ptr<base::DictionaryValue> extra_params_; 301 scoped_ptr<base::DictionaryValue> extra_params_;
277 302
278 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; 303 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_;
279 304
305 // The size of the container element.
306 gfx::Size element_size_;
307
308 // The size of the guest content. Note: In autosize mode, the container
309 // elemen may not match the size of the guest.
310 gfx::Size guest_size_;
311
312 // Indicates whether autosize mode is enabled or not.
313 bool auto_size_enabled_;
314
315 // The maximum size constraints of the container element in autosize mode.
316 gfx::Size max_auto_size_;
317
318 // The minimum size constraints of the container element in autosize mode.
319 gfx::Size min_auto_size_;
320
280 // This is used to ensure pending tasks will not fire after this object is 321 // This is used to ensure pending tasks will not fire after this object is
281 // destroyed. 322 // destroyed.
282 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; 323 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
283 324
284 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); 325 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
285 }; 326 };
286 327
287 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 328 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698