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

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

Issue 17068004: Revert 207755 "Add device policies to control accessibility sett..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_special_storage_policy.h"
11 #include "chrome/browser/prefs/pref_service_syncable.h"
12 #include "chrome/browser/profiles/profile_info_cache.h" 10 #include "chrome/browser/profiles/profile_info_cache.h"
13 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/test/base/testing_browser_process.h" 12 #include "chrome/test/base/testing_browser_process.h"
15 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
16 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
17 15
18 namespace testing { 16 namespace testing {
19 17
20 class ProfileManager : public ::ProfileManager { 18 class ProfileManager : public ::ProfileManager {
21 public: 19 public:
(...skipping 18 matching lines...) Expand all
40 TestingProfileManager::~TestingProfileManager() { 38 TestingProfileManager::~TestingProfileManager() {
41 } 39 }
42 40
43 bool TestingProfileManager::SetUp() { 41 bool TestingProfileManager::SetUp() {
44 SetUpInternal(); 42 SetUpInternal();
45 return called_set_up_; 43 return called_set_up_;
46 } 44 }
47 45
48 TestingProfile* TestingProfileManager::CreateTestingProfile( 46 TestingProfile* TestingProfileManager::CreateTestingProfile(
49 const std::string& profile_name, 47 const std::string& profile_name,
50 scoped_ptr<PrefServiceSyncable> prefs,
51 const string16& user_name, 48 const string16& user_name,
52 int avatar_id) { 49 int avatar_id) {
53 DCHECK(called_set_up_); 50 DCHECK(called_set_up_);
54 51
55 // Create a path for the profile based on the name. 52 // Create a path for the profile based on the name.
56 base::FilePath profile_path(profiles_dir_.path()); 53 base::FilePath profile_path(profiles_dir_.path());
57 profile_path = profile_path.AppendASCII(profile_name); 54 profile_path = profile_path.AppendASCII(profile_name);
58 55
59 // Create the profile and register it. 56 // Create the profile and register it.
60 TestingProfile* profile = new TestingProfile( 57 TestingProfile* profile = new TestingProfile(profile_path);
61 profile_path,
62 NULL,
63 scoped_refptr<ExtensionSpecialStoragePolicy>(),
64 prefs.Pass());
65 profile_manager_->AddProfile(profile); // Takes ownership. 58 profile_manager_->AddProfile(profile); // Takes ownership.
66 59
67 // Update the user metadata. 60 // Update the user metadata.
68 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); 61 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
69 size_t index = cache.GetIndexOfProfileWithPath(profile_path); 62 size_t index = cache.GetIndexOfProfileWithPath(profile_path);
70 cache.SetNameOfProfileAtIndex(index, user_name); 63 cache.SetNameOfProfileAtIndex(index, user_name);
71 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id); 64 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id);
72 65
73 testing_profiles_.insert(std::make_pair(profile_name, profile)); 66 testing_profiles_.insert(std::make_pair(profile_name, profile));
74 67
75 return profile; 68 return profile;
76 } 69 }
77 70
78 TestingProfile* TestingProfileManager::CreateTestingProfile( 71 TestingProfile* TestingProfileManager::CreateTestingProfile(
79 const std::string& name) { 72 const std::string& name) {
80 DCHECK(called_set_up_); 73 DCHECK(called_set_up_);
81 return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(), 74 return CreateTestingProfile(name, UTF8ToUTF16(name), 0);
82 UTF8ToUTF16(name), 0);
83 } 75 }
84 76
85 void TestingProfileManager::DeleteTestingProfile(const std::string& name) { 77 void TestingProfileManager::DeleteTestingProfile(const std::string& name) {
86 DCHECK(called_set_up_); 78 DCHECK(called_set_up_);
87 79
88 TestingProfilesMap::iterator it = testing_profiles_.find(name); 80 TestingProfilesMap::iterator it = testing_profiles_.find(name);
89 DCHECK(it != testing_profiles_.end()); 81 DCHECK(it != testing_profiles_.end());
90 82
91 TestingProfile* profile = it->second; 83 TestingProfile* profile = it->second;
92 84
(...skipping 26 matching lines...) Expand all
119 << "ProfileManager already exists"; 111 << "ProfileManager already exists";
120 112
121 // Set up the directory for profiles. 113 // Set up the directory for profiles.
122 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); 114 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir());
123 115
124 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); 116 profile_manager_ = new testing::ProfileManager(profiles_dir_.path());
125 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. 117 browser_process_->SetProfileManager(profile_manager_); // Takes ownership.
126 118
127 called_set_up_ = true; 119 called_set_up_ = true;
128 } 120 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/test/base/testing_profile_manager.h ('k') | trunk/src/chrome/test/data/policy/policy_test_cases.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698