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

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: Clarify comments 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::User* const active_user =
32 user_manager::UserManager::Get()->GetActiveUser();
33 Profile* const profile =
34 chromeos::ProfileHelper::Get()->GetProfileByUser(active_user);
35 policy_service_ =
36 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile)
37 ->policy_service();
38 policy_service_->AddObserver(policy::POLICY_DOMAIN_CHROME, this);
39
40 PolicyInstance* const policy_instance =
41 arc_bridge_service()->policy_instance();
42 if (!policy_instance) {
43 LOG(ERROR) << "OnPolicyInstanceReady called, but no policy instance found";
44 return;
45 }
46
47 policy_instance->Init(binding_.CreateInterfacePtrAndBind());
48 }
49
50 void ArcPolicyBridge::OnPolicyInstanceClosed() {
51 VLOG(1) << "ArcPolicyBridge::OnPolicyInstanceClosed";
52 policy_service_->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this);
53 policy_service_ = nullptr;
54 }
55
56 void ArcPolicyBridge::GetPolicy(const GetPolicyCallback& callback) {
57 VLOG(1) << "ArcPolicyBridge::GetPolicy";
58 // TODO(phweiss): Get actual policy
59 const std::string stub_policy =
60 "{\"applications\":[{\"packageName\":"
61 "\"com.android.chrome\",\"installType\":\"REQUIRED\",\"lockTaskAllowed\":"
62 "false,\"permissionGrants\":[]}]}";
63 callback.Run(mojo::String(stub_policy));
64 }
65
66 void ArcPolicyBridge::OnPolicyUpdated(const policy::PolicyNamespace& ns,
67 const policy::PolicyMap& previous,
68 const policy::PolicyMap& current) {
69 VLOG(1) << "ArcPolicyBridge::OnPolicyUpdated";
70 DCHECK(arc_bridge_service()->policy_instance() != NULL);
Luis Héctor Chávez 2016/03/17 15:57:49 nit: prefer |nullptr| over |NULL|. Also, you can j
phweiss 2016/03/17 16:07:40 Done.
71 arc_bridge_service()->policy_instance()->OnPolicyChanged();
72 }
73
74 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_policy_bridge.h ('k') | chrome/browser/chromeos/arc/arc_service_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698