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

Side by Side Diff: chrome/browser/chromeos/settings/stub_install_attributes.h

Issue 2403053003: Remove unused email from install attributes and add support for AD. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
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 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_STUB_INSTALL_ATTRIBUTES_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_STUB_INSTALL_ATTRIBUTES_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_STUB_INSTALL_ATTRIBUTES_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_STUB_INSTALL_ATTRIBUTES_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/chromeos/settings/install_attributes.h" 11 #include "chrome/browser/chromeos/settings/install_attributes.h"
12 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 12 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 // This class allows tests to override specific values for easier testing. 16 // This class allows tests to set specific configurations for testing.
17 // To make IsEnterpriseDevice() return true, set a non-empty registration
18 // user.
19 class StubInstallAttributes : public InstallAttributes { 17 class StubInstallAttributes : public InstallAttributes {
20 public: 18 public:
21 StubInstallAttributes(); 19 StubInstallAttributes();
22 20
23 void SetDomain(const std::string& domain); 21 // Setup as not-yet enrolled.
24 void SetRegistrationUser(const std::string& user); 22 void Clear();
25 void SetDeviceId(const std::string& id); 23
26 void SetMode(policy::DeviceMode mode); 24 // Setup as consumer device. (Clears existing configuration.)
25 void SetConsumer();
26
27 // Setup as enterprise enrolled. (Clears existing configuration.)
28 void SetEnterprise(const std::string& domain, const std::string& device_id);
27 29
28 private: 30 private:
29 DISALLOW_COPY_AND_ASSIGN(StubInstallAttributes); 31 DISALLOW_COPY_AND_ASSIGN(StubInstallAttributes);
30 }; 32 };
31 33
32 // Helper class to set install attributes in the scope of a test. 34 // Helper class to set install attributes in the scope of a test.
33 class ScopedStubInstallAttributes { 35 class ScopedStubInstallAttributes {
34 public: 36 public:
35 ScopedStubInstallAttributes(const std::string& domain,
36 const std::string& registration_user,
37 const std::string& device_id,
38 policy::DeviceMode mode);
39 ~ScopedStubInstallAttributes(); 37 ~ScopedStubInstallAttributes();
38
39 private:
40 friend ScopedStubInstallAttributes ScopedStubInstallAttributesUnset();
41 friend ScopedStubInstallAttributes ScopedStubInstallAttributesConsumer();
42 friend ScopedStubInstallAttributes ScopedStubInstallAttributesEnterprise(
43 const std::string& domain,
44 const std::string& device_id);
45 ScopedStubInstallAttributes();
40 }; 46 };
41 47
48 // Factory for empty (unset) ScopedStubInstallAttributes.
49 ScopedStubInstallAttributes ScopedStubInstallAttributesUnset();
emaxx 2016/10/11 17:26:37 Isn't it more common to make such simple factories
Thiemo Nagel 2016/10/11 18:23:30 Yes, you're right. Looks much better now. :)
50
51 // Factory for consumer-type ScopedStubInstallAttributes.
52 ScopedStubInstallAttributes ScopedStubInstallAttributesConsumer();
53
54 // Factory for enterprise-type ScopedStubInstallAttributes.
55 ScopedStubInstallAttributes ScopedStubInstallAttributesEnterprise(
56 const std::string& domain,
57 const std::string& device_id);
58
42 } // namespace chromeos 59 } // namespace chromeos
43 60
44 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_STUB_INSTALL_ATTRIBUTES_H_ 61 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_STUB_INSTALL_ATTRIBUTES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698