OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/printing/print_preview_test.h" | 5 #include "chrome/browser/printing/print_preview_test.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_iterator.h" | 8 #include "chrome/browser/ui/browser_iterator.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
10 #include "chrome/test/base/test_browser_window.h" | 10 #include "chrome/test/base/test_browser_window.h" |
11 #include "components/web_modal/web_contents_modal_dialog_host.h" | 11 #include "components/web_modal/web_contents_modal_dialog_host.h" |
12 #include "content/public/browser/plugin_service.h" | 12 #include "content/public/browser/plugin_service.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 | 14 |
15 using web_modal::WebContentsModalDialogHost; | 15 using web_modal::WebContentsModalDialogHost; |
16 using web_modal::ModalDialogHostObserver; | 16 using web_modal::ModalDialogHostObserver; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // Use a custom test browser window to provide a parent view to the print | 20 // Use a custom test browser window to provide a parent view to the print |
21 // preview dialog. | 21 // preview dialog. |
22 class PrintPreviewTestBrowserWindow | 22 class PrintPreviewTestBrowserWindow |
23 : public TestBrowserWindow, | 23 : public TestBrowserWindow, |
24 public WebContentsModalDialogHost { | 24 public WebContentsModalDialogHost { |
25 public: | 25 public: |
26 PrintPreviewTestBrowserWindow() {} | 26 PrintPreviewTestBrowserWindow() {} |
27 | 27 |
28 // BrowserWindow overrides | 28 // BrowserWindow overrides |
29 virtual WebContentsModalDialogHost* GetWebContentsModalDialogHost() override { | 29 WebContentsModalDialogHost* GetWebContentsModalDialogHost() override { |
30 return this; | 30 return this; |
31 } | 31 } |
32 | 32 |
33 // WebContentsModalDialogHost overrides | 33 // WebContentsModalDialogHost overrides |
34 | 34 |
35 // The web contents modal dialog must be parented to *something*; use the | 35 // The web contents modal dialog must be parented to *something*; use the |
36 // WebContents window since there is no true browser window for unit tests. | 36 // WebContents window since there is no true browser window for unit tests. |
37 virtual gfx::NativeView GetHostView() const override { | 37 gfx::NativeView GetHostView() const override { |
38 return FindBrowser()->tab_strip_model()->GetActiveWebContents()-> | 38 return FindBrowser()->tab_strip_model()->GetActiveWebContents()-> |
39 GetNativeView(); | 39 GetNativeView(); |
40 } | 40 } |
41 | 41 |
42 virtual gfx::Point GetDialogPosition(const gfx::Size& size) override { | 42 gfx::Point GetDialogPosition(const gfx::Size& size) override { |
43 return gfx::Point(); | 43 return gfx::Point(); |
44 } | 44 } |
45 | 45 |
46 virtual gfx::Size GetMaximumDialogSize() override { | 46 gfx::Size GetMaximumDialogSize() override { return gfx::Size(); } |
47 return gfx::Size(); | |
48 } | |
49 | 47 |
50 virtual void AddObserver( | 48 void AddObserver(ModalDialogHostObserver* observer) override {} |
51 ModalDialogHostObserver* observer) override {} | 49 void RemoveObserver(ModalDialogHostObserver* observer) override {} |
52 virtual void RemoveObserver( | |
53 ModalDialogHostObserver* observer) override {} | |
54 | 50 |
55 private: | 51 private: |
56 Browser* FindBrowser() const { | 52 Browser* FindBrowser() const { |
57 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 53 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
58 Browser* browser = *it; | 54 Browser* browser = *it; |
59 if (browser->window() == this) | 55 if (browser->window() == this) |
60 return browser; | 56 return browser; |
61 } | 57 } |
62 NOTREACHED(); | 58 NOTREACHED(); |
63 return NULL; | 59 return NULL; |
(...skipping 11 matching lines...) Expand all Loading... |
75 | 71 |
76 // The PluginService will be destroyed at the end of the test (due to the | 72 // The PluginService will be destroyed at the end of the test (due to the |
77 // ShadowingAtExitManager in our base class). | 73 // ShadowingAtExitManager in our base class). |
78 content::PluginService::GetInstance()->Init(); | 74 content::PluginService::GetInstance()->Init(); |
79 content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting(); | 75 content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting(); |
80 } | 76 } |
81 | 77 |
82 BrowserWindow* PrintPreviewTest::CreateBrowserWindow() { | 78 BrowserWindow* PrintPreviewTest::CreateBrowserWindow() { |
83 return new PrintPreviewTestBrowserWindow; | 79 return new PrintPreviewTestBrowserWindow; |
84 } | 80 } |
OLD | NEW |