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.h" | 5 #include "chrome/test/base/testing_profile.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 bool guest_session, | 375 bool guest_session, |
376 const std::string& supervised_user_id, | 376 const std::string& supervised_user_id, |
377 scoped_ptr<policy::PolicyService> policy_service, | 377 scoped_ptr<policy::PolicyService> policy_service, |
378 const TestingFactories& factories) | 378 const TestingFactories& factories) |
379 : start_time_(Time::Now()), | 379 : start_time_(Time::Now()), |
380 prefs_(prefs.release()), | 380 prefs_(prefs.release()), |
381 testing_prefs_(NULL), | 381 testing_prefs_(NULL), |
382 force_incognito_(false), | 382 force_incognito_(false), |
383 original_profile_(parent), | 383 original_profile_(parent), |
384 guest_session_(guest_session), | 384 guest_session_(guest_session), |
385 supervised_user_id_(supervised_user_id), | |
386 last_session_exited_cleanly_(true), | 385 last_session_exited_cleanly_(true), |
387 #if defined(ENABLE_EXTENSIONS) | 386 #if defined(ENABLE_EXTENSIONS) |
388 extension_special_storage_policy_(extension_policy), | 387 extension_special_storage_policy_(extension_policy), |
389 #endif | 388 #endif |
390 profile_path_(path), | 389 profile_path_(path), |
391 browser_context_dependency_manager_( | 390 browser_context_dependency_manager_( |
392 BrowserContextDependencyManager::GetInstance()), | 391 BrowserContextDependencyManager::GetInstance()), |
393 resource_context_(NULL), | 392 resource_context_(NULL), |
394 delegate_(delegate), | 393 delegate_(delegate), |
395 policy_service_(policy_service.release()) { | 394 policy_service_(policy_service.release()) { |
(...skipping 17 matching lines...) Expand all Loading... |
413 // tasks have run. | 412 // tasks have run. |
414 // TODO(atwilson): See if this is still required once we convert the current | 413 // TODO(atwilson): See if this is still required once we convert the current |
415 // users of the constructor that takes a Delegate* param. | 414 // users of the constructor that takes a Delegate* param. |
416 if (delegate_) { | 415 if (delegate_) { |
417 base::MessageLoop::current()->PostTask( | 416 base::MessageLoop::current()->PostTask( |
418 FROM_HERE, | 417 FROM_HERE, |
419 base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); | 418 base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); |
420 } else { | 419 } else { |
421 FinishInit(); | 420 FinishInit(); |
422 } | 421 } |
| 422 |
| 423 SetSupervisedUserId(supervised_user_id); |
423 } | 424 } |
424 | 425 |
425 void TestingProfile::CreateTempProfileDir() { | 426 void TestingProfile::CreateTempProfileDir() { |
426 if (!temp_dir_.CreateUniqueTempDir()) { | 427 if (!temp_dir_.CreateUniqueTempDir()) { |
427 LOG(ERROR) << "Failed to create unique temporary directory."; | 428 LOG(ERROR) << "Failed to create unique temporary directory."; |
428 | 429 |
429 // Fallback logic in case we fail to create unique temporary directory. | 430 // Fallback logic in case we fail to create unique temporary directory. |
430 base::FilePath system_tmp_dir; | 431 base::FilePath system_tmp_dir; |
431 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir); | 432 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir); |
432 | 433 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 bool TestingProfile::HasOffTheRecordProfile() { | 760 bool TestingProfile::HasOffTheRecordProfile() { |
760 return incognito_profile_.get() != NULL; | 761 return incognito_profile_.get() != NULL; |
761 } | 762 } |
762 | 763 |
763 Profile* TestingProfile::GetOriginalProfile() { | 764 Profile* TestingProfile::GetOriginalProfile() { |
764 if (original_profile_) | 765 if (original_profile_) |
765 return original_profile_; | 766 return original_profile_; |
766 return this; | 767 return this; |
767 } | 768 } |
768 | 769 |
| 770 void TestingProfile::SetSupervisedUserId(const std::string& id) { |
| 771 supervised_user_id_ = id; |
| 772 if (!id.empty()) |
| 773 GetPrefs()->SetString(prefs::kSupervisedUserId, id); |
| 774 else |
| 775 GetPrefs()->ClearPref(prefs::kSupervisedUserId); |
| 776 } |
| 777 |
769 bool TestingProfile::IsSupervised() { | 778 bool TestingProfile::IsSupervised() { |
770 return !supervised_user_id_.empty(); | 779 return !supervised_user_id_.empty(); |
771 } | 780 } |
772 | 781 |
773 bool TestingProfile::IsChild() { | 782 bool TestingProfile::IsChild() { |
774 #if defined(ENABLE_SUPERVISED_USERS) | 783 #if defined(ENABLE_SUPERVISED_USERS) |
775 return supervised_user_id_ == supervised_users::kChildAccountSUID; | 784 return supervised_user_id_ == supervised_users::kChildAccountSUID; |
776 #else | 785 #else |
777 return false; | 786 return false; |
778 #endif | 787 #endif |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 #if defined(ENABLE_EXTENSIONS) | 1140 #if defined(ENABLE_EXTENSIONS) |
1132 extension_policy_, | 1141 extension_policy_, |
1133 #endif | 1142 #endif |
1134 pref_service_.Pass(), | 1143 pref_service_.Pass(), |
1135 original_profile, | 1144 original_profile, |
1136 guest_session_, | 1145 guest_session_, |
1137 supervised_user_id_, | 1146 supervised_user_id_, |
1138 policy_service_.Pass(), | 1147 policy_service_.Pass(), |
1139 testing_factories_); | 1148 testing_factories_); |
1140 } | 1149 } |
OLD | NEW |