| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" | 4 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" |
| 5 | 5 |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 17 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 17 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" | 18 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" |
| 18 #include "chrome/browser/chromeos/login/startup_utils.h" | 19 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 20 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 20 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 21 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 21 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 22 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 22 #include "chromeos/chromeos_paths.h" | 23 #include "chromeos/chromeos_paths.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 for (const auto& user_affiliation_id : user_affiliation_ids) { | 93 for (const auto& user_affiliation_id : user_affiliation_ids) { |
| 93 user_policy->policy_data().add_user_affiliation_ids(user_affiliation_id); | 94 user_policy->policy_data().add_user_affiliation_ids(user_affiliation_id); |
| 94 } | 95 } |
| 95 user_policy->Build(); | 96 user_policy->Build(); |
| 96 fake_session_manager_client->set_user_policy( | 97 fake_session_manager_client->set_user_policy( |
| 97 cryptohome::Identification(account_id), user_policy->GetBlob()); | 98 cryptohome::Identification(account_id), user_policy->GetBlob()); |
| 98 } | 99 } |
| 99 | 100 |
| 100 void PreLoginUser(const std::string& user_id) { | 101 void PreLoginUser(const std::string& user_id) { |
| 101 ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers"); | 102 ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers"); |
| 102 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); | 103 users_pref->AppendIfNotPresent(base::MakeUnique<base::StringValue>(user_id)); |
| 103 chromeos::StartupUtils::MarkOobeCompleted(); | 104 chromeos::StartupUtils::MarkOobeCompleted(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void LoginUser(const std::string& user_id) { | 107 void LoginUser(const std::string& user_id) { |
| 107 chromeos::test::UserSessionManagerTestApi session_manager_test_api( | 108 chromeos::test::UserSessionManagerTestApi session_manager_test_api( |
| 108 chromeos::UserSessionManager::GetInstance()); | 109 chromeos::UserSessionManager::GetInstance()); |
| 109 session_manager_test_api.SetShouldObtainTokenHandleInTests(false); | 110 session_manager_test_api.SetShouldObtainTokenHandleInTests(false); |
| 110 | 111 |
| 111 chromeos::UserContext user_context( | 112 chromeos::UserContext user_context( |
| 112 AccountId::FromUserEmailGaiaId(user_id, "gaia-id-" + user_id)); | 113 AccountId::FromUserEmailGaiaId(user_id, "gaia-id-" + user_id)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 139 // LoginManager tests typically don't stand up a policy test server but | 140 // LoginManager tests typically don't stand up a policy test server but |
| 140 // instead inject policies directly through a SessionManagerClient. So allow | 141 // instead inject policies directly through a SessionManagerClient. So allow |
| 141 // policy fetches to fail - this is expected. | 142 // policy fetches to fail - this is expected. |
| 142 command_line->AppendSwitch( | 143 command_line->AppendSwitch( |
| 143 chromeos::switches::kAllowFailedPolicyFetchForTest); | 144 chromeos::switches::kAllowFailedPolicyFetchForTest); |
| 144 } | 145 } |
| 145 | 146 |
| 146 } // namespace affiliation_test_helper | 147 } // namespace affiliation_test_helper |
| 147 | 148 |
| 148 } // namespace policy | 149 } // namespace policy |
| OLD | NEW |