summaryrefslogtreecommitdiffstats
path: root/chromium/components/policy/core/common/android/android_combined_policy_provider.h
blob: 03d1e32bca87ff59f157e2ceaced61650174d95e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2015 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.

#ifndef COMPONENTS_POLICY_CORE_COMMON_ANDROID_ANDROID_COMBINED_POLICY_PROVIDER_H_
#define COMPONENTS_POLICY_CORE_COMMON_ANDROID_ANDROID_COMBINED_POLICY_PROVIDER_H_

#include <jni.h>

#include <memory>

#include "base/android/scoped_java_ref.h"
#include "components/policy/core/common/configuration_policy_provider.h"
#include "components/policy/core/common/policy_bundle.h"
#include "components/policy/policy_export.h"

namespace policy {

class SchemaRegistry;

namespace android {

class PolicyConverter;

class POLICY_EXPORT AndroidCombinedPolicyProvider
    : public ConfigurationPolicyProvider {
 public:
  explicit AndroidCombinedPolicyProvider(SchemaRegistry* registry);
  AndroidCombinedPolicyProvider(const AndroidCombinedPolicyProvider&) = delete;
  AndroidCombinedPolicyProvider& operator=(
      const AndroidCombinedPolicyProvider&) = delete;

  ~AndroidCombinedPolicyProvider() override;

  // Push the polices updated by the Java policy providers to the core policy
  // system
  void FlushPolicies(JNIEnv* env,
                     const base::android::JavaParamRef<jobject>& obj);

  // Call this method to tell the policy system whether it should wait for
  // policies to be loaded by this provider. If this method is called,
  // IsInitializationComplete() will only return true after SetPolicies() has
  // been called at least once, otherwise it will return true immediately.
  static void SetShouldWaitForPolicy(bool should_wait_for_policy);

  // ConfigurationPolicyProvider:
  bool IsInitializationComplete(PolicyDomain domain) const override;
  bool IsFirstPolicyLoadComplete(PolicyDomain domain) const override;
  void RefreshPolicies() override;

  // For testing
  PolicyConverter* GetPolicyConverterForTesting() {
    return policy_converter_.get();
  }

 private:
  bool initialized_;
  std::unique_ptr<policy::android::PolicyConverter> policy_converter_;
  base::android::ScopedJavaGlobalRef<jobject> java_combined_policy_provider_;
};

}  // namespace android

}  // namespace policy

#endif  // COMPONENTS_POLICY_CORE_COMMON_ANDROID_ANDROID_COMBINED_POLICY_PROVIDER_H_