Commit 72c21f0e authored by Nikita Podguzov's avatar Nikita Podguzov Committed by Commit Bot

Rename External Data device policy handlers

Create DeviceCloudExternalDataPolicyHandler interface for External Data
device policies handlers.

Bug: 970174
Change-Id: Id9b6e540b95a27eb27cd461e8bf3553dcd7c7096
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648175Reviewed-by: default avatarDenis Kuznetsov <antrim@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Reviewed-by: default avatarLutz Justen <ljusten@chromium.org>
Reviewed-by: default avatarSean Kau <skau@chromium.org>
Commit-Queue: Nikita Podguzov <nikitapodguzov@google.com>
Cr-Commit-Position: refs/heads/master@{#669659}
parent e4cd6f9d
...@@ -1574,6 +1574,8 @@ source_set("chromeos") { ...@@ -1574,6 +1574,8 @@ source_set("chromeos") {
"policy/device_auto_update_time_restrictions_decoder.h", "policy/device_auto_update_time_restrictions_decoder.h",
"policy/device_auto_update_time_restrictions_utils.cc", "policy/device_auto_update_time_restrictions_utils.cc",
"policy/device_auto_update_time_restrictions_utils.h", "policy/device_auto_update_time_restrictions_utils.h",
"policy/device_cloud_external_data_policy_handler.cc",
"policy/device_cloud_external_data_policy_handler.h",
"policy/device_cloud_external_data_policy_observer.cc", "policy/device_cloud_external_data_policy_observer.cc",
"policy/device_cloud_external_data_policy_observer.h", "policy/device_cloud_external_data_policy_observer.h",
"policy/device_cloud_policy_initializer.cc", "policy/device_cloud_policy_initializer.cc",
...@@ -1598,8 +1600,8 @@ source_set("chromeos") { ...@@ -1598,8 +1600,8 @@ source_set("chromeos") {
"policy/device_local_account_policy_service.h", "policy/device_local_account_policy_service.h",
"policy/device_local_account_policy_store.cc", "policy/device_local_account_policy_store.cc",
"policy/device_local_account_policy_store.h", "policy/device_local_account_policy_store.h",
"policy/device_native_printers_handler.cc", "policy/device_native_printers_external_data_handler.cc",
"policy/device_native_printers_handler.h", "policy/device_native_printers_external_data_handler.h",
"policy/device_network_configuration_updater.cc", "policy/device_network_configuration_updater.cc",
"policy/device_network_configuration_updater.h", "policy/device_network_configuration_updater.h",
"policy/device_policy_cloud_external_data_manager.cc", "policy/device_policy_cloud_external_data_manager.cc",
...@@ -1609,12 +1611,12 @@ source_set("chromeos") { ...@@ -1609,12 +1611,12 @@ source_set("chromeos") {
"policy/device_policy_remover.h", "policy/device_policy_remover.h",
"policy/device_scheduled_update_checker.cc", "policy/device_scheduled_update_checker.cc",
"policy/device_scheduled_update_checker.h", "policy/device_scheduled_update_checker.h",
"policy/device_wallpaper_image_handler.cc", "policy/device_wallpaper_image_external_data_handler.cc",
"policy/device_wallpaper_image_handler.h", "policy/device_wallpaper_image_external_data_handler.h",
"policy/device_wifi_allowed_handler.cc", "policy/device_wifi_allowed_handler.cc",
"policy/device_wifi_allowed_handler.h", "policy/device_wifi_allowed_handler.h",
"policy/device_wilco_dtc_configuration_handler.cc", "policy/device_wilco_dtc_configuration_external_data_handler.cc",
"policy/device_wilco_dtc_configuration_handler.h", "policy/device_wilco_dtc_configuration_external_data_handler.h",
"policy/display_resolution_handler.cc", "policy/display_resolution_handler.cc",
"policy/display_resolution_handler.h", "policy/display_resolution_handler.h",
"policy/display_rotation_default_handler.cc", "policy/display_rotation_default_handler.cc",
...@@ -2563,7 +2565,7 @@ source_set("unit_tests") { ...@@ -2563,7 +2565,7 @@ source_set("unit_tests") {
"policy/device_cloud_policy_manager_chromeos_unittest.cc", "policy/device_cloud_policy_manager_chromeos_unittest.cc",
"policy/device_cloud_policy_store_chromeos_unittest.cc", "policy/device_cloud_policy_store_chromeos_unittest.cc",
"policy/device_local_account_policy_service_unittest.cc", "policy/device_local_account_policy_service_unittest.cc",
"policy/device_native_printers_handler_unittest.cc", "policy/device_native_printers_external_data_handler_unittest.cc",
"policy/device_policy_decoder_chromeos_unittest.cc", "policy/device_policy_decoder_chromeos_unittest.cc",
"policy/device_scheduled_update_checker_unittest.cc", "policy/device_scheduled_update_checker_unittest.cc",
"policy/dm_token_storage_unittest.cc", "policy/dm_token_storage_unittest.cc",
......
...@@ -29,19 +29,20 @@ ...@@ -29,19 +29,20 @@
#include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
#include "chrome/browser/chromeos/policy/device_local_account.h" #include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
#include "chrome/browser/chromeos/policy/device_native_printers_handler.h" #include "chrome/browser/chromeos/policy/device_native_printers_external_data_handler.h"
#include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h"
#include "chrome/browser/chromeos/policy/device_policy_cloud_external_data_manager.h" #include "chrome/browser/chromeos/policy/device_policy_cloud_external_data_manager.h"
#include "chrome/browser/chromeos/policy/device_scheduled_update_checker.h" #include "chrome/browser/chromeos/policy/device_scheduled_update_checker.h"
#include "chrome/browser/chromeos/policy/device_wallpaper_image_handler.h" #include "chrome/browser/chromeos/policy/device_wallpaper_image_external_data_handler.h"
#include "chrome/browser/chromeos/policy/device_wifi_allowed_handler.h" #include "chrome/browser/chromeos/policy/device_wifi_allowed_handler.h"
#include "chrome/browser/chromeos/policy/device_wilco_dtc_configuration_handler.h" #include "chrome/browser/chromeos/policy/device_wilco_dtc_configuration_external_data_handler.h"
#include "chrome/browser/chromeos/policy/enrollment_config.h" #include "chrome/browser/chromeos/policy/enrollment_config.h"
#include "chrome/browser/chromeos/policy/hostname_handler.h" #include "chrome/browser/chromeos/policy/hostname_handler.h"
#include "chrome/browser/chromeos/policy/minimum_version_policy_handler.h" #include "chrome/browser/chromeos/policy/minimum_version_policy_handler.h"
#include "chrome/browser/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.h" #include "chrome/browser/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.h"
#include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h"
#include "chrome/browser/chromeos/policy/tpm_auto_update_mode_policy_handler.h" #include "chrome/browser/chromeos/policy/tpm_auto_update_mode_policy_handler.h"
#include "chrome/browser/chromeos/printing/bulk_printers_calculator_factory.h"
#include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/device_settings_service.h" #include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chrome/browser/chromeos/system/timezone_util.h" #include "chrome/browser/chromeos/system/timezone_util.h"
...@@ -236,15 +237,6 @@ void BrowserPolicyConnectorChromeOS::Init( ...@@ -236,15 +237,6 @@ void BrowserPolicyConnectorChromeOS::Init(
std::make_unique<MinimumVersionPolicyHandler>( std::make_unique<MinimumVersionPolicyHandler>(
chromeos::CrosSettings::Get()); chromeos::CrosSettings::Get());
device_native_printers_handler_ =
std::make_unique<DeviceNativePrintersHandler>(GetPolicyService());
device_wallpaper_image_handler_ =
std::make_unique<DeviceWallpaperImageHandler>(local_state,
GetPolicyService());
device_wilco_dtc_configuration_handler_ =
std::make_unique<DeviceWilcoDtcConfigurationHandler>(GetPolicyService());
device_wifi_allowed_handler_ = device_wifi_allowed_handler_ =
std::make_unique<DeviceWiFiAllowedHandler>(chromeos::CrosSettings::Get()); std::make_unique<DeviceWiFiAllowedHandler>(chromeos::CrosSettings::Get());
...@@ -255,6 +247,16 @@ void BrowserPolicyConnectorChromeOS::Init( ...@@ -255,6 +247,16 @@ void BrowserPolicyConnectorChromeOS::Init(
device_scheduled_update_checker_ = device_scheduled_update_checker_ =
std::make_unique<DeviceScheduledUpdateChecker>( std::make_unique<DeviceScheduledUpdateChecker>(
chromeos::CrosSettings::Get()); chromeos::CrosSettings::Get());
device_cloud_external_data_policy_handlers_.emplace_back(
std::make_unique<policy::DeviceNativePrintersExternalDataHandler>(
GetPolicyService()));
device_cloud_external_data_policy_handlers_.emplace_back(
std::make_unique<policy::DeviceWallpaperImageExternalDataHandler>(
local_state, GetPolicyService()));
device_cloud_external_data_policy_handlers_.emplace_back(
std::make_unique<policy::DeviceWilcoDtcConfigurationExternalDataHandler>(
GetPolicyService()));
} }
void BrowserPolicyConnectorChromeOS::PreShutdown() { void BrowserPolicyConnectorChromeOS::PreShutdown() {
...@@ -286,14 +288,11 @@ void BrowserPolicyConnectorChromeOS::Shutdown() { ...@@ -286,14 +288,11 @@ void BrowserPolicyConnectorChromeOS::Shutdown() {
if (hostname_handler_) if (hostname_handler_)
hostname_handler_->Shutdown(); hostname_handler_->Shutdown();
if (device_native_printers_handler_) for (auto& device_cloud_external_data_policy_handler :
device_native_printers_handler_->Shutdown(); device_cloud_external_data_policy_handlers_) {
device_cloud_external_data_policy_handler->Shutdown();
if (device_wallpaper_image_handler_) }
device_wallpaper_image_handler_->Shutdown(); chromeos::BulkPrintersCalculatorFactory::Get()->ShutdownForDevice();
if (device_wilco_dtc_configuration_handler_)
device_wilco_dtc_configuration_handler_->Shutdown();
ChromeBrowserPolicyConnector::Shutdown(); ChromeBrowserPolicyConnector::Shutdown();
} }
......
...@@ -49,13 +49,11 @@ class DeviceWiFiAllowedHandler; ...@@ -49,13 +49,11 @@ class DeviceWiFiAllowedHandler;
struct EnrollmentConfig; struct EnrollmentConfig;
class HostnameHandler; class HostnameHandler;
class MinimumVersionPolicyHandler; class MinimumVersionPolicyHandler;
class DeviceNativePrintersHandler;
class DeviceWallpaperImageHandler;
class ProxyPolicyProvider; class ProxyPolicyProvider;
class ServerBackedStateKeysBroker; class ServerBackedStateKeysBroker;
class DeviceWilcoDtcConfigurationHandler;
class TPMAutoUpdateModePolicyHandler; class TPMAutoUpdateModePolicyHandler;
class DeviceScheduledUpdateChecker; class DeviceScheduledUpdateChecker;
class DeviceCloudExternalDataPolicyHandler;
// Extends ChromeBrowserPolicyConnector with the setup specific to Chrome OS. // Extends ChromeBrowserPolicyConnector with the setup specific to Chrome OS.
class BrowserPolicyConnectorChromeOS class BrowserPolicyConnectorChromeOS
...@@ -238,15 +236,13 @@ class BrowserPolicyConnectorChromeOS ...@@ -238,15 +236,13 @@ class BrowserPolicyConnectorChromeOS
std::unique_ptr<BluetoothPolicyHandler> bluetooth_policy_handler_; std::unique_ptr<BluetoothPolicyHandler> bluetooth_policy_handler_;
std::unique_ptr<HostnameHandler> hostname_handler_; std::unique_ptr<HostnameHandler> hostname_handler_;
std::unique_ptr<MinimumVersionPolicyHandler> minimum_version_policy_handler_; std::unique_ptr<MinimumVersionPolicyHandler> minimum_version_policy_handler_;
std::unique_ptr<DeviceNativePrintersHandler> device_native_printers_handler_;
std::unique_ptr<DeviceWallpaperImageHandler> device_wallpaper_image_handler_;
std::unique_ptr<DeviceWilcoDtcConfigurationHandler>
device_wilco_dtc_configuration_handler_;
std::unique_ptr<DeviceWiFiAllowedHandler> device_wifi_allowed_handler_; std::unique_ptr<DeviceWiFiAllowedHandler> device_wifi_allowed_handler_;
std::unique_ptr<TPMAutoUpdateModePolicyHandler> std::unique_ptr<TPMAutoUpdateModePolicyHandler>
tpm_auto_update_mode_policy_handler_; tpm_auto_update_mode_policy_handler_;
std::unique_ptr<DeviceScheduledUpdateChecker> std::unique_ptr<DeviceScheduledUpdateChecker>
device_scheduled_update_checker_; device_scheduled_update_checker_;
std::vector<std::unique_ptr<policy::DeviceCloudExternalDataPolicyHandler>>
device_cloud_external_data_policy_handlers_;
// This policy provider is used on Chrome OS to feed user policy into the // This policy provider is used on Chrome OS to feed user policy into the
// global PolicyService instance. This works by installing the cloud policy // global PolicyService instance. This works by installing the cloud policy
......
// Copyright 2019 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/policy/device_cloud_external_data_policy_handler.h"
namespace policy {
DeviceCloudExternalDataPolicyHandler::DeviceCloudExternalDataPolicyHandler() =
default;
} // namespace policy
// Copyright 2019 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 CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_EXTERNAL_DATA_POLICY_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_EXTERNAL_DATA_POLICY_HANDLER_H_
#include "chrome/browser/chromeos/policy/device_cloud_external_data_policy_observer.h"
namespace policy {
// Base class for handling per-device external resources like wallpaper or
// printers configuration.
class DeviceCloudExternalDataPolicyHandler
: public DeviceCloudExternalDataPolicyObserver::Delegate {
public:
DeviceCloudExternalDataPolicyHandler();
virtual void Shutdown() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(DeviceCloudExternalDataPolicyHandler);
};
} // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_EXTERNAL_DATA_POLICY_HANDLER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/policy/device_native_printers_handler.h" #include "chrome/browser/chromeos/policy/device_native_printers_external_data_handler.h"
#include <utility> #include <utility>
...@@ -21,37 +21,37 @@ base::WeakPtr<chromeos::BulkPrintersCalculator> GetBulkPrintersCalculator() { ...@@ -21,37 +21,37 @@ base::WeakPtr<chromeos::BulkPrintersCalculator> GetBulkPrintersCalculator() {
} // namespace } // namespace
DeviceNativePrintersHandler::DeviceNativePrintersHandler( DeviceNativePrintersExternalDataHandler::
PolicyService* policy_service) DeviceNativePrintersExternalDataHandler(PolicyService* policy_service)
: device_native_printers_observer_( : device_native_printers_observer_(
std::make_unique<DeviceCloudExternalDataPolicyObserver>( std::make_unique<DeviceCloudExternalDataPolicyObserver>(
policy_service, policy_service,
key::kDeviceNativePrinters, key::kDeviceNativePrinters,
this)) {} this)) {}
DeviceNativePrintersHandler::~DeviceNativePrintersHandler() {} DeviceNativePrintersExternalDataHandler::
~DeviceNativePrintersExternalDataHandler() = default;
void DeviceNativePrintersHandler::OnDeviceExternalDataSet( void DeviceNativePrintersExternalDataHandler::OnDeviceExternalDataSet(
const std::string& policy) { const std::string& policy) {
GetBulkPrintersCalculator()->ClearData(); GetBulkPrintersCalculator()->ClearData();
} }
void DeviceNativePrintersHandler::OnDeviceExternalDataCleared( void DeviceNativePrintersExternalDataHandler::OnDeviceExternalDataCleared(
const std::string& policy) { const std::string& policy) {
GetBulkPrintersCalculator()->ClearData(); GetBulkPrintersCalculator()->ClearData();
} }
void DeviceNativePrintersHandler::OnDeviceExternalDataFetched( void DeviceNativePrintersExternalDataHandler::OnDeviceExternalDataFetched(
const std::string& policy, const std::string& policy,
std::unique_ptr<std::string> data, std::unique_ptr<std::string> data,
const base::FilePath& file_path) { const base::FilePath& file_path) {
GetBulkPrintersCalculator()->SetData(std::move(data)); GetBulkPrintersCalculator()->SetData(std::move(data));
} }
void DeviceNativePrintersHandler::Shutdown() { void DeviceNativePrintersExternalDataHandler::Shutdown() {
if (device_native_printers_observer_) if (device_native_printers_observer_)
device_native_printers_observer_.reset(); device_native_printers_observer_.reset();
chromeos::BulkPrintersCalculatorFactory::Get()->Shutdown();
} }
} // namespace policy } // namespace policy
...@@ -2,40 +2,40 @@ ...@@ -2,40 +2,40 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_NATIVE_PRINTERS_HANDLER_H_ #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_NATIVE_PRINTERS_EXTERNAL_DATA_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_NATIVE_PRINTERS_HANDLER_H_ #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_NATIVE_PRINTERS_EXTERNAL_DATA_HANDLER_H_
#include <memory> #include <memory>
#include <string> #include <string>
#include "chrome/browser/chromeos/policy/device_cloud_external_data_policy_observer.h" #include "chrome/browser/chromeos/policy/device_cloud_external_data_policy_handler.h"
namespace policy { namespace policy {
class PolicyService; class PolicyService;
class DeviceNativePrintersHandler class DeviceNativePrintersExternalDataHandler
: public DeviceCloudExternalDataPolicyObserver::Delegate { : public DeviceCloudExternalDataPolicyHandler {
public: public:
explicit DeviceNativePrintersHandler(PolicyService* policy_service); explicit DeviceNativePrintersExternalDataHandler(
~DeviceNativePrintersHandler() override; PolicyService* policy_service);
~DeviceNativePrintersExternalDataHandler() override;
// DeviceCloudExternalDataPolicyObserver::Delegate: // DeviceCloudExternalDataPolicyHandler:
void OnDeviceExternalDataSet(const std::string& policy) override; void OnDeviceExternalDataSet(const std::string& policy) override;
void OnDeviceExternalDataCleared(const std::string& policy) override; void OnDeviceExternalDataCleared(const std::string& policy) override;
void OnDeviceExternalDataFetched(const std::string& policy, void OnDeviceExternalDataFetched(const std::string& policy,
std::unique_ptr<std::string> data, std::unique_ptr<std::string> data,
const base::FilePath& file_path) override; const base::FilePath& file_path) override;
void Shutdown() override;
void Shutdown();
private: private:
std::unique_ptr<DeviceCloudExternalDataPolicyObserver> std::unique_ptr<DeviceCloudExternalDataPolicyObserver>
device_native_printers_observer_; device_native_printers_observer_;
DISALLOW_COPY_AND_ASSIGN(DeviceNativePrintersHandler); DISALLOW_COPY_AND_ASSIGN(DeviceNativePrintersExternalDataHandler);
}; };
} // namespace policy } // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_NATIVE_PRINTERS_HANDLER_H_ #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_NATIVE_PRINTERS_EXTERNAL_DATA_HANDLER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/policy/device_native_printers_handler.h" #include "chrome/browser/chromeos/policy/device_native_printers_external_data_handler.h"
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -57,9 +57,9 @@ const char kDeviceNativePrintersContentsJson[] = R"json( ...@@ -57,9 +57,9 @@ const char kDeviceNativePrintersContentsJson[] = R"json(
} // namespace } // namespace
class DeviceNativePrintersHandlerTest : public testing::Test { class DeviceNativePrintersExternalDataHandlerTest : public testing::Test {
protected: protected:
DeviceNativePrintersHandlerTest() {} DeviceNativePrintersExternalDataHandlerTest() {}
// testing::Test // testing::Test
void SetUp() override { void SetUp() override {
...@@ -70,29 +70,33 @@ class DeviceNativePrintersHandlerTest : public testing::Test { ...@@ -70,29 +70,33 @@ class DeviceNativePrintersHandlerTest : public testing::Test {
EXPECT_CALL(policy_service_, EXPECT_CALL(policy_service_,
RemoveObserver(policy::POLICY_DOMAIN_CHROME, testing::_)) RemoveObserver(policy::POLICY_DOMAIN_CHROME, testing::_))
.Times(1); .Times(1);
device_native_printers_handler_ = device_native_printers_external_data_handler_ =
std::make_unique<DeviceNativePrintersHandler>(&policy_service_); std::make_unique<DeviceNativePrintersExternalDataHandler>(
&policy_service_);
external_printers_ = external_printers_ =
chromeos::BulkPrintersCalculatorFactory::Get()->GetForDevice(); chromeos::BulkPrintersCalculatorFactory::Get()->GetForDevice();
external_printers_->SetAccessMode( external_printers_->SetAccessMode(
chromeos::BulkPrintersCalculator::ALL_ACCESS); chromeos::BulkPrintersCalculator::ALL_ACCESS);
} }
void TearDown() override { device_native_printers_handler_->Shutdown(); } void TearDown() override {
device_native_printers_external_data_handler_->Shutdown();
}
protected: protected:
base::test::ScopedTaskEnvironment scoped_task_environment_; base::test::ScopedTaskEnvironment scoped_task_environment_;
MockPolicyService policy_service_; MockPolicyService policy_service_;
std::unique_ptr<DeviceNativePrintersHandler> device_native_printers_handler_; std::unique_ptr<DeviceNativePrintersExternalDataHandler>
device_native_printers_external_data_handler_;
base::WeakPtr<chromeos::BulkPrintersCalculator> external_printers_; base::WeakPtr<chromeos::BulkPrintersCalculator> external_printers_;
}; };
TEST_F(DeviceNativePrintersHandlerTest, OnDataFetched) { TEST_F(DeviceNativePrintersExternalDataHandlerTest, OnDataFetched) {
EXPECT_TRUE(external_printers_->GetPrinters().empty()); EXPECT_TRUE(external_printers_->GetPrinters().empty());
device_native_printers_handler_->OnDeviceExternalDataSet( device_native_printers_external_data_handler_->OnDeviceExternalDataSet(
key::kDeviceNativePrinters); key::kDeviceNativePrinters);
device_native_printers_handler_->OnDeviceExternalDataFetched( device_native_printers_external_data_handler_->OnDeviceExternalDataFetched(
key::kDeviceNativePrinters, key::kDeviceNativePrinters,
std::make_unique<std::string>(kDeviceNativePrintersContentsJson), std::make_unique<std::string>(kDeviceNativePrintersContentsJson),
base::FilePath()); base::FilePath());
...@@ -106,16 +110,16 @@ TEST_F(DeviceNativePrintersHandlerTest, OnDataFetched) { ...@@ -106,16 +110,16 @@ TEST_F(DeviceNativePrintersHandlerTest, OnDataFetched) {
EXPECT_EQ("Color Laser", printers.at("Second").display_name()); EXPECT_EQ("Color Laser", printers.at("Second").display_name());
} }
TEST_F(DeviceNativePrintersHandlerTest, OnDataCleared) { TEST_F(DeviceNativePrintersExternalDataHandlerTest, OnDataCleared) {
EXPECT_TRUE(external_printers_->GetPrinters().empty()); EXPECT_TRUE(external_printers_->GetPrinters().empty());
device_native_printers_handler_->OnDeviceExternalDataSet( device_native_printers_external_data_handler_->OnDeviceExternalDataSet(
key::kDeviceNativePrinters); key::kDeviceNativePrinters);
device_native_printers_handler_->OnDeviceExternalDataFetched( device_native_printers_external_data_handler_->OnDeviceExternalDataFetched(
key::kDeviceNativePrinters, key::kDeviceNativePrinters,
std::make_unique<std::string>(kDeviceNativePrintersContentsJson), std::make_unique<std::string>(kDeviceNativePrintersContentsJson),
base::FilePath()); base::FilePath());
device_native_printers_handler_->OnDeviceExternalDataCleared( device_native_printers_external_data_handler_->OnDeviceExternalDataCleared(
key::kDeviceNativePrinters); key::kDeviceNativePrinters);
scoped_task_environment_.RunUntilIdle(); scoped_task_environment_.RunUntilIdle();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/policy/device_wallpaper_image_handler.h" #include "chrome/browser/chromeos/policy/device_wallpaper_image_external_data_handler.h"
#include <utility> #include <utility>
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
namespace policy { namespace policy {
DeviceWallpaperImageHandler::DeviceWallpaperImageHandler( DeviceWallpaperImageExternalDataHandler::
PrefService* local_state, DeviceWallpaperImageExternalDataHandler(PrefService* local_state,
PolicyService* policy_service) PolicyService* policy_service)
: local_state_(local_state), : local_state_(local_state),
device_wallpaper_image_observer_( device_wallpaper_image_observer_(
std::make_unique<DeviceCloudExternalDataPolicyObserver>( std::make_unique<DeviceCloudExternalDataPolicyObserver>(
...@@ -23,20 +23,22 @@ DeviceWallpaperImageHandler::DeviceWallpaperImageHandler( ...@@ -23,20 +23,22 @@ DeviceWallpaperImageHandler::DeviceWallpaperImageHandler(
key::kDeviceWallpaperImage, key::kDeviceWallpaperImage,
this)) {} this)) {}
DeviceWallpaperImageHandler::~DeviceWallpaperImageHandler() = default; DeviceWallpaperImageExternalDataHandler::
~DeviceWallpaperImageExternalDataHandler() = default;
// static // static
void DeviceWallpaperImageHandler::RegisterPrefs(PrefRegistrySimple* registry) { void DeviceWallpaperImageExternalDataHandler::RegisterPrefs(
PrefRegistrySimple* registry) {
registry->RegisterStringPref(prefs::kDeviceWallpaperImageFilePath, registry->RegisterStringPref(prefs::kDeviceWallpaperImageFilePath,
std::string()); std::string());
} }
void DeviceWallpaperImageHandler::OnDeviceExternalDataCleared( void DeviceWallpaperImageExternalDataHandler::OnDeviceExternalDataCleared(
const std::string& policy) { const std::string& policy) {
local_state_->SetString(prefs::kDeviceWallpaperImageFilePath, std::string()); local_state_->SetString(prefs::kDeviceWallpaperImageFilePath, std::string());
} }
void DeviceWallpaperImageHandler::OnDeviceExternalDataFetched( void DeviceWallpaperImageExternalDataHandler::OnDeviceExternalDataFetched(
const std::string& policy, const std::string& policy,
std::unique_ptr<std::string> data, std::unique_ptr<std::string> data,
const base::FilePath& file_path) { const base::FilePath& file_path) {
...@@ -44,7 +46,7 @@ void DeviceWallpaperImageHandler::OnDeviceExternalDataFetched( ...@@ -44,7 +46,7 @@ void DeviceWallpaperImageHandler::OnDeviceExternalDataFetched(
file_path.value()); file_path.value());
} }
void DeviceWallpaperImageHandler::Shutdown() { void DeviceWallpaperImageExternalDataHandler::Shutdown() {
device_wallpaper_image_observer_.reset(); device_wallpaper_image_observer_.reset();
} }
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WALLPAPER_IMAGE_HANDLER_H_ #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WALLPAPER_IMAGE_EXTERNAL_DATA_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WALLPAPER_IMAGE_HANDLER_H_ #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WALLPAPER_IMAGE_EXTERNAL_DATA_HANDLER_H_
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/chromeos/policy/device_cloud_external_data_policy_observer.h" #include "chrome/browser/chromeos/policy/device_cloud_external_data_policy_handler.h"
class PrefRegistrySimple; class PrefRegistrySimple;
class PrefService; class PrefService;
...@@ -21,22 +21,21 @@ class PolicyService; ...@@ -21,22 +21,21 @@ class PolicyService;
// This class observes the device setting "DeviceWallpaperImage", and sets // This class observes the device setting "DeviceWallpaperImage", and sets
// "policy.device_wallpaper_image_file_path" pref appropriately based on the // "policy.device_wallpaper_image_file_path" pref appropriately based on the
// file path with fetched wallpaper image. // file path with fetched wallpaper image.
class DeviceWallpaperImageHandler final class DeviceWallpaperImageExternalDataHandler final
: public DeviceCloudExternalDataPolicyObserver::Delegate { : public DeviceCloudExternalDataPolicyHandler {
public: public:
DeviceWallpaperImageHandler(PrefService* local_state, DeviceWallpaperImageExternalDataHandler(PrefService* local_state,
PolicyService* policy_service); PolicyService* policy_service);
~DeviceWallpaperImageHandler() override; ~DeviceWallpaperImageExternalDataHandler() override;
static void RegisterPrefs(PrefRegistrySimple* registry); static void RegisterPrefs(PrefRegistrySimple* registry);
// DeviceCloudExternalDataPolicyObserver::Delegate: // DeviceCloudExternalDataPolicyHandler:
void OnDeviceExternalDataCleared(const std::string& policy) override; void OnDeviceExternalDataCleared(const std::string& policy) override;
void OnDeviceExternalDataFetched(const std::string& policy, void OnDeviceExternalDataFetched(const std::string& policy,
std::unique_ptr<std::string> data, std::unique_ptr<std::string> data,
const base::FilePath& file_path) override; const base::FilePath& file_path) override;
void Shutdown() override;
void Shutdown();
private: private:
PrefService* const local_state_; PrefService* const local_state_;
...@@ -44,9 +43,9 @@ class DeviceWallpaperImageHandler final ...@@ -44,9 +43,9 @@ class DeviceWallpaperImageHandler final
std::unique_ptr<DeviceCloudExternalDataPolicyObserver> std::unique_ptr<DeviceCloudExternalDataPolicyObserver>
device_wallpaper_image_observer_; device_wallpaper_image_observer_;
DISALLOW_COPY_AND_ASSIGN(DeviceWallpaperImageHandler); DISALLOW_COPY_AND_ASSIGN(DeviceWallpaperImageExternalDataHandler);
}; };
} // namespace policy } // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WALLPAPER_IMAGE_HANDLER_H_ #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WALLPAPER_IMAGE_EXTERNAL_DATA_HANDLER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/policy/device_wilco_dtc_configuration_handler.h" #include "chrome/browser/chromeos/policy/device_wilco_dtc_configuration_external_data_handler.h"
#include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_manager.h" #include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_manager.h"
#include "components/policy/policy_constants.h" #include "components/policy/policy_constants.h"
...@@ -20,29 +20,31 @@ chromeos::WilcoDtcSupportdManager* GetWilcoDtcSupportdManager() { ...@@ -20,29 +20,31 @@ chromeos::WilcoDtcSupportdManager* GetWilcoDtcSupportdManager() {
} // namespace } // namespace
DeviceWilcoDtcConfigurationHandler::DeviceWilcoDtcConfigurationHandler( DeviceWilcoDtcConfigurationExternalDataHandler::
PolicyService* policy_service) DeviceWilcoDtcConfigurationExternalDataHandler(
PolicyService* policy_service)
: device_wilco_dtc_configuration_observer_( : device_wilco_dtc_configuration_observer_(
std::make_unique<DeviceCloudExternalDataPolicyObserver>( std::make_unique<DeviceCloudExternalDataPolicyObserver>(
policy_service, policy_service,
key::kDeviceWilcoDtcConfiguration, key::kDeviceWilcoDtcConfiguration,
this)) {} this)) {}
DeviceWilcoDtcConfigurationHandler::~DeviceWilcoDtcConfigurationHandler() {} DeviceWilcoDtcConfigurationExternalDataHandler::
~DeviceWilcoDtcConfigurationExternalDataHandler() = default;
void DeviceWilcoDtcConfigurationHandler::OnDeviceExternalDataCleared( void DeviceWilcoDtcConfigurationExternalDataHandler::
const std::string& policy) { OnDeviceExternalDataCleared(const std::string& policy) {
GetWilcoDtcSupportdManager()->SetConfigurationData(nullptr); GetWilcoDtcSupportdManager()->SetConfigurationData(nullptr);
} }
void DeviceWilcoDtcConfigurationHandler::OnDeviceExternalDataFetched( void DeviceWilcoDtcConfigurationExternalDataHandler::
const std::string& policy, OnDeviceExternalDataFetched(const std::string& policy,
std::unique_ptr<std::string> data, std::unique_ptr<std::string> data,
const base::FilePath& file_path) { const base::FilePath& file_path) {
GetWilcoDtcSupportdManager()->SetConfigurationData(std::move(data)); GetWilcoDtcSupportdManager()->SetConfigurationData(std::move(data));
} }
void DeviceWilcoDtcConfigurationHandler::Shutdown() { void DeviceWilcoDtcConfigurationExternalDataHandler::Shutdown() {
device_wilco_dtc_configuration_observer_.reset(); device_wilco_dtc_configuration_observer_.reset();
} }
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WILCO_DTC_CONFIGURATION_HANDLER_H_ #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WILCO_DTC_CONFIGURATION_EXTERNAL_DATA_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WILCO_DTC_CONFIGURATION_HANDLER_H_ #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WILCO_DTC_CONFIGURATION_EXTERNAL_DATA_HANDLER_H_
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/chromeos/policy/device_cloud_external_data_policy_observer.h" #include "chrome/browser/chromeos/policy/device_cloud_external_data_policy_handler.h"
namespace policy { namespace policy {
...@@ -18,27 +18,27 @@ class PolicyService; ...@@ -18,27 +18,27 @@ class PolicyService;
// This class observes the device setting "DeviceWilcoDtcConfiguration" and // This class observes the device setting "DeviceWilcoDtcConfiguration" and
// saves the wilco DTC (diagnostics and telemetry) controller configuration // saves the wilco DTC (diagnostics and telemetry) controller configuration
// received in JSON format. // received in JSON format.
class DeviceWilcoDtcConfigurationHandler final class DeviceWilcoDtcConfigurationExternalDataHandler final
: public DeviceCloudExternalDataPolicyObserver::Delegate { : public DeviceCloudExternalDataPolicyHandler {
public: public:
explicit DeviceWilcoDtcConfigurationHandler(PolicyService* policy_service); explicit DeviceWilcoDtcConfigurationExternalDataHandler(
~DeviceWilcoDtcConfigurationHandler() override; PolicyService* policy_service);
~DeviceWilcoDtcConfigurationExternalDataHandler() override;
// DeviceCloudExternalDataPolicyObserver::Delegate: // DeviceCloudExternalDataPolicyHandler:
void OnDeviceExternalDataCleared(const std::string& policy) override; void OnDeviceExternalDataCleared(const std::string& policy) override;
void OnDeviceExternalDataFetched(const std::string& policy, void OnDeviceExternalDataFetched(const std::string& policy,
std::unique_ptr<std::string> data, std::unique_ptr<std::string> data,
const base::FilePath& file_path) override; const base::FilePath& file_path) override;
void Shutdown() override;
void Shutdown();
private: private:
std::unique_ptr<DeviceCloudExternalDataPolicyObserver> std::unique_ptr<DeviceCloudExternalDataPolicyObserver>
device_wilco_dtc_configuration_observer_; device_wilco_dtc_configuration_observer_;
DISALLOW_COPY_AND_ASSIGN(DeviceWilcoDtcConfigurationHandler); DISALLOW_COPY_AND_ASSIGN(DeviceWilcoDtcConfigurationExternalDataHandler);
}; };
} // namespace policy } // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WILCO_DTC_CONFIGURATION_HANDLER_H_ #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_WILCO_DTC_CONFIGURATION_EXTERNAL_DATA_HANDLER_H_
...@@ -67,9 +67,8 @@ void BulkPrintersCalculatorFactory::ShutdownProfiles() { ...@@ -67,9 +67,8 @@ void BulkPrintersCalculatorFactory::ShutdownProfiles() {
printers_by_user_.clear(); printers_by_user_.clear();
} }
void BulkPrintersCalculatorFactory::Shutdown() { void BulkPrintersCalculatorFactory::ShutdownForDevice() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
printers_by_user_.clear();
device_printers_.reset(); device_printers_.reset();
} }
......
...@@ -47,8 +47,8 @@ class BulkPrintersCalculatorFactory { ...@@ -47,8 +47,8 @@ class BulkPrintersCalculatorFactory {
// Tear down all BulkPrintersCalculator created for users/profiles. // Tear down all BulkPrintersCalculator created for users/profiles.
void ShutdownProfiles(); void ShutdownProfiles();
// Tear down all BulkPrintersCalculator. // Tear down BulkPrintersCalculator created for the device.
void Shutdown(); void ShutdownForDevice();
private: private:
friend struct base::LazyInstanceTraitsBase<BulkPrintersCalculatorFactory>; friend struct base::LazyInstanceTraitsBase<BulkPrintersCalculatorFactory>;
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
#include "chrome/browser/chromeos/policy/auto_enrollment_client_impl.h" #include "chrome/browser/chromeos/policy/auto_enrollment_client_impl.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/policy/device_wallpaper_image_handler.h" #include "chrome/browser/chromeos/policy/device_wallpaper_image_external_data_handler.h"
#include "chrome/browser/chromeos/policy/dm_token_storage.h" #include "chrome/browser/chromeos/policy/dm_token_storage.h"
#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
#include "chrome/browser/chromeos/policy/status_collector/device_status_collector.h" #include "chrome/browser/chromeos/policy/status_collector/device_status_collector.h"
...@@ -635,7 +635,7 @@ void RegisterLocalState(PrefRegistrySimple* registry) { ...@@ -635,7 +635,7 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
policy::BrowserPolicyConnectorChromeOS::RegisterPrefs(registry); policy::BrowserPolicyConnectorChromeOS::RegisterPrefs(registry);
policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs(registry); policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs(registry);
policy::DeviceStatusCollector::RegisterPrefs(registry); policy::DeviceStatusCollector::RegisterPrefs(registry);
policy::DeviceWallpaperImageHandler::RegisterPrefs(registry); policy::DeviceWallpaperImageExternalDataHandler::RegisterPrefs(registry);
policy::DMTokenStorage::RegisterPrefs(registry); policy::DMTokenStorage::RegisterPrefs(registry);
policy::PolicyCertServiceFactory::RegisterPrefs(registry); policy::PolicyCertServiceFactory::RegisterPrefs(registry);
policy::TPMAutoUpdateModePolicyHandler::RegisterPrefs(registry); policy::TPMAutoUpdateModePolicyHandler::RegisterPrefs(registry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment