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

Side by Side Diff: chrome/browser/chromeos/arc/arc_policy_bridge.cc

Issue 1877803002: Rename ArcApplicationPolicy to ArcPolicy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@managed_cros
Patch Set: Updated histograms.xml 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 unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
40 filtered_policies.SetBoolean(arc_policy_name, !bool_value); 40 filtered_policies.SetBoolean(arc_policy_name, !bool_value);
41 } else { 41 } else {
42 filtered_policies.Set(arc_policy_name, 42 filtered_policies.Set(arc_policy_name,
43 policy_value->CreateDeepCopy().release()); 43 policy_value->CreateDeepCopy().release());
44 } 44 }
45 } 45 }
46 } 46 }
47 47
48 std::string GetFilteredJSONPolicies(const policy::PolicyMap& policy_map) { 48 std::string GetFilteredJSONPolicies(const policy::PolicyMap& policy_map) {
49 base::DictionaryValue filtered_policies; 49 base::DictionaryValue filtered_policies;
50 // Parse ArcApplicationPolicy as JSON string before adding other policies to 50 // Parse ArcPolicy as JSON string before adding other policies to the
51 // the dictionary. 51 // dictionary.
52 const base::Value* const app_policy_value = 52 const base::Value* const app_policy_value =
53 policy_map.GetValue(policy::key::kArcApplicationPolicy); 53 policy_map.GetValue(policy::key::kArcPolicy);
54 if (app_policy_value) { 54 if (app_policy_value) {
55 std::string app_policy_string; 55 std::string app_policy_string;
56 app_policy_value->GetAsString(&app_policy_string); 56 app_policy_value->GetAsString(&app_policy_string);
57 std::unique_ptr<base::DictionaryValue> app_policy_dict = 57 std::unique_ptr<base::DictionaryValue> app_policy_dict =
58 base::DictionaryValue::From(base::JSONReader::Read(app_policy_string)); 58 base::DictionaryValue::From(base::JSONReader::Read(app_policy_string));
59 if (app_policy_dict) { 59 if (app_policy_dict) {
60 // Need a deep copy of all values here instead of doing a swap, because 60 // Need a deep copy of all values here instead of doing a swap, because
61 // JSONReader::Read constructs a dictionary whose StringValues are 61 // JSONReader::Read constructs a dictionary whose StringValues are
62 // JSONStringValues which are based on StringPiece instead of string. 62 // JSONStringValues which are based on StringPiece instead of string.
63 filtered_policies.MergeDictionary(app_policy_dict.get()); 63 filtered_policies.MergeDictionary(app_policy_dict.get());
64 } else { 64 } else {
65 LOG(ERROR) << "Value of ArcApplicationPolicy has invalid format: " 65 LOG(ERROR) << "Value of ArcPolicy has invalid format: "
66 << app_policy_string; 66 << app_policy_string;
67 } 67 }
68 } 68 }
69 69
70 // Keep them sorted by the ARC policy names. 70 // Keep them sorted by the ARC policy names.
71 AddPolicy("cameraDisabled", policy::key::kVideoCaptureAllowed, policy_map, 71 AddPolicy("cameraDisabled", policy::key::kVideoCaptureAllowed, policy_map,
72 true, filtered_policies); 72 true, filtered_policies);
73 73
74 std::string policy_json; 74 std::string policy_json;
75 JSONStringValueSerializer serializer(&policy_json); 75 JSONStringValueSerializer serializer(&policy_json);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 const user_manager::User* const primary_user = 144 const user_manager::User* const primary_user =
145 user_manager::UserManager::Get()->GetPrimaryUser(); 145 user_manager::UserManager::Get()->GetPrimaryUser();
146 Profile* const profile = 146 Profile* const profile =
147 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); 147 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user);
148 policy_service_ = 148 policy_service_ =
149 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile) 149 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile)
150 ->policy_service(); 150 ->policy_service();
151 } 151 }
152 152
153 } // namespace arc 153 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698