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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/infobars/infobar_service.h" | 23 #include "chrome/browser/infobars/infobar_service.h" |
24 #include "chrome/browser/prefs/session_startup_pref.h" | 24 #include "chrome/browser/prefs/session_startup_pref.h" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/profiles/profile_impl.h" | 26 #include "chrome/browser/profiles/profile_impl.h" |
27 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
28 #include "chrome/browser/sessions/session_restore.h" | 28 #include "chrome/browser/sessions/session_restore.h" |
29 #include "chrome/browser/signin/signin_promo.h" | 29 #include "chrome/browser/signin/signin_promo.h" |
30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_commands.h" | 31 #include "chrome/browser/ui/browser_commands.h" |
32 #include "chrome/browser/ui/browser_finder.h" | 32 #include "chrome/browser/ui/browser_finder.h" |
33 #include "chrome/browser/ui/browser_iterator.h" | |
34 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
35 #include "chrome/browser/ui/browser_list_observer.h" | 34 #include "chrome/browser/ui/browser_list_observer.h" |
36 #include "chrome/browser/ui/browser_window.h" | 35 #include "chrome/browser/ui/browser_window.h" |
37 #include "chrome/browser/ui/host_desktop.h" | 36 #include "chrome/browser/ui/host_desktop.h" |
38 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 37 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
39 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 38 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
40 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
41 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
42 #include "chrome/common/extensions/extension_constants.h" | 41 #include "chrome/common/extensions/extension_constants.h" |
43 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 namespace { | 84 namespace { |
86 | 85 |
87 // Check that there are two browsers. Find the one that is not |browser|. | 86 // Check that there are two browsers. Find the one that is not |browser|. |
88 Browser* FindOneOtherBrowser(Browser* browser) { | 87 Browser* FindOneOtherBrowser(Browser* browser) { |
89 // There should only be one other browser. | 88 // There should only be one other browser. |
90 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile(), | 89 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile(), |
91 browser->host_desktop_type())); | 90 browser->host_desktop_type())); |
92 | 91 |
93 // Find the new browser. | 92 // Find the new browser. |
94 Browser* other_browser = NULL; | 93 Browser* other_browser = NULL; |
95 for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) { | 94 for (auto* b : *BrowserList::GetInstance()) { |
96 if (*it != browser) | 95 if (b != browser) |
97 other_browser = *it; | 96 other_browser = b; |
98 } | 97 } |
99 return other_browser; | 98 return other_browser; |
100 } | 99 } |
101 | 100 |
102 bool IsWindows10OrNewer() { | 101 bool IsWindows10OrNewer() { |
103 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
104 return base::win::GetVersion() >= base::win::VERSION_WIN10; | 103 return base::win::GetVersion() >= base::win::VERSION_WIN10; |
105 #else | 104 #else |
106 return false; | 105 return false; |
107 #endif | 106 #endif |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 browser()->host_desktop_type())); | 182 browser()->host_desktop_type())); |
184 } | 183 } |
185 | 184 |
186 void SetAppLaunchPref(const std::string& app_id, | 185 void SetAppLaunchPref(const std::string& app_id, |
187 extensions::LaunchType launch_type) { | 186 extensions::LaunchType launch_type) { |
188 extensions::SetLaunchType(browser()->profile(), app_id, launch_type); | 187 extensions::SetLaunchType(browser()->profile(), app_id, launch_type); |
189 } | 188 } |
190 | 189 |
191 Browser* FindOneOtherBrowserForProfile(Profile* profile, | 190 Browser* FindOneOtherBrowserForProfile(Profile* profile, |
192 Browser* not_this_browser) { | 191 Browser* not_this_browser) { |
193 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 192 for (auto* browser : *BrowserList::GetInstance()) { |
194 if (*it != not_this_browser && it->profile() == profile) | 193 if (browser != not_this_browser && browser->profile() == profile) |
195 return *it; | 194 return browser; |
196 } | 195 } |
197 return NULL; | 196 return NULL; |
198 } | 197 } |
199 | 198 |
200 // A helper function that checks the session restore UI (infobar) is shown | 199 // A helper function that checks the session restore UI (infobar) is shown |
201 // when Chrome starts up after crash. | 200 // when Chrome starts up after crash. |
202 void EnsureRestoreUIWasShown(content::WebContents* web_contents) { | 201 void EnsureRestoreUIWasShown(content::WebContents* web_contents) { |
203 #if defined(OS_MACOSX) | 202 #if defined(OS_MACOSX) |
204 InfoBarService* infobar_service = | 203 InfoBarService* infobar_service = |
205 InfoBarService::FromWebContents(web_contents); | 204 InfoBarService::FromWebContents(web_contents); |
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 ASSERT_EQ(1, tab_strip->count()); | 1718 ASSERT_EQ(1, tab_strip->count()); |
1720 EXPECT_EQ("title1.html", | 1719 EXPECT_EQ("title1.html", |
1721 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1720 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
1722 } | 1721 } |
1723 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1722 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
1724 | 1723 |
1725 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || | 1724 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || |
1726 // defined(ENABLE_CONFIGURATION_POLICY) | 1725 // defined(ENABLE_CONFIGURATION_POLICY) |
1727 | 1726 |
1728 #endif // !defined(OS_CHROMEOS) | 1727 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |