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

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

Issue 1701563002: Refactor ProfileInfoCache in c/b/ui/views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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 <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/path_service.h" 11 #include "base/path_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/histogram_tester.h" 13 #include "base/test/histogram_tester.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/extensions/extension_browsertest.h" 16 #include "chrome/browser/extensions/extension_browsertest.h"
17 #include "chrome/browser/profiles/profile_attributes_entry.h"
18 #include "chrome/browser/profiles/profile_attributes_storage.h"
17 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/profiles/profile_metrics.h" 20 #include "chrome/browser/profiles/profile_metrics.h"
19 #include "chrome/browser/profiles/profiles_state.h" 21 #include "chrome/browser/profiles/profiles_state.h"
20 #include "chrome/browser/ui/browser_list.h" 22 #include "chrome/browser/ui/browser_list.h"
21 #include "chrome/browser/ui/user_manager.h" 23 #include "chrome/browser/ui/user_manager.h"
22 #include "chrome/browser/ui/views/frame/browser_view.h" 24 #include "chrome/browser/ui/views/frame/browser_view.h"
23 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 25 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
24 #include "chrome/browser/ui/views/profiles/user_manager_view.h" 26 #include "chrome/browser/ui/views/profiles/user_manager_view.h"
25 #include "chrome/common/chrome_paths.h" 27 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ProfileManager* profile_manager = g_browser_process->profile_manager(); 63 ProfileManager* profile_manager = g_browser_process->profile_manager();
62 Profile* profile = 64 Profile* profile =
63 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); 65 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
64 profile_manager->RegisterTestingProfile(profile, true, false); 66 profile_manager->RegisterTestingProfile(profile, true, false);
65 return profile; 67 return profile;
66 } 68 }
67 69
68 // Set up the profiles to enable Lock. Takes as parameter a profile that will be 70 // Set up the profiles to enable Lock. Takes as parameter a profile that will be
69 // signed in, and also creates a supervised user (necessary for lock). 71 // signed in, and also creates a supervised user (necessary for lock).
70 void SetupProfilesForLock(Profile* signed_in) { 72 void SetupProfilesForLock(Profile* signed_in) {
71 const char* signed_in_email = "me@google.com"; 73 const char* signed_in_email = "me@google.com";
Peter Kasting 2016/02/16 20:49:54 Nit: Compile-time constants like this should be na
72 Profile* supervised = CreateTestingProfile("supervised"); 74 Profile* supervised = CreateTestingProfile("supervised");
Peter Kasting 2016/02/16 20:49:54 Nit: Declare variables as close to first use as po
lwchkg 2016/02/17 17:09:31 Thanks a lot! On 2016/02/16 20:49:54, Peter Kasti
73 ProfileInfoCache* cache = &g_browser_process->profile_manager()-> 75
74 GetProfileInfoCache(); 76 ProfileAttributesStorage& storage =
75 cache->SetAuthInfoOfProfileAtIndex(cache->GetIndexOfProfileWithPath( 77 g_browser_process->profile_manager()->GetProfileAttributesStorage();
Peter Kasting 2016/02/16 20:49:54 Nit: Prefer pointers to non-const refs
lwchkg 2016/02/17 17:09:31 Done.
76 signed_in->GetPath()), "12345", base::UTF8ToUTF16(signed_in_email)); 78 ProfileAttributesEntry* entry_signed_in;
79 ProfileAttributesEntry* entry_supervised;
80 ASSERT_TRUE(storage.GetProfileAttributesWithPath(
81 signed_in->GetPath(), &entry_signed_in));
82 ASSERT_TRUE(storage.GetProfileAttributesWithPath(
83 supervised->GetPath(), &entry_supervised));
84
85 entry_signed_in->SetAuthInfo("12345", base::UTF8ToUTF16(signed_in_email));
77 signed_in->GetPrefs()-> 86 signed_in->GetPrefs()->
78 SetString(prefs::kGoogleServicesHostedDomain, "google.com"); 87 SetString(prefs::kGoogleServicesHostedDomain, "google.com");
79 cache->SetSupervisedUserIdOfProfileAtIndex(cache->GetIndexOfProfileWithPath( 88 entry_supervised->SetSupervisedUserId(signed_in_email);
80 supervised->GetPath()), signed_in_email);
81 89
82 EXPECT_TRUE(profiles::IsLockAvailable(signed_in)); 90 EXPECT_TRUE(profiles::IsLockAvailable(signed_in));
83 } 91 }
84 92
85 views::View* FindWebView(views::View* view) { 93 views::View* FindWebView(views::View* view) {
86 std::queue<views::View*> queue; 94 std::queue<views::View*> queue;
87 queue.push(view); 95 queue.push(view);
88 while (!queue.empty()) { 96 while (!queue.empty()) {
89 views::View* current = queue.front(); 97 views::View* current = queue.front();
90 queue.pop(); 98 queue.pop();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 EXPECT_EQ(1U, BrowserList::GetInstance()->size()); 325 EXPECT_EQ(1U, BrowserList::GetInstance()->size());
318 326
319 WaitForUserManager(); 327 WaitForUserManager();
320 // Assert that the first profile's extensions are not blocked. 328 // Assert that the first profile's extensions are not blocked.
321 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); 329 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size());
322 ASSERT_EQ(0U, registry->blocked_extensions().size()); 330 ASSERT_EQ(0U, registry->blocked_extensions().size());
323 331
324 // We need to hide the User Manager or else the process can't die. 332 // We need to hide the User Manager or else the process can't die.
325 UserManager::Hide(); 333 UserManager::Hide();
326 } 334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698