Durable Storage: Refactor browser test and test the basic "deny" flow.
[chromium-blink-merge.git] / chrome / test / base / dialog_test_browser_window.cc
blob5328cb9d9b0ea7707fffd5e6441f4848e30dd2ee
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() {
24 return this;
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 {
30 return FindBrowser()
31 ->tab_strip_model()
32 ->GetActiveWebContents()
33 ->GetNativeView();
36 gfx::Point DialogTestBrowserWindow::GetDialogPosition(const gfx::Size& size) {
37 return gfx::Point();
40 gfx::Size DialogTestBrowserWindow::GetMaximumDialogSize() {
41 return gfx::Size();
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)
55 return browser;
57 NOTREACHED();
58 return nullptr;