OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
6 | 6 |
7 #import "content/browser/web_contents/web_contents_view_mac.h" | 7 #import "content/browser/web_contents/web_contents_view_mac.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 } | 277 } |
278 | 278 |
279 void WebContentsViewMac::CreateView( | 279 void WebContentsViewMac::CreateView( |
280 const gfx::Size& initial_size, gfx::NativeView context) { | 280 const gfx::Size& initial_size, gfx::NativeView context) { |
281 WebContentsViewCocoa* view = | 281 WebContentsViewCocoa* view = |
282 [[WebContentsViewCocoa alloc] initWithWebContentsViewMac:this]; | 282 [[WebContentsViewCocoa alloc] initWithWebContentsViewMac:this]; |
283 cocoa_view_.reset(view); | 283 cocoa_view_.reset(view); |
284 } | 284 } |
285 | 285 |
286 RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForWidget( | 286 RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForWidget( |
287 RenderWidgetHost* render_widget_host) { | 287 RenderWidgetHost* render_widget_host, bool is_guest_view_hack) { |
288 if (render_widget_host->GetView()) { | 288 if (render_widget_host->GetView()) { |
289 // During testing, the view will already be set up in most cases to the | 289 // During testing, the view will already be set up in most cases to the |
290 // test view, so we don't want to clobber it with a real one. To verify that | 290 // test view, so we don't want to clobber it with a real one. To verify that |
291 // this actually is happening (and somebody isn't accidentally creating the | 291 // this actually is happening (and somebody isn't accidentally creating the |
292 // view twice), we check for the RVH Factory, which will be set when we're | 292 // view twice), we check for the RVH Factory, which will be set when we're |
293 // making special ones (which go along with the special views). | 293 // making special ones (which go along with the special views). |
294 DCHECK(RenderViewHostFactory::has_factory()); | 294 DCHECK(RenderViewHostFactory::has_factory()); |
295 return static_cast<RenderWidgetHostViewBase*>( | 295 return static_cast<RenderWidgetHostViewBase*>( |
296 render_widget_host->GetView()); | 296 render_widget_host->GetView()); |
297 } | 297 } |
298 | 298 |
299 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac( | 299 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac( |
300 render_widget_host); | 300 render_widget_host, is_guest_view_hack); |
301 if (delegate()) { | 301 if (!is_guest_view_hack && delegate()) { |
lazyboy
2014/10/16 06:14:24
I needed to add this check here to fix mac crash.
piman
2014/10/16 20:47:47
I'm no mac expert, not fully sure about everything
lazyboy
2014/10/17 00:46:00
I've done #2, check for GetView() before using it.
| |
302 base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate> > | 302 base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate> > |
303 rw_delegate( | 303 rw_delegate( |
304 delegate()->CreateRenderWidgetHostViewDelegate(render_widget_host)); | 304 delegate()->CreateRenderWidgetHostViewDelegate(render_widget_host)); |
305 | 305 |
306 view->SetDelegate(rw_delegate.get()); | 306 view->SetDelegate(rw_delegate.get()); |
307 } | 307 } |
308 view->SetAllowPauseForResizeOrRepaint(!allow_other_views_); | 308 view->SetAllowPauseForResizeOrRepaint(!allow_other_views_); |
309 | 309 |
310 // Fancy layout comes later; for now just make it our size and resize it | 310 // Fancy layout comes later; for now just make it our size and resize it |
311 // with us. In case there are other siblings of the content area, we want | 311 // with us. In case there are other siblings of the content area, we want |
(...skipping 12 matching lines...) Expand all Loading... | |
324 // added. On 10.6 things magically work fine; on 10.5 they fail | 324 // added. On 10.6 things magically work fine; on 10.5 they fail |
325 // <http://crbug.com/61493>. Digging into Cocoa key view loop code yielded | 325 // <http://crbug.com/61493>. Digging into Cocoa key view loop code yielded |
326 // madness; TODO(avi,rohit): look at this again and figure out what's really | 326 // madness; TODO(avi,rohit): look at this again and figure out what's really |
327 // going on. | 327 // going on. |
328 [cocoa_view_.get() setNextKeyView:view_view]; | 328 [cocoa_view_.get() setNextKeyView:view_view]; |
329 return view; | 329 return view; |
330 } | 330 } |
331 | 331 |
332 RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForPopupWidget( | 332 RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForPopupWidget( |
333 RenderWidgetHost* render_widget_host) { | 333 RenderWidgetHost* render_widget_host) { |
334 return new RenderWidgetHostViewMac(render_widget_host); | 334 return new RenderWidgetHostViewMac(render_widget_host, false); |
335 } | 335 } |
336 | 336 |
337 void WebContentsViewMac::SetPageTitle(const base::string16& title) { | 337 void WebContentsViewMac::SetPageTitle(const base::string16& title) { |
338 // Meaningless on the Mac; widgets don't have a "title" attribute | 338 // Meaningless on the Mac; widgets don't have a "title" attribute |
339 } | 339 } |
340 | 340 |
341 | 341 |
342 void WebContentsViewMac::RenderViewCreated(RenderViewHost* host) { | 342 void WebContentsViewMac::RenderViewCreated(RenderViewHost* host) { |
343 // We want updates whenever the intrinsic width of the webpage changes. | 343 // We want updates whenever the intrinsic width of the webpage changes. |
344 // Put the RenderView into that mode. The preferred width is used for example | 344 // Put the RenderView into that mode. The preferred width is used for example |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 // When the subviews require a layout, their size should be reset to the size | 577 // When the subviews require a layout, their size should be reset to the size |
578 // of this view. (It is possible for the size to get out of sync as an | 578 // of this view. (It is possible for the size to get out of sync as an |
579 // optimization in preparation for an upcoming WebContentsView resize. | 579 // optimization in preparation for an upcoming WebContentsView resize. |
580 // http://crbug.com/264207) | 580 // http://crbug.com/264207) |
581 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { | 581 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { |
582 for (NSView* subview in self.subviews) | 582 for (NSView* subview in self.subviews) |
583 [subview setFrame:self.bounds]; | 583 [subview setFrame:self.bounds]; |
584 } | 584 } |
585 | 585 |
586 @end | 586 @end |
OLD | NEW |