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/settings_window_manager.h" | 5 #include "chrome/browser/ui/settings_window_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
15 #include "chrome/browser/ui/browser_iterator.h" | 15 #include "chrome/browser/ui/browser_iterator.h" |
16 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
17 #include "chrome/browser/ui/chrome_pages.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
18 #include "chrome/browser/ui/settings_window_manager_observer.h" | 18 #include "chrome/browser/ui/settings_window_manager_observer.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
| 26 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 27 #include "base/mac/scoped_nsautorelease_pool.h" |
| 28 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 29 |
26 namespace { | 30 namespace { |
27 | 31 |
28 class SettingsWindowTestObserver | 32 class SettingsWindowTestObserver |
29 : public chrome::SettingsWindowManagerObserver { | 33 : public chrome::SettingsWindowManagerObserver { |
30 public: | 34 public: |
31 SettingsWindowTestObserver() : browser_(NULL), new_settings_count_(0) {} | 35 SettingsWindowTestObserver() : browser_(NULL), new_settings_count_(0) {} |
32 ~SettingsWindowTestObserver() override {} | 36 ~SettingsWindowTestObserver() override {} |
33 | 37 |
34 void OnNewSettingsWindow(Browser* settings_browser) override { | 38 void OnNewSettingsWindow(Browser* settings_browser) override { |
35 browser_ = settings_browser; | 39 browser_ = settings_browser; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void ShowSettingsForProfile(Profile* profile) { | 97 void ShowSettingsForProfile(Profile* profile) { |
94 settings_manager_->ShowChromePageForProfile( | 98 settings_manager_->ShowChromePageForProfile( |
95 profile, GURL(chrome::kChromeUISettingsURL)); | 99 profile, GURL(chrome::kChromeUISettingsURL)); |
96 } | 100 } |
97 | 101 |
98 void CloseBrowserSynchronously(Browser* browser) { | 102 void CloseBrowserSynchronously(Browser* browser) { |
99 content::WindowedNotificationObserver observer( | 103 content::WindowedNotificationObserver observer( |
100 chrome::NOTIFICATION_BROWSER_CLOSED, | 104 chrome::NOTIFICATION_BROWSER_CLOSED, |
101 content::NotificationService::AllSources()); | 105 content::NotificationService::AllSources()); |
102 browser->window()->Close(); | 106 browser->window()->Close(); |
| 107 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 108 AutoreleasePool()->Recycle(); |
| 109 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
103 observer.Wait(); | 110 observer.Wait(); |
104 } | 111 } |
105 | 112 |
106 void CloseNonDefaultBrowsers() { | 113 void CloseNonDefaultBrowsers() { |
107 std::list<Browser*> browsers_to_close; | 114 std::list<Browser*> browsers_to_close; |
108 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 115 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
109 if (*it != browser()) | 116 if (*it != browser()) |
110 browsers_to_close.push_back(*it); | 117 browsers_to_close.push_back(*it); |
111 } | 118 } |
112 for (std::list<Browser*>::iterator iter = browsers_to_close.begin(); | 119 for (std::list<Browser*>::iterator iter = browsers_to_close.begin(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 213 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
207 | 214 |
208 // Downloads should open in an existing browser window. | 215 // Downloads should open in an existing browser window. |
209 chrome::ShowDownloads(browser()); | 216 chrome::ShowDownloads(browser()); |
210 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 217 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
211 | 218 |
212 // About should open a new browser window. | 219 // About should open a new browser window. |
213 chrome::ShowAboutChrome(browser()); | 220 chrome::ShowAboutChrome(browser()); |
214 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 221 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
215 } | 222 } |
OLD | NEW |