| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" | 5 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" |
| 6 | 6 |
| 7 #include "chrome/browser/platform_util.h" | 7 #include "chrome/browser/platform_util.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "components/web_modal/web_contents_modal_dialog_host.h" | 9 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 10 #include "extensions/browser/guest_view/guest_view_base.h" | |
| 11 | 10 |
| 12 namespace { | 11 namespace { |
| 13 | 12 |
| 14 class ChromeConstrainedWindowViewsClient | 13 class ChromeConstrainedWindowViewsClient |
| 15 : public constrained_window::ConstrainedWindowViewsClient { | 14 : public constrained_window::ConstrainedWindowViewsClient { |
| 16 public: | 15 public: |
| 17 ChromeConstrainedWindowViewsClient() {} | 16 ChromeConstrainedWindowViewsClient() {} |
| 18 ~ChromeConstrainedWindowViewsClient() override {} | 17 ~ChromeConstrainedWindowViewsClient() override {} |
| 19 | 18 |
| 20 private: | 19 private: |
| 21 // ConstrainedWindowViewsClient: | 20 // ConstrainedWindowViewsClient: |
| 22 content::WebContents* GetEmbedderWebContents( | |
| 23 content::WebContents* initiator_web_contents) override { | |
| 24 return extensions::GuestViewBase::GetTopLevelWebContents( | |
| 25 initiator_web_contents); | |
| 26 } | |
| 27 web_modal::ModalDialogHost* GetModalDialogHost( | 21 web_modal::ModalDialogHost* GetModalDialogHost( |
| 28 gfx::NativeWindow parent) override { | 22 gfx::NativeWindow parent) override { |
| 29 // Get the browser dialog management and hosting components from |parent|. | 23 // Get the browser dialog management and hosting components from |parent|. |
| 30 Browser* browser = chrome::FindBrowserWithWindow(parent); | 24 Browser* browser = chrome::FindBrowserWithWindow(parent); |
| 31 if (browser) { | 25 if (browser) { |
| 32 ChromeWebModalDialogManagerDelegate* manager = browser; | 26 ChromeWebModalDialogManagerDelegate* manager = browser; |
| 33 return manager->GetWebContentsModalDialogHost(); | 27 return manager->GetWebContentsModalDialogHost(); |
| 34 } | 28 } |
| 35 return nullptr; | 29 return nullptr; |
| 36 } | 30 } |
| 37 gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override { | 31 gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override { |
| 38 return platform_util::GetViewForWindow(parent); | 32 return platform_util::GetViewForWindow(parent); |
| 39 } | 33 } |
| 40 | 34 |
| 41 DISALLOW_COPY_AND_ASSIGN(ChromeConstrainedWindowViewsClient); | 35 DISALLOW_COPY_AND_ASSIGN(ChromeConstrainedWindowViewsClient); |
| 42 }; | 36 }; |
| 43 | 37 |
| 44 } // namespace | 38 } // namespace |
| 45 | 39 |
| 46 scoped_ptr<constrained_window::ConstrainedWindowViewsClient> | 40 scoped_ptr<constrained_window::ConstrainedWindowViewsClient> |
| 47 CreateChromeConstrainedWindowViewsClient() { | 41 CreateChromeConstrainedWindowViewsClient() { |
| 48 return make_scoped_ptr(new ChromeConstrainedWindowViewsClient); | 42 return make_scoped_ptr(new ChromeConstrainedWindowViewsClient); |
| 49 } | 43 } |
| OLD | NEW |