1 // Copyright 2015 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/test/base/dialog_test_browser_window.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_iterator.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "content/public/browser/web_contents.h"
12 using web_modal::WebContentsModalDialogHost
;
13 using web_modal::ModalDialogHostObserver
;
15 DialogTestBrowserWindow::DialogTestBrowserWindow() {
18 DialogTestBrowserWindow::~DialogTestBrowserWindow() {
22 WebContentsModalDialogHost
*
23 DialogTestBrowserWindow::GetWebContentsModalDialogHost() {
27 // The web contents modal dialog must be parented to *something*; use the
28 // WebContents window since there is no true browser window for unit tests.
29 gfx::NativeView
DialogTestBrowserWindow::GetHostView() const {
32 ->GetActiveWebContents()
36 gfx::Point
DialogTestBrowserWindow::GetDialogPosition(const gfx::Size
& size
) {
40 gfx::Size
DialogTestBrowserWindow::GetMaximumDialogSize() {
44 void DialogTestBrowserWindow::AddObserver(ModalDialogHostObserver
* observer
) {
47 void DialogTestBrowserWindow::RemoveObserver(
48 ModalDialogHostObserver
* observer
) {
51 Browser
* DialogTestBrowserWindow::FindBrowser() const {
52 for (chrome::BrowserIterator it
; !it
.done(); it
.Next()) {
53 Browser
* browser
= *it
;
54 if (browser
->window() == this)