• tapted's avatar
    Mac: Attach Extension NSViews to the view hierarchy before creating renderers · 836dc7a4
    tapted authored
    Extensions with background pages (e.g. Google Cast) currently have a
    shorter code path when showing an extension popup that can cause the
    renderer to ask for screen metrics before the hosting NSView is added to
    the view hierarchy. Since the NSWindow is nil in this case, screen
    metrics for the primary screen are used, and they may be the incorrect
    screen for the popup.
    
    On non-Mac, toolkit-views platforms get around this problem by deferring
    creation until View::ViewHierarchyChanged is triggered. However, there
    is no NSView apart from the render view on the extension-side on Mac, so
    to do the same we'd either need to add one (and keep it sized
    appropriately), or modify the WebContents view itself to override
    [NSView viewDid/WillMoveToSuperview] and feed it through to embedders.
    
    Instead, this CL tweaks the ExtensionPopupController initialization to
    always create the popup NSWindow (initially hidden), before creating the
    ExtensionViewHost.
    
    BUG=324748, 305620
    TEST=On a retina mac, plug in a (non-retina) external monitor, move
    Chrome there, and open the Chromecast dialog. It should look "nice" (not
    as nice as the retina screen, but consistent with other text in Chrome).
    See http://crbug.com/324748#c41
    
    Review URL: https://codereview.chromium.org/653843002
    
    Cr-Commit-Position: refs/heads/master@{#317011}
    836dc7a4
extension_view_views.h 3.82 KB