Chromium Code Reviews| Index: chrome/browser/ui/views/chrome_constrained_window_views_client.cc |
| diff --git a/chrome/browser/ui/views/chrome_constrained_window_views_client.cc b/chrome/browser/ui/views/chrome_constrained_window_views_client.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..77cfe13540236a5dacb1dc77177841ad5fe2ef6e |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/chrome_constrained_window_views_client.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" |
| + |
| +#include "chrome/browser/ui/browser_finder.h" |
| +#include "components/constrained_window/constrained_window_views_client.h" |
|
msw
2014/10/22 21:32:43
nit: not needed if included by the header.
oshima
2014/10/22 22:39:08
Done.
|
| +#include "components/web_modal/web_contents_modal_dialog_host.h" |
| +#include "extensions/browser/guest_view/guest_view_base.h" |
| + |
| +namespace { |
| + |
| +class ChromeConstrainedWindowViewsClient |
| + : public ConstrainedWindowViewsClient { |
| + public: |
| + ChromeConstrainedWindowViewsClient() {} |
| + virtual ~ChromeConstrainedWindowViewsClient() {} |
|
msw
2014/10/22 21:32:43
nit: virtual -> override (or final?) here and belo
oshima
2014/10/22 22:39:08
Oh, i didn't know about it. done.
|
| + |
| + private: |
| + // ConstrainedWindowViewsClient: |
| + virtual content::WebContents* GetEmbedderWebContents( |
| + content::WebContents* initiator_web_contents) override { |
| + extensions::GuestViewBase* guest_view = |
| + extensions::GuestViewBase::FromWebContents(initiator_web_contents); |
| + return guest_view && guest_view->embedder_web_contents() ? |
| + guest_view->embedder_web_contents() : initiator_web_contents; |
| + } |
| + virtual web_modal::ModalDialogHost* GetModalDialogHost( |
| + gfx::NativeWindow parent) override { |
| + // Get the browser dialog management and hosting components from |parent|. |
| + Browser* browser = chrome::FindBrowserWithWindow(parent); |
| + if (browser) { |
|
msw
2014/10/22 21:32:43
nit: return browser ? browser->GetWebContentsModal
oshima
2014/10/22 22:39:08
GetWebContentsModalDialogHost is private on Browse
msw
2014/10/23 18:49:05
Ahhhh, got it! This is fine as-is.
|
| + ChromeWebModalDialogManagerDelegate* manager = browser; |
| + return manager->GetWebContentsModalDialogHost(); |
| + } |
| + return NULL; |
| + } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ChromeConstrainedWindowViewsClient); |
| +}; |
| + |
| +} // namespace |
| + |
| +scoped_ptr<ConstrainedWindowViewsClient> |
| +CreateChromeConstrainedWindowViewsClient() { |
| + return make_scoped_ptr(new ChromeConstrainedWindowViewsClient); |
| +} |