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

Unified Diff: chrome/browser/policy/configuration_policy_handler_list_factory.cc

Issue 2581643002: Define a new policy to disable clearing the browsing history from the UI. (Closed)
Patch Set: less headers Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/resources/options/clear_browser_data_overlay.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/configuration_policy_handler_list_factory.cc
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
index d419d89617ab967cc393b067617d191c8a235dd0..36a8046c0d8b73cffce00136187cc47648f5b880 100644
--- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc
+++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -28,6 +28,7 @@
#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
+#include "components/browsing_data/core/pref_names.h"
#include "components/certificate_transparency/pref_names.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/metrics/metrics_pref_names.h"
@@ -696,6 +697,27 @@ class ForceYouTubeSafetyModePolicyHandler : public TypeCheckingPolicyHandler {
DISALLOW_COPY_AND_ASSIGN(ForceYouTubeSafetyModePolicyHandler);
};
+class BrowsingHistoryPolicyHandler : public TypeCheckingPolicyHandler {
+ public:
+ BrowsingHistoryPolicyHandler()
+ : TypeCheckingPolicyHandler(key::kAllowDeletingBrowserHistory,
+ base::Value::Type::BOOLEAN) {}
+ ~BrowsingHistoryPolicyHandler() override {}
+
+ void ApplyPolicySettings(const PolicyMap& policies,
+ PrefValueMap* prefs) override {
+ const base::Value* value = policies.GetValue(policy_name());
+ bool deleting_history_allowed;
+ if (value && value->GetAsBoolean(&deleting_history_allowed) &&
+ !deleting_history_allowed) {
+ prefs->SetBoolean(
+ browsing_data::prefs::kDeleteBrowsingHistory, false);
+ prefs->SetBoolean(
+ browsing_data::prefs::kDeleteDownloadHistory, false);
+ }
+ }
+};
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
void GetExtensionAllowedTypesMap(
std::vector<std::unique_ptr<StringMappingListPolicyHandler::MappingEntry>>*
@@ -804,6 +826,8 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
prefs::kEnableDeprecatedWebPlatformFeatures,
base::Bind(GetDeprecatedFeaturesMap)));
+ handlers->AddHandler(base::MakeUnique<BrowsingHistoryPolicyHandler>());
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
handlers->AddHandler(base::MakeUnique<extensions::ExtensionListPolicyHandler>(
key::kExtensionInstallWhitelist,
« no previous file with comments | « no previous file | chrome/browser/resources/options/clear_browser_data_overlay.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698