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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/api/infobars/infobar_service.h" | 8 #include "chrome/browser/api/infobars/infobar_service.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
13 #include "chrome/browser/first_run/first_run.h" | 13 #include "chrome/browser/first_run/first_run.h" |
14 #include "chrome/browser/prefs/session_startup_pref.h" | 14 #include "chrome/browser/prefs/session_startup_pref.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_impl.h" | 16 #include "chrome/browser/profiles/profile_impl.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/sessions/session_restore.h" | 18 #include "chrome/browser/sessions/session_restore.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 21 #include "chrome/browser/ui/browser_iterator.h" |
21 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
22 #include "chrome/browser/ui/browser_list_observer.h" | 23 #include "chrome/browser/ui/browser_list_observer.h" |
23 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
24 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 25 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
25 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 26 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
27 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 28 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
28 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 service->extension_prefs()->SetLaunchType(app_id, launch_type); | 82 service->extension_prefs()->SetLaunchType(app_id, launch_type); |
82 } | 83 } |
83 | 84 |
84 // Check that there are two browsers. Find the one that is not |browser()|. | 85 // Check that there are two browsers. Find the one that is not |browser()|. |
85 void FindOneOtherBrowser(Browser** out_other_browser) { | 86 void FindOneOtherBrowser(Browser** out_other_browser) { |
86 // There should only be one other browser. | 87 // There should only be one other browser. |
87 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); | 88 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
88 | 89 |
89 // Find the new browser. | 90 // Find the new browser. |
90 Browser* other_browser = NULL; | 91 Browser* other_browser = NULL; |
91 for (BrowserList::const_iterator i = BrowserList::begin(); | 92 for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) { |
92 i != BrowserList::end() && !other_browser; ++i) { | 93 if (*it != browser()) |
93 if (*i != browser()) | 94 other_browser = *it; |
94 other_browser = *i; | |
95 } | 95 } |
96 ASSERT_TRUE(other_browser); | 96 ASSERT_TRUE(other_browser); |
97 ASSERT_TRUE(other_browser != browser()); | 97 ASSERT_TRUE(other_browser != browser()); |
98 *out_other_browser = other_browser; | 98 *out_other_browser = other_browser; |
99 } | 99 } |
100 | 100 |
101 Browser* FindOneOtherBrowserForProfile(Profile* profile, | 101 Browser* FindOneOtherBrowserForProfile(Profile* profile, |
102 Browser* not_this_browser) { | 102 Browser* not_this_browser) { |
103 for (BrowserList::const_iterator i = BrowserList::begin(); | 103 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
104 i != BrowserList::end(); ++i) { | 104 if (*it != not_this_browser && it->profile() == profile) |
105 if (*i != not_this_browser && (*i)->profile() == profile) | 105 return *it; |
106 return *i; | |
107 } | 106 } |
108 return NULL; | 107 return NULL; |
109 } | 108 } |
110 }; | 109 }; |
111 | 110 |
112 class OpenURLsPopupObserver : public chrome::BrowserListObserver { | 111 class OpenURLsPopupObserver : public chrome::BrowserListObserver { |
113 public: | 112 public: |
114 OpenURLsPopupObserver() : added_browser_(NULL) { } | 113 OpenURLsPopupObserver() : added_browser_(NULL) { } |
115 | 114 |
116 virtual void OnBrowserAdded(Browser* browser) OVERRIDE { | 115 virtual void OnBrowserAdded(Browser* browser) OVERRIDE { |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); | 873 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); |
875 ASSERT_TRUE(new_browser); | 874 ASSERT_TRUE(new_browser); |
876 tab_strip = new_browser->tab_strip_model(); | 875 tab_strip = new_browser->tab_strip_model(); |
877 ASSERT_EQ(1, tab_strip->count()); | 876 ASSERT_EQ(1, tab_strip->count()); |
878 web_contents = tab_strip->GetWebContentsAt(0); | 877 web_contents = tab_strip->GetWebContentsAt(0); |
879 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); | 878 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); |
880 EXPECT_EQ(1U, | 879 EXPECT_EQ(1U, |
881 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); | 880 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); |
882 } | 881 } |
883 #endif // !OS_CHROMEOS | 882 #endif // !OS_CHROMEOS |
OLD | NEW |