chromium/chrome/browser/ui/webui/support_tool/support_tool_ui.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#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 {

// The filename prefix for the file to export the generated file.
constexpr char kFilenamePrefix[] =;

// The path we use to show URL generator page
// chrome://support-tool/url-generator
constexpr char kUrlGeneratorPath[] =;

// Records the open page action to `kSupportToolWebUIActionHistogram`. There are
// two possible types of pages that a user can navigate into: main support tool
// page and URL generator page. We check which was was opened from `url`.
void RecordOpenPageMetric(const GURL& url) {}

void CreateAndAddSupportToolHTMLSource(Profile* profile, const GURL& url) {}

}  // namespace

const char kSupportToolWebUIActionHistogram[] =;

////////////////////////////////////////////////////////////////////////////////
//
// SupportToolMessageHandler
//
////////////////////////////////////////////////////////////////////////////////

// The handler for Javascript messages related to Support Tool.
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) {}

// Starts data collection with the issue details and selected set of data
// collectors that are sent from UI. Returns the result to UI in the format UI
// accepts.
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() {}

// Checks `errors` and fires WebUIListener with the error message or the
// exported path according to the returned errors.
// type DataExportResult = {
//  success: boolean,
//  path: string,
//  error: string,
// }
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::SupportToolUI(content::WebUI* web_ui) :{}

SupportToolUI::~SupportToolUI() = default;

// static
base::Value::Dict SupportToolUI::GetLocalizedStrings() {}

// static
bool SupportToolUI::IsEnabled(Profile* profile) {}