| OLD | NEW |
| 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" | |
| 8 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 9 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 11 #include "chrome/browser/prefs/pref_service_syncable.h" | 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 12 #include "chrome/browser/profiles/profile_info_cache.h" | 11 #include "chrome/browser/profiles/profile_info_cache.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 16 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 96 } |
| 98 | 97 |
| 99 void TestingProfileManager::DeleteProfileInfoCache() { | 98 void TestingProfileManager::DeleteProfileInfoCache() { |
| 100 profile_manager_->profile_info_cache_.reset(NULL); | 99 profile_manager_->profile_info_cache_.reset(NULL); |
| 101 } | 100 } |
| 102 | 101 |
| 103 void TestingProfileManager::SetLoggedIn(bool logged_in) { | 102 void TestingProfileManager::SetLoggedIn(bool logged_in) { |
| 104 profile_manager_->logged_in_ = logged_in; | 103 profile_manager_->logged_in_ = logged_in; |
| 105 } | 104 } |
| 106 | 105 |
| 106 const base::FilePath& TestingProfileManager::profiles_dir() { |
| 107 DCHECK(called_set_up_); |
| 108 return profiles_dir_.path(); |
| 109 } |
| 110 |
| 107 ProfileManager* TestingProfileManager::profile_manager() { | 111 ProfileManager* TestingProfileManager::profile_manager() { |
| 108 DCHECK(called_set_up_); | 112 DCHECK(called_set_up_); |
| 109 return profile_manager_; | 113 return profile_manager_; |
| 110 } | 114 } |
| 111 | 115 |
| 112 ProfileInfoCache* TestingProfileManager::profile_info_cache() { | 116 ProfileInfoCache* TestingProfileManager::profile_info_cache() { |
| 113 DCHECK(called_set_up_); | 117 DCHECK(called_set_up_); |
| 114 return &profile_manager_->GetProfileInfoCache(); | 118 return &profile_manager_->GetProfileInfoCache(); |
| 115 } | 119 } |
| 116 | 120 |
| 117 void TestingProfileManager::SetUpInternal() { | 121 void TestingProfileManager::SetUpInternal() { |
| 118 ASSERT_FALSE(browser_process_->profile_manager()) | 122 ASSERT_FALSE(browser_process_->profile_manager()) |
| 119 << "ProfileManager already exists"; | 123 << "ProfileManager already exists"; |
| 120 | 124 |
| 121 // Set up the directory for profiles. | 125 // Set up the directory for profiles. |
| 122 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); | 126 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); |
| 123 | 127 |
| 124 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); | 128 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); |
| 125 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. | 129 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. |
| 126 | 130 |
| 127 called_set_up_ = true; | 131 called_set_up_ = true; |
| 128 } | 132 } |
| OLD | NEW |