OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/arc/policy/arc_policy_bridge.h" | 5 #include "chrome/browser/chromeos/arc/policy/arc_policy_bridge.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // have opposite semantics, set this to true so the bool is inverted before | 46 // have opposite semantics, set this to true so the bool is inverted before |
47 // being added. Otherwise, set it to false. | 47 // being added. Otherwise, set it to false. |
48 void MapBoolToBool(const std::string& arc_policy_name, | 48 void MapBoolToBool(const std::string& arc_policy_name, |
49 const std::string& policy_name, | 49 const std::string& policy_name, |
50 const policy::PolicyMap& policy_map, | 50 const policy::PolicyMap& policy_map, |
51 bool invert_bool_value, | 51 bool invert_bool_value, |
52 base::DictionaryValue* filtered_policies) { | 52 base::DictionaryValue* filtered_policies) { |
53 const base::Value* const policy_value = policy_map.GetValue(policy_name); | 53 const base::Value* const policy_value = policy_map.GetValue(policy_name); |
54 if (!policy_value) | 54 if (!policy_value) |
55 return; | 55 return; |
56 if (!policy_value->IsType(base::Value::TYPE_BOOLEAN)) { | 56 if (!policy_value->IsType(base::Value::Type::BOOLEAN)) { |
57 LOG(ERROR) << "Policy " << policy_name << " is not a boolean."; | 57 LOG(ERROR) << "Policy " << policy_name << " is not a boolean."; |
58 return; | 58 return; |
59 } | 59 } |
60 bool bool_value; | 60 bool bool_value; |
61 policy_value->GetAsBoolean(&bool_value); | 61 policy_value->GetAsBoolean(&bool_value); |
62 filtered_policies->SetBoolean(arc_policy_name, | 62 filtered_policies->SetBoolean(arc_policy_name, |
63 bool_value != invert_bool_value); | 63 bool_value != invert_bool_value); |
64 } | 64 } |
65 | 65 |
66 // int_true: value of Chrome OS policy for which arc policy is set to true. | 66 // int_true: value of Chrome OS policy for which arc policy is set to true. |
67 // It is set to false for all other values. | 67 // It is set to false for all other values. |
68 void MapIntToBool(const std::string& arc_policy_name, | 68 void MapIntToBool(const std::string& arc_policy_name, |
69 const std::string& policy_name, | 69 const std::string& policy_name, |
70 const policy::PolicyMap& policy_map, | 70 const policy::PolicyMap& policy_map, |
71 int int_true, | 71 int int_true, |
72 base::DictionaryValue* filtered_policies) { | 72 base::DictionaryValue* filtered_policies) { |
73 const base::Value* const policy_value = policy_map.GetValue(policy_name); | 73 const base::Value* const policy_value = policy_map.GetValue(policy_name); |
74 if (!policy_value) | 74 if (!policy_value) |
75 return; | 75 return; |
76 if (!policy_value->IsType(base::Value::TYPE_INTEGER)) { | 76 if (!policy_value->IsType(base::Value::Type::INTEGER)) { |
77 LOG(ERROR) << "Policy " << policy_name << " is not an integer."; | 77 LOG(ERROR) << "Policy " << policy_name << " is not an integer."; |
78 return; | 78 return; |
79 } | 79 } |
80 int int_value; | 80 int int_value; |
81 policy_value->GetAsInteger(&int_value); | 81 policy_value->GetAsInteger(&int_value); |
82 filtered_policies->SetBoolean(arc_policy_name, int_value == int_true); | 82 filtered_policies->SetBoolean(arc_policy_name, int_value == int_true); |
83 } | 83 } |
84 | 84 |
85 void AddGlobalAppRestriction(const std::string& arc_app_restriction_name, | 85 void AddGlobalAppRestriction(const std::string& arc_app_restriction_name, |
86 const std::string& policy_name, | 86 const std::string& policy_name, |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 user_manager::UserManager::Get()->GetPrimaryUser(); | 379 user_manager::UserManager::Get()->GetPrimaryUser(); |
380 Profile* const profile = | 380 Profile* const profile = |
381 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); | 381 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); |
382 auto* profile_policy_connector = | 382 auto* profile_policy_connector = |
383 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile); | 383 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile); |
384 policy_service_ = profile_policy_connector->policy_service(); | 384 policy_service_ = profile_policy_connector->policy_service(); |
385 is_managed_ = profile_policy_connector->IsManaged(); | 385 is_managed_ = profile_policy_connector->IsManaged(); |
386 } | 386 } |
387 | 387 |
388 } // namespace arc | 388 } // namespace arc |
OLD | NEW |