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

Unified Diff: chrome/browser/chromeos/policy/enterprise_install_attributes.h

Issue 397543005: Encapsulate data-format constants in EnterpriseInstallAttributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Julian's nit. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/enterprise_install_attributes.h
diff --git a/chrome/browser/chromeos/policy/enterprise_install_attributes.h b/chrome/browser/chromeos/policy/enterprise_install_attributes.h
index 9e6c5c8480c0baccebb5e99e6c88720f6cccb2d9..6fee78e50f944a4d10709589494d4f2fbec3b6e5 100644
--- a/chrome/browser/chromeos/policy/enterprise_install_attributes.h
+++ b/chrome/browser/chromeos/policy/enterprise_install_attributes.h
@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
+#include "base/gtest_prod_util.h"
#include "base/memory/weak_ptr.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "chromeos/dbus/dbus_method_call_status.h"
@@ -35,20 +36,9 @@ class EnterpriseInstallAttributes {
// A callback to handle responses of methods returning a LockResult value.
typedef base::Callback<void(LockResult lock_result)> LockResultCallback;
- // Constants for the possible device modes that can be stored in the lockbox.
- static const char kConsumerDeviceMode[];
- static const char kEnterpriseDeviceMode[];
- static const char kRetailKioskDeviceMode[];
- static const char kConsumerKioskDeviceMode[];
- static const char kUnknownDeviceMode[];
-
- // Field names in the lockbox.
- static const char kAttrEnterpriseDeviceId[];
- static const char kAttrEnterpriseDomain[];
- static const char kAttrEnterpriseMode[];
- static const char kAttrEnterpriseOwned[];
- static const char kAttrEnterpriseUser[];
- static const char kAttrConsumerKioskEnabled[];
+ // Return serialized InstallAttributes of an enterprise-owned configuration.
+ static std::string GetEnterpriseOwnedInstallAttributesBlobForTesting(
+ const std::string& user_name);
explicit EnterpriseInstallAttributes(
chromeos::CryptohomeClient* cryptohome_client);
@@ -106,6 +96,36 @@ class EnterpriseInstallAttributes {
DeviceMode registration_mode_;
private:
+ FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
+ DeviceLockedFromOlderVersion);
+ FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
+ ReadCacheFile);
+ FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
+ ReadCacheFileForConsumerKiosk);
+ FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
+ VerifyFakeInstallAttributesCache);
+
+ // Constants for the possible device modes that can be stored in the lockbox.
+ static const char kConsumerDeviceMode[];
+ static const char kEnterpriseDeviceMode[];
+ static const char kRetailKioskDeviceMode[];
+ static const char kConsumerKioskDeviceMode[];
+ static const char kUnknownDeviceMode[];
+
+ // Field names in the lockbox.
+ static const char kAttrEnterpriseDeviceId[];
+ static const char kAttrEnterpriseDomain[];
+ static const char kAttrEnterpriseMode[];
+ static const char kAttrEnterpriseOwned[];
+ static const char kAttrEnterpriseUser[];
+ static const char kAttrConsumerKioskEnabled[];
+
+ // Translates DeviceMode constants to strings used in the lockbox.
+ std::string GetDeviceModeString(DeviceMode mode);
+
+ // Translates strings used in the lockbox to DeviceMode values.
+ DeviceMode GetDeviceModeFromString(const std::string& mode);
+
// Decodes the install attributes provided in |attr_map|.
void DecodeInstallAttributes(
const std::map<std::string, std::string>& attr_map);

Powered by Google App Engine
This is Rietveld 408576698