aw_browser_policy_connector.cc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2015 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. #include "android_webview/browser/aw_browser_policy_connector.h"
  5. #include <memory>
  6. #include "android_webview/browser/aw_browser_process.h"
  7. #include "android_webview/browser/enterprise_authentication_app_link_policy_handler.h"
  8. #include "base/bind.h"
  9. #include "components/policy/core/browser/configuration_policy_handler_list.h"
  10. #include "components/policy/core/browser/url_blocklist_policy_handler.h"
  11. #include "components/policy/core/common/android/android_combined_policy_provider.h"
  12. #include "components/policy/core/common/policy_details.h"
  13. #include "components/policy/core/common/policy_pref_names.h"
  14. #include "components/policy/policy_constants.h"
  15. #include "components/version_info/android/channel_getter.h"
  16. #include "components/version_info/channel.h"
  17. #include "net/url_request/url_request_context_getter.h"
  18. namespace android_webview {
  19. namespace {
  20. // Factory for the handlers that will be responsible for converting the policies
  21. // to the associated preferences.
  22. std::unique_ptr<policy::ConfigurationPolicyHandlerList> BuildHandlerList(
  23. const policy::Schema& chrome_schema) {
  24. version_info::Channel channel = version_info::android::GetChannel();
  25. std::unique_ptr<policy::ConfigurationPolicyHandlerList> handlers(
  26. new policy::ConfigurationPolicyHandlerList(
  27. policy::ConfigurationPolicyHandlerList::
  28. PopulatePolicyHandlerParametersCallback(),
  29. base::BindRepeating(&policy::GetChromePolicyDetails),
  30. channel != version_info::Channel::STABLE &&
  31. channel != version_info::Channel::BETA));
  32. // URL Filtering
  33. handlers->AddHandler(std::make_unique<policy::SimplePolicyHandler>(
  34. policy::key::kURLAllowlist, policy::policy_prefs::kUrlAllowlist,
  35. base::Value::Type::LIST));
  36. handlers->AddHandler(std::make_unique<policy::URLBlocklistPolicyHandler>(
  37. policy::key::kURLBlocklist));
  38. // HTTP Negotiate authentication
  39. handlers->AddHandler(std::make_unique<policy::SimplePolicyHandler>(
  40. policy::key::kAuthServerAllowlist, prefs::kAuthServerAllowlist,
  41. base::Value::Type::STRING));
  42. handlers->AddHandler(std::make_unique<policy::SimplePolicyHandler>(
  43. policy::key::kAuthAndroidNegotiateAccountType,
  44. prefs::kAuthAndroidNegotiateAccountType, base::Value::Type::STRING));
  45. handlers->AddHandler(
  46. std::make_unique<policy::EnterpriseAuthenticationAppLinkPolicyHandler>(
  47. policy::key::kEnterpriseAuthenticationAppLinkPolicy,
  48. prefs::kEnterpriseAuthAppLinkPolicy));
  49. return handlers;
  50. }
  51. } // namespace
  52. AwBrowserPolicyConnector::AwBrowserPolicyConnector()
  53. : BrowserPolicyConnectorBase(base::BindRepeating(&BuildHandlerList)) {}
  54. AwBrowserPolicyConnector::~AwBrowserPolicyConnector() = default;
  55. std::vector<std::unique_ptr<policy::ConfigurationPolicyProvider>>
  56. AwBrowserPolicyConnector::CreatePolicyProviders() {
  57. std::vector<std::unique_ptr<policy::ConfigurationPolicyProvider>> providers;
  58. providers.push_back(
  59. std::make_unique<policy::android::AndroidCombinedPolicyProvider>(
  60. GetSchemaRegistry()));
  61. return providers;
  62. }
  63. } // namespace android_webview