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/ui/browser_command_controller.h" | 5 #include "chrome/browser/ui/browser_command_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 IN_PROC_BROWSER_TEST_F(BrowserCommandControllerBrowserTest, | 81 IN_PROC_BROWSER_TEST_F(BrowserCommandControllerBrowserTest, |
82 DISABLED_NewAvatarMenuEnabledInGuestMode) { | 82 DISABLED_NewAvatarMenuEnabledInGuestMode) { |
83 EXPECT_EQ(1U, BrowserList::GetInstance()->size()); | 83 EXPECT_EQ(1U, BrowserList::GetInstance()->size()); |
84 | 84 |
85 // Create a guest browser nicely. Using CreateProfile() and CreateBrowser() | 85 // Create a guest browser nicely. Using CreateProfile() and CreateBrowser() |
86 // does incomplete initialization that would lead to | 86 // does incomplete initialization that would lead to |
87 // SystemUrlRequestContextGetter being leaked. | 87 // SystemUrlRequestContextGetter being leaked. |
88 content::WindowedNotificationObserver browser_creation_observer( | 88 content::WindowedNotificationObserver browser_creation_observer( |
89 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 89 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
90 content::NotificationService::AllSources()); | 90 content::NotificationService::AllSources()); |
91 profiles::SwitchToGuestProfile(chrome::GetActiveDesktop(), | 91 profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); |
92 ProfileManager::CreateCallback()); | |
93 | 92 |
94 // RunUntilIdle() (racily) isn't sufficient to ensure browser creation, so | 93 // RunUntilIdle() (racily) isn't sufficient to ensure browser creation, so |
95 // listen for the notification. | 94 // listen for the notification. |
96 base::MessageLoop::current()->RunUntilIdle(); | 95 base::MessageLoop::current()->RunUntilIdle(); |
97 browser_creation_observer.Wait(); | 96 browser_creation_observer.Wait(); |
98 EXPECT_EQ(2U, BrowserList::GetInstance()->size()); | 97 EXPECT_EQ(2U, BrowserList::GetInstance()->size()); |
99 | 98 |
100 // Access the browser that was created for the new Guest Profile. | 99 // Access the browser that was created for the new Guest Profile. |
101 Profile* guest = g_browser_process->profile_manager()->GetProfileByPath( | 100 Profile* guest = g_browser_process->profile_manager()->GetProfileByPath( |
102 ProfileManager::GetGuestProfilePath()); | 101 ProfileManager::GetGuestProfilePath()); |
103 Browser* browser = chrome::FindAnyBrowser(guest, true); | 102 Browser* browser = chrome::FindAnyBrowser(guest, true); |
104 EXPECT_TRUE(browser); | 103 EXPECT_TRUE(browser); |
105 | 104 |
106 // The BrowsingDataRemover needs a loaded TemplateUrlService or else it hangs | 105 // The BrowsingDataRemover needs a loaded TemplateUrlService or else it hangs |
107 // on to a CallbackList::Subscription forever. | 106 // on to a CallbackList::Subscription forever. |
108 TemplateURLServiceFactory::GetForProfile(guest)->set_loaded(true); | 107 TemplateURLServiceFactory::GetForProfile(guest)->set_loaded(true); |
109 | 108 |
110 const CommandUpdater* command_updater = | 109 const CommandUpdater* command_updater = |
111 browser->command_controller()->command_updater(); | 110 browser->command_controller()->command_updater(); |
112 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
113 // Chrome OS uses system tray menu to handle multi-profiles. | 112 // Chrome OS uses system tray menu to handle multi-profiles. |
114 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 113 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
115 #else | 114 #else |
116 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 115 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
117 #endif | 116 #endif |
118 } | 117 } |
OLD | NEW |