Reland "Reland "[PolicyLogs] Adding chrome://policy/logs on Desktop""
The issue that caused the revert in crrev.com/c/4616067 has been
fixed by crrev.com/c/4626859. The policy logger no longer posts
tasks to a sequence. The lines changed in the files of this CL are
the same as the original reland.
chrome://policy/logs is already available on Android and enabled by
default. This CL brings chrome://policy/logs to desktop behind a
feature flag that is enabled by default.
Bug: b/282733597
Change-Id: I3eaadf0a07a009ed1d2e423dd7024eb89a939155
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4654277
Reviewed-by: Demetrios Papadopoulos <[email protected]>
Commit-Queue: Salma Elmahallawy <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1164140}
diff --git a/chrome/browser/ui/webui/policy/policy_ui.cc b/chrome/browser/ui/webui/policy/policy_ui.cc
index 5547f40..d96bf35 100644
--- a/chrome/browser/ui/webui/policy/policy_ui.cc
+++ b/chrome/browser/ui/webui/policy/policy_ui.cc
@@ -1,3 +1,4 @@
+
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,6 +7,9 @@
#include <memory>
+#include "base/json/json_writer.h"
+#include "base/strings/stringprintf.h"
+#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/policy/value_provider/chrome_policies_value_provider.h"
@@ -17,33 +21,27 @@
#include "components/grit/policy_resources.h"
#include "components/grit/policy_resources_map.h"
#include "components/policy/core/common/features.h"
+#include "components/policy/core/common/policy_logger.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/policy/core/common/policy_utils.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/strings/grit/components_strings.h"
+#include "components/version_info/version_info.h"
+#include "components/version_ui/version_handler_helper.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "content/public/common/user_agent.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/webui/web_ui_util.h"
-#if BUILDFLAG(IS_ANDROID)
-#include "base/json/json_writer.h"
-#include "base/strings/stringprintf.h"
-#include "base/system/sys_info.h"
-#include "components/policy/core/common/policy_logger.h"
-#include "components/version_info/version_info.h"
-#include "components/version_ui/version_handler_helper.h"
-#include "content/public/common/user_agent.h"
-#endif // BUILDFLAG(IS_ANDROID)
-
namespace {
-#if BUILDFLAG(IS_ANDROID)
// Returns the operating system information to be displayed on
// chrome://policy/logs page.
std::string GetOsInfo() {
- // The base format for the OS version and build
+#if BUILDFLAG(IS_ANDROID)
+ // The base format for the OS version and build.
constexpr char kOSVersionAndBuildFormat[] = "Android %s %s";
return base::StringPrintf(
kOSVersionAndBuildFormat,
@@ -51,6 +49,11 @@
(content::GetAndroidOSInfo(content::IncludeAndroidBuildNumber::Include,
content::IncludeAndroidModel::Include))
.c_str());
+#else
+ return base::StringPrintf("%s %s",
+ base::SysInfo::OperatingSystemName().c_str(),
+ base::SysInfo::OperatingSystemVersion().c_str());
+#endif // BUILDFLAG (IS_ANDROID)
}
// Returns the version information to be displayed on the chrome://policy/logs
@@ -65,7 +68,6 @@
return version_info;
}
-#endif
void CreateAndAddPolicyUIHtmlSource(Profile* profile) {
content::WebUIDataSource* source = content::WebUIDataSource::CreateAndAdd(
@@ -150,7 +152,6 @@
};
source->AddLocalizedStrings(kPolicyLogsStrings);
-#if BUILDFLAG(IS_ANDROID)
source->AddBoolean(
"loggingEnabled",
policy::PolicyLogger::GetInstance()->IsPolicyLoggingEnabled());
@@ -164,7 +165,6 @@
source->AddResourcePath("logs/", IDR_POLICY_LOGS_POLICY_LOGS_HTML);
source->AddResourcePath("logs", IDR_POLICY_LOGS_POLICY_LOGS_HTML);
-#endif // BUILDFLAG(IS_ANDROID)
if (policy::utils::IsPolicyTestingEnabled(profile->GetPrefs())) {
// Localized strings for chrome://policy/test.