| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/chromeos/settings/stub_install_attributes.h" | 5 #include "chrome/browser/chromeos/settings/stub_install_attributes.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 9 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 10 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 10 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 11 | 11 |
| 12 namespace chromeos { | 12 namespace chromeos { |
| 13 | 13 |
| 14 StubInstallAttributes::StubInstallAttributes() : InstallAttributes(nullptr) { | 14 StubInstallAttributes::StubInstallAttributes() : InstallAttributes(nullptr) { |
| 15 device_locked_ = true; | 15 device_locked_ = true; |
| 16 } | 16 } |
| 17 | 17 |
| 18 void StubInstallAttributes::SetDomain(const std::string& domain) { | 18 void StubInstallAttributes::Clear() { |
| 19 registration_domain_ = domain; | 19 registration_mode_ = policy::DEVICE_MODE_NOT_SET; |
| 20 registration_domain_.clear(); |
| 21 registration_realm_.clear(); |
| 22 registration_device_id_.clear(); |
| 20 } | 23 } |
| 21 | 24 |
| 22 void StubInstallAttributes::SetRegistrationUser(const std::string& user) { | 25 void StubInstallAttributes::SetConsumer() { |
| 23 registration_user_ = user; | 26 registration_mode_ = policy::DEVICE_MODE_CONSUMER; |
| 27 registration_domain_.clear(); |
| 28 registration_realm_.clear(); |
| 29 registration_device_id_.clear(); |
| 24 } | 30 } |
| 25 | 31 |
| 26 void StubInstallAttributes::SetDeviceId(const std::string& id) { | 32 void StubInstallAttributes::SetEnterprise(const std::string& domain, |
| 27 registration_device_id_ = id; | 33 const std::string& device_id) { |
| 34 registration_mode_ = policy::DEVICE_MODE_ENTERPRISE; |
| 35 registration_domain_ = domain; |
| 36 registration_realm_.clear(); |
| 37 registration_device_id_ = device_id; |
| 28 } | 38 } |
| 29 | 39 |
| 30 void StubInstallAttributes::SetMode(policy::DeviceMode mode) { | 40 // static |
| 31 registration_mode_ = mode; | 41 ScopedStubInstallAttributes ScopedStubInstallAttributes::CreateUnset() { |
| 42 StubInstallAttributes* attributes = new StubInstallAttributes(); |
| 43 attributes->Clear(); |
| 44 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( |
| 45 attributes); |
| 46 return ScopedStubInstallAttributes(); |
| 32 } | 47 } |
| 33 | 48 |
| 34 ScopedStubInstallAttributes::ScopedStubInstallAttributes( | 49 // static |
| 35 const std::string& domain, | 50 ScopedStubInstallAttributes ScopedStubInstallAttributes::CreateConsumer() { |
| 36 const std::string& registration_user, | |
| 37 const std::string& device_id, | |
| 38 policy::DeviceMode mode) { | |
| 39 StubInstallAttributes* attributes = new StubInstallAttributes(); | 51 StubInstallAttributes* attributes = new StubInstallAttributes(); |
| 40 attributes->SetDomain(domain); | 52 attributes->SetConsumer(); |
| 41 attributes->SetRegistrationUser(registration_user); | |
| 42 attributes->SetDeviceId(device_id); | |
| 43 attributes->SetMode(mode); | |
| 44 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( | 53 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( |
| 45 attributes); | 54 attributes); |
| 55 return ScopedStubInstallAttributes(); |
| 56 } |
| 57 |
| 58 // static |
| 59 ScopedStubInstallAttributes ScopedStubInstallAttributes::CreateEnterprise( |
| 60 const std::string& domain, |
| 61 const std::string& device_id) { |
| 62 StubInstallAttributes* attributes = new StubInstallAttributes(); |
| 63 attributes->SetEnterprise(domain, device_id); |
| 64 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( |
| 65 attributes); |
| 66 return ScopedStubInstallAttributes(); |
| 67 } |
| 68 |
| 69 ScopedStubInstallAttributes::ScopedStubInstallAttributes() { |
| 46 } | 70 } |
| 47 | 71 |
| 48 ScopedStubInstallAttributes::~ScopedStubInstallAttributes() { | 72 ScopedStubInstallAttributes::~ScopedStubInstallAttributes() { |
| 49 policy::BrowserPolicyConnectorChromeOS::RemoveInstallAttributesForTesting(); | 73 policy::BrowserPolicyConnectorChromeOS::RemoveInstallAttributesForTesting(); |
| 50 } | 74 } |
| 51 | 75 |
| 52 } // namespace chromeos | 76 } // namespace chromeos |
| OLD | NEW |