#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/ui/webui/support_tool/support_tool_ui.h"
#include <optional>
#include <set>
#include <string>
#include <vector>
#include "base/check.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/support_tool/data_collection_module.pb.h"
#include "chrome/browser/support_tool/data_collector.h"
#include "chrome/browser/support_tool/screenshot_data_collector.h"
#include "chrome/browser/support_tool/support_tool_handler.h"
#include "chrome/browser/support_tool/support_tool_util.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/webui/support_tool/support_tool_ui_utils.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/support_tool_resources.h"
#include "chrome/grit/support_tool_resources_map.h"
#include "components/feedback/redaction_tool/pii_types.h"
#include "components/policy/core/common/management/management_service.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "net/base/url_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/selected_file_info.h"
#include "url/gurl.h"
namespace {
constexpr char kFilenamePrefix[] = …;
constexpr char kUrlGeneratorPath[] = …;
void RecordOpenPageMetric(const GURL& url) { … }
void CreateAndAddSupportToolHTMLSource(Profile* profile, const GURL& url) { … }
}
const char kSupportToolWebUIActionHistogram[] = …;
class SupportToolMessageHandler : public content::WebUIMessageHandler,
public ui::SelectFileDialog::Listener { … };
SupportToolMessageHandler::~SupportToolMessageHandler() { … }
void SupportToolMessageHandler::RegisterMessages() { … }
base::Value::List SupportToolMessageHandler::GetAccountsList() { … }
void SupportToolMessageHandler::HandleGetEmailAddresses(
const base::Value::List& args) { … }
void SupportToolMessageHandler::HandleGetDataCollectors(
const base::Value::List& args) { … }
void SupportToolMessageHandler::HandleGetAllDataCollectors(
const base::Value::List& args) { … }
void SupportToolMessageHandler::HandleTakeScreenshot(
const base::Value::List& args) { … }
void SupportToolMessageHandler::OnScreenshotTaken(
std::optional<SupportToolError> error) { … }
void SupportToolMessageHandler::HandleStartDataCollection(
const base::Value::List& args) { … }
void SupportToolMessageHandler::OnDataCollectionDone(
const PIIMap& detected_pii,
std::set<SupportToolError> errors) { … }
void SupportToolMessageHandler::HandleCancelDataCollection(
const base::Value::List& args) { … }
void SupportToolMessageHandler::HandleStartDataExport(
const base::Value::List& args) { … }
void SupportToolMessageHandler::FileSelected(const ui::SelectedFileInfo& file,
int index) { … }
void SupportToolMessageHandler::FileSelectionCanceled() { … }
void SupportToolMessageHandler::OnDataExportDone(
base::FilePath path,
std::set<SupportToolError> errors) { … }
void SupportToolMessageHandler::HandleShowExportedDataInFolder(
const base::Value::List& args) { … }
void SupportToolMessageHandler::HandleGenerateCustomizedURL(
const base::Value::List& args) { … }
void SupportToolMessageHandler::HandleGenerateSupportToken(
const base::Value::List& args) { … }
SupportToolUI::SupportToolUI(content::WebUI* web_ui) : … { … }
SupportToolUI::~SupportToolUI() = default;
base::Value::Dict SupportToolUI::GetLocalizedStrings() { … }
bool SupportToolUI::IsEnabled(Profile* profile) { … }