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

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

Issue 1754803003: Implement Stub for policy bridge to ARC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Includes, Comments, and Formatting adjusted Created 4 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/arc/arc_policy_bridge.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/chromeos/profiles/profile_helper.h"
9 #include "chrome/browser/policy/profile_policy_connector.h"
10 #include "chrome/browser/policy/profile_policy_connector_factory.h"
11 #include "components/policy/core/common/policy_map.h"
12 #include "components/policy/core/common/policy_namespace.h"
13 #include "components/user_manager/user.h"
14 #include "mojo/public/cpp/bindings/string.h"
15
16 namespace arc {
17
18 ArcPolicyBridge::ArcPolicyBridge(ArcBridgeService* bridge_service)
19 : ArcService(bridge_service), binding_(this) {
20 VLOG(1) << "ArcPolicyBridge::ArcPolicyBridge";
21 arc_bridge_service()->AddObserver(this);
22 }
23
24 ArcPolicyBridge::~ArcPolicyBridge() {
25 VLOG(1) << "ArcPolicyBridge::~ArcPolicyBridge";
26 arc_bridge_service()->RemoveObserver(this);
27 }
28
29 void ArcPolicyBridge::OnPolicyInstanceReady() {
30 VLOG(1) << "ArcPolicyBridge::OnPolicyInstanceReady";
31 const user_manager::UserList& user_list =
32 user_manager::UserManager::Get()->GetLoggedInUsers();
33 DCHECK(user_list.size() == 1);
Luis Héctor Chávez 2016/03/15 18:01:56 Is it possible to change this for user_manager::Us
phweiss 2016/03/16 18:45:12 I changed this to using the active user.
Thiemo Nagel 2016/03/16 19:59:33 Primary user would make more sense to me but in pr
phweiss 2016/03/17 15:52:59 I dont have a preference, changed it to primary.
34 Profile* const profile =
35 chromeos::ProfileHelper::Get()->GetProfileByUser(user_list.front());
36 policy_service_ =
37 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile)
38 ->policy_service();
39 policy_service_->AddObserver(policy::POLICY_DOMAIN_CHROME, this);
40
41 PolicyInstance* const policy_instance =
42 arc_bridge_service()->policy_instance();
43 if (!policy_instance) {
44 LOG(ERROR) << "OnPolicyInstanceReady called, but no policy instance found";
45 return;
46 }
47
48 policy_instance->Init(binding_.CreateInterfacePtrAndBind());
49 }
50
51 void ArcPolicyBridge::OnPolicyInstanceClosed() {
52 VLOG(1) << "ArcPolicyBridge::OnPolicyInstanceClosed";
53 policy_service_->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this);
54 policy_service_ = nullptr;
55 }
56
57 void ArcPolicyBridge::GetPolicy(const GetPolicyCallback& callback) {
58 VLOG(1) << "ArcPolicyBridge::GetPolicy";
59 // TODO(phweiss): Get actual policies
Luis Héctor Chávez 2016/03/15 18:01:56 Regardless of the decision mentioned in policy.moj
phweiss 2016/03/17 15:52:59 Renamed the function to GetPolicies, also for cons
60 const std::string stub_policy =
61 "{\"applications\":[{\"packageName\":"
62 "\"com.android.chrome\",\"installType\":\"REQUIRED\",\"lockTaskAllowed\":"
63 "false,\"permissionGrants\":[]}]}";
64 callback.Run(mojo::String(stub_policy));
65 }
66
67 void ArcPolicyBridge::OnPolicyUpdated(const policy::PolicyNamespace& ns,
68 const policy::PolicyMap& previous,
69 const policy::PolicyMap& current) {
70 VLOG(1) << "ArcPolicyBridge::OnPolicyUpdated";
71 arc_bridge_service()->policy_instance()->OnPolicyChanged();
Luis Héctor Chávez 2016/03/15 18:01:56 It's probably a good idea to add DCHECKs that arc_
phweiss 2016/03/16 18:45:12 Done.
72 }
73
74 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698