| 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/arc_policy_bridge.h" | 5 #include "chrome/browser/chromeos/arc/arc_policy_bridge.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 filtered_policies->Set(kArcGlobalAppRestrictions, | 59 filtered_policies->Set(kArcGlobalAppRestrictions, |
| 60 global_app_restrictions); | 60 global_app_restrictions); |
| 61 } | 61 } |
| 62 global_app_restrictions->SetWithoutPathExpansion( | 62 global_app_restrictions->SetWithoutPathExpansion( |
| 63 arc_app_restriction_name, policy_value->CreateDeepCopy()); | 63 arc_app_restriction_name, policy_value->CreateDeepCopy()); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 std::string GetFilteredJSONPolicies(const policy::PolicyMap& policy_map) { | 67 std::string GetFilteredJSONPolicies(const policy::PolicyMap& policy_map) { |
| 68 base::DictionaryValue filtered_policies; | 68 base::DictionaryValue filtered_policies; |
| 69 // Parse ArcApplicationPolicy as JSON string before adding other policies to | 69 // Parse ArcPolicy as JSON string before adding other policies to the |
| 70 // the dictionary. | 70 // dictionary. |
| 71 const base::Value* const app_policy_value = | 71 const base::Value* const app_policy_value = |
| 72 policy_map.GetValue(policy::key::kArcApplicationPolicy); | 72 policy_map.GetValue(policy::key::kArcPolicy); |
| 73 if (app_policy_value) { | 73 if (app_policy_value) { |
| 74 std::string app_policy_string; | 74 std::string app_policy_string; |
| 75 app_policy_value->GetAsString(&app_policy_string); | 75 app_policy_value->GetAsString(&app_policy_string); |
| 76 std::unique_ptr<base::DictionaryValue> app_policy_dict = | 76 std::unique_ptr<base::DictionaryValue> app_policy_dict = |
| 77 base::DictionaryValue::From(base::JSONReader::Read(app_policy_string)); | 77 base::DictionaryValue::From(base::JSONReader::Read(app_policy_string)); |
| 78 if (app_policy_dict) { | 78 if (app_policy_dict) { |
| 79 // Need a deep copy of all values here instead of doing a swap, because | 79 // Need a deep copy of all values here instead of doing a swap, because |
| 80 // JSONReader::Read constructs a dictionary whose StringValues are | 80 // JSONReader::Read constructs a dictionary whose StringValues are |
| 81 // JSONStringValues which are based on StringPiece instead of string. | 81 // JSONStringValues which are based on StringPiece instead of string. |
| 82 filtered_policies.MergeDictionary(app_policy_dict.get()); | 82 filtered_policies.MergeDictionary(app_policy_dict.get()); |
| 83 } else { | 83 } else { |
| 84 LOG(ERROR) << "Value of ArcApplicationPolicy has invalid format: " | 84 LOG(ERROR) << "Value of ArcPolicy has invalid format: " |
| 85 << app_policy_string; | 85 << app_policy_string; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Keep them sorted by the ARC policy names. | 89 // Keep them sorted by the ARC policy names. |
| 90 AddPolicy("cameraDisabled", policy::key::kVideoCaptureAllowed, policy_map, | 90 AddPolicy("cameraDisabled", policy::key::kVideoCaptureAllowed, policy_map, |
| 91 true, &filtered_policies); | 91 true, &filtered_policies); |
| 92 | 92 |
| 93 // Add global app restrictions. | 93 // Add global app restrictions. |
| 94 AddGlobalAppRestriction("com.android.browser:URLBlacklist", | 94 AddGlobalAppRestriction("com.android.browser:URLBlacklist", |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 const user_manager::User* const primary_user = | 171 const user_manager::User* const primary_user = |
| 172 user_manager::UserManager::Get()->GetPrimaryUser(); | 172 user_manager::UserManager::Get()->GetPrimaryUser(); |
| 173 Profile* const profile = | 173 Profile* const profile = |
| 174 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); | 174 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); |
| 175 policy_service_ = | 175 policy_service_ = |
| 176 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile) | 176 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile) |
| 177 ->policy_service(); | 177 ->policy_service(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace arc | 180 } // namespace arc |
| OLD | NEW |