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

Side by Side Diff: chrome/test/base/testing_profile_manager.cc

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
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/test/base/testing_profile_manager.h" 5 #include "chrome/test/base/testing_profile_manager.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_special_storage_policy.h" 9 #include "chrome/browser/extensions/extension_special_storage_policy.h"
10 #include "chrome/browser/prefs/pref_service_syncable.h" 10 #include "chrome/browser/prefs/pref_service_syncable.h"
11 #include "chrome/browser/profiles/profile_info_cache.h" 11 #include "chrome/browser/profiles/profile_info_cache.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/test/base/testing_browser_process.h" 13 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace testing { 17 namespace testing {
18 18
19 class ProfileManager : public ::ProfileManager { 19 class ProfileManager : public ::ProfileManagerWithoutInit {
20 public: 20 public:
21 explicit ProfileManager(const base::FilePath& user_data_dir) 21 explicit ProfileManager(const base::FilePath& user_data_dir)
22 : ::ProfileManager(user_data_dir) {} 22 : ::ProfileManagerWithoutInit(user_data_dir) {}
23 23
24 protected: 24 protected:
25 virtual Profile* CreateProfileHelper( 25 virtual Profile* CreateProfileHelper(
26 const base::FilePath& file_path) OVERRIDE { 26 const base::FilePath& file_path) OVERRIDE {
27 return new TestingProfile(file_path); 27 return new TestingProfile(file_path);
28 } 28 }
29 }; 29 };
30 30
31 } // namespace testing 31 } // namespace testing
32 32
(...skipping 17 matching lines...) Expand all
50 const string16& user_name, 50 const string16& user_name,
51 int avatar_id, 51 int avatar_id,
52 const std::string& managed_user_id) { 52 const std::string& managed_user_id) {
53 DCHECK(called_set_up_); 53 DCHECK(called_set_up_);
54 54
55 // Create a path for the profile based on the name. 55 // Create a path for the profile based on the name.
56 base::FilePath profile_path(profiles_dir_.path()); 56 base::FilePath profile_path(profiles_dir_.path());
57 profile_path = profile_path.AppendASCII(profile_name); 57 profile_path = profile_path.AppendASCII(profile_name);
58 58
59 // Create the profile and register it. 59 // Create the profile and register it.
60 TestingProfile* profile = new TestingProfile( 60 TestingProfile::Builder builder;
61 profile_path, 61 builder.SetPath(profile_path);
62 NULL, 62 builder.SetPrefService(prefs.Pass());
63 scoped_refptr<ExtensionSpecialStoragePolicy>(), 63 TestingProfile* profile = builder.Build().release();
64 prefs.Pass());
65 profile_manager_->AddProfile(profile); // Takes ownership. 64 profile_manager_->AddProfile(profile); // Takes ownership.
66 65
67 // Update the user metadata. 66 // Update the user metadata.
68 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); 67 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
69 size_t index = cache.GetIndexOfProfileWithPath(profile_path); 68 size_t index = cache.GetIndexOfProfileWithPath(profile_path);
70 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id); 69 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id);
71 cache.SetManagedUserIdOfProfileAtIndex(index, managed_user_id); 70 cache.SetManagedUserIdOfProfileAtIndex(index, managed_user_id);
72 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it 71 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it
73 // last. 72 // last.
74 cache.SetNameOfProfileAtIndex(index, user_name); 73 cache.SetNameOfProfileAtIndex(index, user_name);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 << "ProfileManager already exists"; 126 << "ProfileManager already exists";
128 127
129 // Set up the directory for profiles. 128 // Set up the directory for profiles.
130 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); 129 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir());
131 130
132 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); 131 profile_manager_ = new testing::ProfileManager(profiles_dir_.path());
133 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. 132 browser_process_->SetProfileManager(profile_manager_); // Takes ownership.
134 133
135 called_set_up_ = true; 134 called_set_up_ = true;
136 } 135 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | components/autofill/core/browser/personal_data_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698