summaryrefslogtreecommitdiffstats
path: root/android_webview/browser/aw_browser_policy_connector.cc
blob: f3123f5328151390df7c2e67c332f7e4de8b6e23 (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
67
// 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.

#include "android_webview/browser/aw_browser_policy_connector.h"

#include "android_webview/browser/aw_browser_context.h"
#include "base/bind.h"
#include "components/policy/core/browser/android/android_combined_policy_provider.h"
#include "components/policy/core/browser/configuration_policy_handler_list.h"
#include "components/policy/core/browser/url_blacklist_policy_handler.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "net/url_request/url_request_context_getter.h"
#include "policy/policy_constants.h"

namespace android_webview {

namespace {

// Callback only used in ChromeOS. No-op here.
void PopulatePolicyHandlerParameters(
    policy::PolicyHandlerParameters* parameters) {}

// Used to check if a policy is deprecated. Currently bypasses that check.
const policy::PolicyDetails* GetChromePolicyDetails(const std::string& policy) {
  return nullptr;
}

// Factory for the handlers that will be responsible for converting the policies
// to the associated preferences.
scoped_ptr<policy::ConfigurationPolicyHandlerList> BuildHandlerList(
    const policy::Schema& chrome_schema) {
  scoped_ptr<policy::ConfigurationPolicyHandlerList> handlers(
      new policy::ConfigurationPolicyHandlerList(
          base::Bind(&PopulatePolicyHandlerParameters),
          base::Bind(&GetChromePolicyDetails)));

  // URL Filtering
  handlers->AddHandler(make_scoped_ptr(new policy::SimplePolicyHandler(
      policy::key::kURLWhitelist, policy::policy_prefs::kUrlWhitelist,
      base::Value::TYPE_LIST)));
  handlers->AddHandler(
      make_scoped_ptr(new policy::URLBlacklistPolicyHandler()));

  // HTTP Negotiate authentication
  handlers->AddHandler(make_scoped_ptr(new policy::SimplePolicyHandler(
      policy::key::kAuthServerWhitelist, prefs::kAuthServerWhitelist,
      base::Value::TYPE_STRING)));
  handlers->AddHandler(make_scoped_ptr(new policy::SimplePolicyHandler(
      policy::key::kAuthAndroidNegotiateAccountType,
      prefs::kAuthAndroidNegotiateAccountType, base::Value::TYPE_STRING)));

  return handlers;
}

}  // namespace

AwBrowserPolicyConnector::AwBrowserPolicyConnector()
   : BrowserPolicyConnectorBase(base::Bind(&BuildHandlerList)) {
  SetPlatformPolicyProvider(make_scoped_ptr(
      new policy::android::AndroidCombinedPolicyProvider(GetSchemaRegistry())));
  InitPolicyProviders();
}

AwBrowserPolicyConnector::~AwBrowserPolicyConnector() {}

}  // namespace android_webview