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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h"
7 #include "chrome/browser/platform_util.h"
8 #include "chrome/browser/ui/browser_finder.h"
9 #include "components/web_modal/web_contents_modal_dialog_host.h"
10 #include "extensions/browser/guest_view/guest_view_base.h"
14 class ChromeConstrainedWindowViewsClient
15 : public constrained_window::ConstrainedWindowViewsClient
{
17 ChromeConstrainedWindowViewsClient() {}
18 ~ChromeConstrainedWindowViewsClient() override
{}
21 // ConstrainedWindowViewsClient:
22 content::WebContents
* GetEmbedderWebContents(
23 content::WebContents
* initiator_web_contents
) override
{
24 extensions::GuestViewBase
* guest_view
=
25 extensions::GuestViewBase::FromWebContents(initiator_web_contents
);
26 return guest_view
&& guest_view
->embedder_web_contents() ?
27 guest_view
->embedder_web_contents() : initiator_web_contents
;
29 web_modal::ModalDialogHost
* GetModalDialogHost(
30 gfx::NativeWindow parent
) override
{
31 // Get the browser dialog management and hosting components from |parent|.
32 Browser
* browser
= chrome::FindBrowserWithWindow(parent
);
34 ChromeWebModalDialogManagerDelegate
* manager
= browser
;
35 return manager
->GetWebContentsModalDialogHost();
39 gfx::NativeView
GetDialogHostView(gfx::NativeWindow parent
) override
{
40 return platform_util::GetViewForWindow(parent
);
43 DISALLOW_COPY_AND_ASSIGN(ChromeConstrainedWindowViewsClient
);
48 scoped_ptr
<constrained_window::ConstrainedWindowViewsClient
>
49 CreateChromeConstrainedWindowViewsClient() {
50 return make_scoped_ptr(new ChromeConstrainedWindowViewsClient
);