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

Unified Diff: chrome/browser/chromeos/arc/arc_policy_bridge.cc

Issue 1869783006: Revert of Pass policy VideoCaptureAllowed to ARC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/arc/arc_policy_bridge.cc
diff --git a/chrome/browser/chromeos/arc/arc_policy_bridge.cc b/chrome/browser/chromeos/arc/arc_policy_bridge.cc
index 15f7bf78cb47343bf12fd9fc865f9a94de5293b3..e472d9ad5d5cfe7b2903ad00a0e400ded09f0c7f 100644
--- a/chrome/browser/chromeos/arc/arc_policy_bridge.cc
+++ b/chrome/browser/chromeos/arc/arc_policy_bridge.cc
@@ -4,9 +4,6 @@
#include "chrome/browser/chromeos/arc/arc_policy_bridge.h"
-#include <string>
-
-#include "base/json/json_reader.h"
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
#include "base/values.h"
@@ -20,60 +17,6 @@
#include "policy/policy_constants.h"
namespace arc {
-
-namespace {
-
-// invert_bool_value: If the Chrome policy and the ARC policy with boolean value
-// have opposite semantics, set this to true so the bool is inverted before
-// being added. Otherwise, set it to false.
-void AddPolicy(const std::string arc_policy_name,
- const std::string policy_name,
- const policy::PolicyMap& policy_map,
- bool invert_bool_value,
- base::DictionaryValue& filtered_policies) {
- const base::Value* const policy_value = policy_map.GetValue(policy_name);
- if (policy_value) {
- if (invert_bool_value && policy_value->IsType(base::Value::TYPE_BOOLEAN)) {
- bool bool_value;
- policy_value->GetAsBoolean(&bool_value);
- filtered_policies.SetBoolean(arc_policy_name, !bool_value);
- } else {
- filtered_policies.Set(arc_policy_name,
- policy_value->CreateDeepCopy().release());
- }
- }
-}
-
-std::string GetFilteredJSONPolicies(const policy::PolicyMap& policy_map) {
- base::DictionaryValue filtered_policies;
- // Parse ArcApplicationPolicy as JSON string before adding other policies to
- // the dictionary.
- const base::Value* const app_policy_value =
- policy_map.GetValue(policy::key::kArcApplicationPolicy);
- if (app_policy_value) {
- std::string app_policy_string;
- app_policy_value->GetAsString(&app_policy_string);
- std::unique_ptr<base::DictionaryValue> app_policy_dict =
- base::DictionaryValue::From(base::JSONReader::Read(app_policy_string));
- if (app_policy_dict) {
- filtered_policies.Swap(app_policy_dict.get());
- } else {
- LOG(ERROR) << "Value of ArcApplicationPolicy has invalid format: "
- << app_policy_string;
- }
- }
-
- // Keep them sorted by the ARC policy names.
- AddPolicy("cameraDisabled", policy::key::kVideoCaptureAllowed, policy_map,
- true, filtered_policies);
-
- std::string policy_json;
- JSONStringValueSerializer serializer(&policy_json);
- serializer.Serialize(filtered_policies);
- return policy_json;
-}
-
-} // namespace
ArcPolicyBridge::ArcPolicyBridge(ArcBridgeService* bridge_service)
: ArcService(bridge_service), binding_(this) {
@@ -146,4 +89,23 @@
->policy_service();
}
+std::string ArcPolicyBridge::GetFilteredJSONPolicies(
+ const policy::PolicyMap& policy_map) {
+ // TODO(phweiss): Implement general filtering mechanism when more policies
+ // need to be passed on.
+ // Create dictionary with the desired policies.
+ base::DictionaryValue filtered_policies;
+ const std::string policy_name = policy::key::kArcApplicationPolicy;
+ const base::Value* const policy_value = policy_map.GetValue(policy_name);
+ if (policy_value) {
+ filtered_policies.Set(policy_name,
+ policy_value->CreateDeepCopy().release());
+ }
+ // Convert dictionary to JSON.
+ std::string policy_json;
+ JSONStringValueSerializer serializer(&policy_json);
+ serializer.Serialize(filtered_policies);
+ return policy_json;
+}
+
} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/arc/arc_policy_bridge.h ('k') | chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698