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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_policy_bridge.cc
diff --git a/chrome/browser/chromeos/arc/arc_policy_bridge.cc b/chrome/browser/chromeos/arc/arc_policy_bridge.cc
new file mode 100644
index 0000000000000000000000000000000000000000..93d34265584ab82bccda4855cbc5b34b13fd176f
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_policy_bridge.cc
@@ -0,0 +1,74 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/arc/arc_policy_bridge.h"
+
+#include "base/logging.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/policy/profile_policy_connector.h"
+#include "chrome/browser/policy/profile_policy_connector_factory.h"
+#include "components/policy/core/common/policy_map.h"
+#include "components/policy/core/common/policy_namespace.h"
+#include "components/user_manager/user.h"
+#include "mojo/public/cpp/bindings/string.h"
+
+namespace arc {
+
+ArcPolicyBridge::ArcPolicyBridge(ArcBridgeService* bridge_service)
+ : ArcService(bridge_service), binding_(this) {
+ VLOG(1) << "ArcPolicyBridge::ArcPolicyBridge";
+ arc_bridge_service()->AddObserver(this);
+}
+
+ArcPolicyBridge::~ArcPolicyBridge() {
+ VLOG(1) << "ArcPolicyBridge::~ArcPolicyBridge";
+ arc_bridge_service()->RemoveObserver(this);
+}
+
+void ArcPolicyBridge::OnPolicyInstanceReady() {
+ VLOG(1) << "ArcPolicyBridge::OnPolicyInstanceReady";
+ const user_manager::UserList& user_list =
+ user_manager::UserManager::Get()->GetLoggedInUsers();
+ 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.
+ Profile* const profile =
+ chromeos::ProfileHelper::Get()->GetProfileByUser(user_list.front());
+ policy_service_ =
+ policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile)
+ ->policy_service();
+ policy_service_->AddObserver(policy::POLICY_DOMAIN_CHROME, this);
+
+ PolicyInstance* const policy_instance =
+ arc_bridge_service()->policy_instance();
+ if (!policy_instance) {
+ LOG(ERROR) << "OnPolicyInstanceReady called, but no policy instance found";
+ return;
+ }
+
+ policy_instance->Init(binding_.CreateInterfacePtrAndBind());
+}
+
+void ArcPolicyBridge::OnPolicyInstanceClosed() {
+ VLOG(1) << "ArcPolicyBridge::OnPolicyInstanceClosed";
+ policy_service_->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this);
+ policy_service_ = nullptr;
+}
+
+void ArcPolicyBridge::GetPolicy(const GetPolicyCallback& callback) {
+ VLOG(1) << "ArcPolicyBridge::GetPolicy";
+ // 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
+ const std::string stub_policy =
+ "{\"applications\":[{\"packageName\":"
+ "\"com.android.chrome\",\"installType\":\"REQUIRED\",\"lockTaskAllowed\":"
+ "false,\"permissionGrants\":[]}]}";
+ callback.Run(mojo::String(stub_policy));
+}
+
+void ArcPolicyBridge::OnPolicyUpdated(const policy::PolicyNamespace& ns,
+ const policy::PolicyMap& previous,
+ const policy::PolicyMap& current) {
+ VLOG(1) << "ArcPolicyBridge::OnPolicyUpdated";
+ 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.
+}
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698