Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / chrome_constrained_window_views_client.cc
bloba9ca4d93ffa50bf81a1a9fd1f034afc7fbed2265
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"
11 namespace {
13 class ChromeConstrainedWindowViewsClient
14 : public constrained_window::ConstrainedWindowViewsClient {
15 public:
16 ChromeConstrainedWindowViewsClient() {}
17 ~ChromeConstrainedWindowViewsClient() override {}
19 private:
20 // ConstrainedWindowViewsClient:
21 web_modal::ModalDialogHost* GetModalDialogHost(
22 gfx::NativeWindow parent) override {
23 // Get the browser dialog management and hosting components from |parent|.
24 Browser* browser = chrome::FindBrowserWithWindow(parent);
25 if (browser) {
26 ChromeWebModalDialogManagerDelegate* manager = browser;
27 return manager->GetWebContentsModalDialogHost();
29 return nullptr;
31 gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override {
32 return platform_util::GetViewForWindow(parent);
35 DISALLOW_COPY_AND_ASSIGN(ChromeConstrainedWindowViewsClient);
38 } // namespace
40 scoped_ptr<constrained_window::ConstrainedWindowViewsClient>
41 CreateChromeConstrainedWindowViewsClient() {
42 return make_scoped_ptr(new ChromeConstrainedWindowViewsClient);