Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1169)

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc

Issue 1304943006: ProfileChooserVIew heap-use-after-free fix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove un-needed import Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 NOTREACHED() << "Could not create directory at " << path.MaybeAsASCII(); 43 NOTREACHED() << "Could not create directory at " << path.MaybeAsASCII();
44 44
45 Profile* profile = 45 Profile* profile =
46 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); 46 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
47 profile_manager->RegisterTestingProfile(profile, true, false); 47 profile_manager->RegisterTestingProfile(profile, true, false);
48 EXPECT_EQ(starting_number_of_profiles + 1, 48 EXPECT_EQ(starting_number_of_profiles + 1,
49 profile_manager->GetNumberOfProfiles()); 49 profile_manager->GetNumberOfProfiles());
50 return profile; 50 return profile;
51 } 51 }
52 52
53 Profile* CreateProfileOutsideUserDataDir() {
54 base::FilePath path;
55 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &path))
56 NOTREACHED() << "Could not create directory at " << path.MaybeAsASCII();
57
58 ProfileManager* profile_manager = g_browser_process->profile_manager();
59 Profile* profile =
60 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
61 profile_manager->RegisterTestingProfile(profile, true, false);
62 return profile;
63 }
64
53 // Set up the profiles to enable Lock. Takes as parameter a profile that will be 65 // Set up the profiles to enable Lock. Takes as parameter a profile that will be
54 // signed in, and also creates a supervised user (necessary for lock). 66 // signed in, and also creates a supervised user (necessary for lock).
55 void SetupProfilesForLock(Profile* signed_in) { 67 void SetupProfilesForLock(Profile* signed_in) {
56 const char* signed_in_email = "me@google.com"; 68 const char* signed_in_email = "me@google.com";
57 Profile* supervised = CreateTestingProfile("supervised"); 69 Profile* supervised = CreateTestingProfile("supervised");
58 ProfileInfoCache* cache = &g_browser_process->profile_manager()-> 70 ProfileInfoCache* cache = &g_browser_process->profile_manager()->
59 GetProfileInfoCache(); 71 GetProfileInfoCache();
60 cache->SetAuthInfoOfProfileAtIndex(cache->GetIndexOfProfileWithPath( 72 cache->SetAuthInfoOfProfileAtIndex(cache->GetIndexOfProfileWithPath(
61 signed_in->GetPath()), "12345", base::UTF8ToUTF16(signed_in_email)); 73 signed_in->GetPath()), "12345", base::UTF8ToUTF16(signed_in_email));
62 signed_in->GetPrefs()-> 74 signed_in->GetPrefs()->
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 current_profile_bubble()->avatar_menu_.get()); 189 current_profile_bubble()->avatar_menu_.get());
178 base::MessageLoop::current()->RunUntilIdle(); 190 base::MessageLoop::current()->RunUntilIdle();
179 } 191 }
180 192
181 private: 193 private:
182 scoped_ptr<content::WindowedNotificationObserver> window_close_observer_; 194 scoped_ptr<content::WindowedNotificationObserver> window_close_observer_;
183 195
184 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewExtensionsTest); 196 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewExtensionsTest);
185 }; 197 };
186 198
199 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest,
200 NoProfileChooserOnOutsideUserDataDirProfiles) {
201 // Test that the profile chooser view does not show when avatar menu is not
202 // available. This can be repro'ed with a profile path outside user_data_dir.
203 // crbug.com/527505
204 Profile* new_profile = CreateProfileOutsideUserDataDir();
205 Browser* browser = CreateBrowser(new_profile);
206 browser->window()->ShowAvatarBubbleFromAvatarButton(
207 BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN,
208 signin::ManageAccountsParams());
209 ASSERT_FALSE(ProfileChooserView::IsShowing());
210 CloseBrowserSynchronously(browser);
211 }
212
187 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, SigninButtonHasFocus) { 213 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, SigninButtonHasFocus) {
188 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); 214 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled());
189 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser())); 215 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser()));
190 216
191 EXPECT_TRUE(signin_current_profile_link()->HasFocus()); 217 EXPECT_TRUE(signin_current_profile_link()->HasFocus());
192 } 218 }
193 219
194 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ContentAreaHasFocus) { 220 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ContentAreaHasFocus) {
195 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); 221 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled());
196 222
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 EXPECT_EQ(1U, BrowserList::GetInstance(chrome::GetActiveDesktop())->size()); 314 EXPECT_EQ(1U, BrowserList::GetInstance(chrome::GetActiveDesktop())->size());
289 315
290 WaitForUserManager(); 316 WaitForUserManager();
291 // Assert that the first profile's extensions are not blocked. 317 // Assert that the first profile's extensions are not blocked.
292 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); 318 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size());
293 ASSERT_EQ(0U, registry->blocked_extensions().size()); 319 ASSERT_EQ(0U, registry->blocked_extensions().size());
294 320
295 // We need to hide the User Manager or else the process can't die. 321 // We need to hide the User Manager or else the process can't die.
296 UserManager::Hide(); 322 UserManager::Hide();
297 } 323 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698