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

Unified Diff: chrome/browser/policy/configuration_policy_handler.cc

Issue 8480003: Surface error messages from ONC parsing in about:policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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/policy/configuration_policy_handler.cc
diff --git a/chrome/browser/policy/configuration_policy_handler.cc b/chrome/browser/policy/configuration_policy_handler.cc
index 5d4b25256035b9ffe75476799a2d9a45389a97bc..acd96463eed10fbdcf4f6bb5709ed5a7734d9e34 100644
--- a/chrome/browser/policy/configuration_policy_handler.cc
+++ b/chrome/browser/policy/configuration_policy_handler.cc
@@ -31,38 +31,16 @@
#include "policy/configuration_policy_type.h"
#include "policy/policy_constants.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/policy/configuration_policy_handler_chromeos.h"
+#endif
+
namespace policy {
namespace {
// Implementations of ConfigurationPolicyHandler -------------------------------
-// Abstract class derived from ConfigurationPolicyHandler that should be
-// subclassed to handle a single policy (not a combination of policies).
-class TypeCheckingPolicyHandler : public ConfigurationPolicyHandler {
- public:
- TypeCheckingPolicyHandler(ConfigurationPolicyType policy_type,
- base::Value::Type value_type);
-
- // ConfigurationPolicyHandler methods:
- virtual bool CheckPolicySettings(const PolicyMap* policies,
- PolicyErrorMap* errors) OVERRIDE;
-
- protected:
- virtual ~TypeCheckingPolicyHandler();
-
- ConfigurationPolicyType policy_type() const;
-
- private:
- // The ConfigurationPolicyType of the policy.
- ConfigurationPolicyType policy_type_;
-
- // The type the value of the policy should have.
- base::Value::Type value_type_;
-
- DISALLOW_COPY_AND_ASSIGN(TypeCheckingPolicyHandler);
-};
-
// ConfigurationPolicyHandler for policies that map directly to a preference.
class SimplePolicyHandler : public TypeCheckingPolicyHandler {
public:
@@ -256,7 +234,7 @@ class ProxyPolicyHandler : public ConfigurationPolicyHandler {
DISALLOW_COPY_AND_ASSIGN(ProxyPolicyHandler);
};
-//
+// ConfigurationPolicyHandler for policies that enable/disable Javascript.
class JavascriptPolicyHandler : public ConfigurationPolicyHandler {
public:
JavascriptPolicyHandler();
@@ -272,7 +250,6 @@ class JavascriptPolicyHandler : public ConfigurationPolicyHandler {
DISALLOW_COPY_AND_ASSIGN(JavascriptPolicyHandler);
};
-
// Helper classes --------------------------------------------------------------
// Implementation of SearchTermsData just for validation.
@@ -538,35 +515,6 @@ std::string ValueTypeToString(Value::Type type) {
}
-// TypeCheckingPolicyHandler implementation ------------------------------------
-
-TypeCheckingPolicyHandler::TypeCheckingPolicyHandler(
- ConfigurationPolicyType policy_type,
- Value::Type value_type)
- : policy_type_(policy_type),
- value_type_(value_type) {
-}
-
-TypeCheckingPolicyHandler::~TypeCheckingPolicyHandler() {
-}
-
-ConfigurationPolicyType TypeCheckingPolicyHandler::policy_type() const {
- return policy_type_;
-}
-
-bool TypeCheckingPolicyHandler::CheckPolicySettings(const PolicyMap* policies,
- PolicyErrorMap* errors) {
- const Value* value = policies->Get(policy_type_);
- if (value && value_type_ != value->GetType()) {
- errors->AddError(policy_type_,
- IDS_POLICY_TYPE_ERROR,
- ValueTypeToString(value_type_));
- return false;
- }
- return true;
-}
-
-
// SimplePolicyHandler implementation ------------------------------------------
SimplePolicyHandler::SimplePolicyHandler(
@@ -1293,7 +1241,6 @@ void JavascriptPolicyHandler::ApplyPolicySettings(const PolicyMap* policies,
Value::CreateIntegerValue(setting));
}
-
} // namespace
@@ -1324,7 +1271,51 @@ ConfigurationPolicyHandler::HandlerList*
list->push_back(new DownloadDirPolicyHandler());
#endif // !defined(OS_CHROME0S)
+#if defined(OS_CHROMEOS)
+ list->push_back(
+ new NetworkConfigurationPolicyHandler(
+ kPolicyDeviceOpenNetworkConfiguration));
+ list->push_back(
+ new NetworkConfigurationPolicyHandler(
+ kPolicyOpenNetworkConfiguration));
+#endif
+
return list;
}
+// TypeCheckingPolicyHandler implementation ------------------------------------
+
+TypeCheckingPolicyHandler::TypeCheckingPolicyHandler(
+ ConfigurationPolicyType policy_type,
+ Value::Type value_type)
+ : policy_type_(policy_type),
+ value_type_(value_type) {
+}
+
+TypeCheckingPolicyHandler::~TypeCheckingPolicyHandler() {
+}
+
+ConfigurationPolicyType TypeCheckingPolicyHandler::policy_type() const {
+ return policy_type_;
+}
+
+bool TypeCheckingPolicyHandler::CheckPolicySettings(const PolicyMap* policies,
+ PolicyErrorMap* errors) {
+ const Value* value = NULL;
+ return CheckAndGetValue(policies, errors, &value);
+}
+
+bool TypeCheckingPolicyHandler::CheckAndGetValue(const PolicyMap* policies,
+ PolicyErrorMap* errors,
+ const Value** value) {
+ *value = policies->Get(policy_type_);
+ if (*value && !(*value)->IsType(value_type_)) {
+ errors->AddError(policy_type_,
+ IDS_POLICY_TYPE_ERROR,
+ ValueTypeToString(value_type_));
+ return false;
+ }
+ return true;
+}
+
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698