OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/test/histogram_tester.h" | 15 #include "base/test/histogram_tester.h" |
| 16 #include "base/threading/thread_restrictions.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/browser/extensions/extension_browsertest.h" | 19 #include "chrome/browser/extensions/extension_browsertest.h" |
19 #include "chrome/browser/profiles/profile_attributes_entry.h" | 20 #include "chrome/browser/profiles/profile_attributes_entry.h" |
20 #include "chrome/browser/profiles/profile_attributes_storage.h" | 21 #include "chrome/browser/profiles/profile_attributes_storage.h" |
21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
22 #include "chrome/browser/profiles/profile_metrics.h" | 23 #include "chrome/browser/profiles/profile_metrics.h" |
23 #include "chrome/browser/profiles/profiles_state.h" | 24 #include "chrome/browser/profiles/profiles_state.h" |
24 #include "chrome/browser/ui/browser_list.h" | 25 #include "chrome/browser/ui/browser_list.h" |
25 #include "chrome/browser/ui/user_manager.h" | 26 #include "chrome/browser/ui/user_manager.h" |
26 #include "chrome/browser/ui/views/frame/browser_view.h" | 27 #include "chrome/browser/ui/views/frame/browser_view.h" |
27 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" | 28 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" |
28 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 29 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
29 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
32 #include "components/prefs/pref_service.h" | 33 #include "components/prefs/pref_service.h" |
33 #include "components/signin/core/common/profile_management_switches.h" | 34 #include "components/signin/core/common/profile_management_switches.h" |
34 #include "components/signin/core/common/signin_pref_names.h" | 35 #include "components/signin/core/common/signin_pref_names.h" |
35 #include "content/public/test/test_utils.h" | 36 #include "content/public/test/test_utils.h" |
36 #include "extensions/browser/extension_registry.h" | 37 #include "extensions/browser/extension_registry.h" |
37 #include "ui/events/event_utils.h" | 38 #include "ui/events/event_utils.h" |
38 #include "ui/views/controls/button/label_button.h" | 39 #include "ui/views/controls/button/label_button.h" |
39 #include "ui/views/controls/webview/webview.h" | 40 #include "ui/views/controls/webview/webview.h" |
40 | 41 |
41 namespace { | 42 namespace { |
42 | 43 |
43 Profile* CreateTestingProfile(const std::string& profile_name) { | 44 Profile* CreateTestingProfile(const std::string& profile_name) { |
| 45 base::ThreadRestrictions::ScopedAllowIO allow_io; |
44 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 46 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
45 size_t starting_number_of_profiles = profile_manager->GetNumberOfProfiles(); | 47 size_t starting_number_of_profiles = profile_manager->GetNumberOfProfiles(); |
46 | 48 |
47 base::FilePath path; | 49 base::FilePath path; |
48 PathService::Get(chrome::DIR_USER_DATA, &path); | 50 PathService::Get(chrome::DIR_USER_DATA, &path); |
49 path = path.AppendASCII(profile_name); | 51 path = path.AppendASCII(profile_name); |
50 if (!base::PathExists(path) && !base::CreateDirectory(path)) | 52 if (!base::PathExists(path) && !base::CreateDirectory(path)) |
51 NOTREACHED() << "Could not create directory at " << path.MaybeAsASCII(); | 53 NOTREACHED() << "Could not create directory at " << path.MaybeAsASCII(); |
52 | 54 |
53 Profile* profile = | 55 Profile* profile = |
54 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); | 56 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); |
55 profile_manager->RegisterTestingProfile(profile, true, false); | 57 profile_manager->RegisterTestingProfile(profile, true, false); |
56 EXPECT_EQ(starting_number_of_profiles + 1, | 58 EXPECT_EQ(starting_number_of_profiles + 1, |
57 profile_manager->GetNumberOfProfiles()); | 59 profile_manager->GetNumberOfProfiles()); |
58 return profile; | 60 return profile; |
59 } | 61 } |
60 | 62 |
61 Profile* CreateProfileOutsideUserDataDir() { | 63 Profile* CreateProfileOutsideUserDataDir() { |
| 64 base::ThreadRestrictions::ScopedAllowIO allow_io; |
62 base::FilePath path; | 65 base::FilePath path; |
63 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &path)) | 66 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &path)) |
64 NOTREACHED() << "Could not create directory at " << path.MaybeAsASCII(); | 67 NOTREACHED() << "Could not create directory at " << path.MaybeAsASCII(); |
65 | 68 |
66 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 69 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
67 Profile* profile = | 70 Profile* profile = |
68 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); | 71 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); |
69 profile_manager->RegisterTestingProfile(profile, true, false); | 72 profile_manager->RegisterTestingProfile(profile, true, false); |
70 return profile; | 73 return profile; |
71 } | 74 } |
72 | 75 |
73 // Set up the profiles to enable Lock. Takes as parameter a profile that will be | 76 // Set up the profiles to enable Lock. Takes as parameter a profile that will be |
74 // signed in, and also creates a supervised user (necessary for lock). | 77 // signed in, and also creates a supervised user (necessary for lock). |
75 void SetupProfilesForLock(Profile* signed_in) { | 78 void SetupProfilesForLock(Profile* signed_in) { |
| 79 base::ThreadRestrictions::ScopedAllowIO allow_io; |
76 const char signed_in_email[] = "me@google.com"; | 80 const char signed_in_email[] = "me@google.com"; |
77 | 81 |
78 // Set up the |signed_in| profile. | 82 // Set up the |signed_in| profile. |
79 ProfileAttributesStorage* storage = | 83 ProfileAttributesStorage* storage = |
80 &g_browser_process->profile_manager()->GetProfileAttributesStorage(); | 84 &g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
81 ProfileAttributesEntry* entry_signed_in; | 85 ProfileAttributesEntry* entry_signed_in; |
82 ASSERT_TRUE(storage->GetProfileAttributesWithPath(signed_in->GetPath(), | 86 ASSERT_TRUE(storage->GetProfileAttributesWithPath(signed_in->GetPath(), |
83 &entry_signed_in)); | 87 &entry_signed_in)); |
84 entry_signed_in->SetAuthInfo("12345", base::UTF8ToUTF16(signed_in_email)); | 88 entry_signed_in->SetAuthInfo("12345", base::UTF8ToUTF16(signed_in_email)); |
85 signed_in->GetPrefs()->SetString(prefs::kGoogleServicesHostedDomain, | 89 signed_in->GetPrefs()->SetString(prefs::kGoogleServicesHostedDomain, |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // Wait until the user manager is shown. | 338 // Wait until the user manager is shown. |
335 runner->Run(); | 339 runner->Run(); |
336 | 340 |
337 // Assert that the first profile's extensions are not blocked. | 341 // Assert that the first profile's extensions are not blocked. |
338 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); | 342 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); |
339 ASSERT_EQ(0U, registry->blocked_extensions().size()); | 343 ASSERT_EQ(0U, registry->blocked_extensions().size()); |
340 | 344 |
341 // We need to hide the User Manager or else the process can't die. | 345 // We need to hide the User Manager or else the process can't die. |
342 UserManager::Hide(); | 346 UserManager::Hide(); |
343 } | 347 } |
OLD | NEW |