OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/profiles/profile_window.h" | 5 #include "chrome/browser/profiles/profile_window.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 Browser* ProfileWindowBrowserTest::OpenGuestBrowser() { | 104 Browser* ProfileWindowBrowserTest::OpenGuestBrowser() { |
105 size_t num_browsers = BrowserList::GetInstance()->size(); | 105 size_t num_browsers = BrowserList::GetInstance()->size(); |
106 | 106 |
107 // Create a guest browser nicely. Using CreateProfile() and CreateBrowser() | 107 // Create a guest browser nicely. Using CreateProfile() and CreateBrowser() |
108 // does incomplete initialization that would lead to | 108 // does incomplete initialization that would lead to |
109 // SystemUrlRequestContextGetter being leaked. | 109 // SystemUrlRequestContextGetter being leaked. |
110 content::WindowedNotificationObserver browser_creation_observer( | 110 content::WindowedNotificationObserver browser_creation_observer( |
111 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 111 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
112 content::NotificationService::AllSources()); | 112 content::NotificationService::AllSources()); |
113 profiles::SwitchToGuestProfile(chrome::GetActiveDesktop(), | 113 profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); |
114 ProfileManager::CreateCallback()); | |
115 | 114 |
116 browser_creation_observer.Wait(); | 115 browser_creation_observer.Wait(); |
117 DCHECK_NE(static_cast<Profile*>(nullptr), | 116 DCHECK_NE(static_cast<Profile*>(nullptr), |
118 g_browser_process->profile_manager()->GetProfileByPath( | 117 g_browser_process->profile_manager()->GetProfileByPath( |
119 ProfileManager::GetGuestProfilePath())); | 118 ProfileManager::GetGuestProfilePath())); |
120 EXPECT_EQ(num_browsers + 1, BrowserList::GetInstance()->size()); | 119 EXPECT_EQ(num_browsers + 1, BrowserList::GetInstance()->size()); |
121 | 120 |
122 Profile* guest = g_browser_process->profile_manager()->GetProfileByPath( | 121 Profile* guest = g_browser_process->profile_manager()->GetProfileByPath( |
123 ProfileManager::GetGuestProfilePath()); | 122 ProfileManager::GetGuestProfilePath()); |
124 Browser* browser = chrome::FindAnyBrowser(guest, true); | 123 Browser* browser = chrome::FindAnyBrowser(guest, true); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 AppMenuModel model_normal_profile(&accelerator_handler, browser()); | 206 AppMenuModel model_normal_profile(&accelerator_handler, browser()); |
208 EXPECT_NE(-1, model_normal_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU)); | 207 EXPECT_NE(-1, model_normal_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU)); |
209 | 208 |
210 // Guest browser has no bookmark menu. | 209 // Guest browser has no bookmark menu. |
211 Browser* guest_browser = OpenGuestBrowser(); | 210 Browser* guest_browser = OpenGuestBrowser(); |
212 AppMenuModel model_guest_profile(&accelerator_handler, guest_browser); | 211 AppMenuModel model_guest_profile(&accelerator_handler, guest_browser); |
213 EXPECT_EQ(-1, model_guest_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU)); | 212 EXPECT_EQ(-1, model_guest_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU)); |
214 } | 213 } |
215 | 214 |
216 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) | 215 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) |
OLD | NEW |