#include "chrome/browser/ui/webui/components/components_handler.h"
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/grit/generated_resources.h"
#include "components/update_client/crx_update_item.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/common/webui_url_constants.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/crosapi/browser_manager.h"
#include "chrome/browser/ash/crosapi/browser_util.h"
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/lacros_url_handling.h"
#endif
#endif
ComponentsHandler::ComponentsHandler(
component_updater::ComponentUpdateService* component_updater)
: … { … }
ComponentsHandler::~ComponentsHandler() = default;
void ComponentsHandler::RegisterMessages() { … }
void ComponentsHandler::OnJavascriptAllowed() { … }
void ComponentsHandler::OnJavascriptDisallowed() { … }
void ComponentsHandler::HandleRequestComponentsData(
const base::Value::List& args) { … }
void ComponentsHandler::HandleCheckUpdate(const base::Value::List& args) { … }
void ComponentsHandler::OnEvent(Events event, const std::string& id) { … }
std::u16string ComponentsHandler::ComponentEventToString(Events event) { … }
std::u16string ComponentsHandler::ServiceStatusToString(
update_client::ComponentState state) { … }
#if BUILDFLAG(IS_CHROMEOS)
void ComponentsHandler::HandleCrosUrlComponentsRedirect(
const base::Value::List& args) {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
lacros_url_handling::NavigateInAsh(GURL(chrome::kChromeUIComponentsUrl));
#else
DCHECK(crosapi::BrowserManager::Get());
crosapi::BrowserManager::Get()->SwitchToTab(
GURL(chrome::kChromeUIComponentsUrl),
NavigateParams::RESPECT);
#endif
}
#endif
void ComponentsHandler::OnDemandUpdate(const std::string& component_id) { … }
base::Value::List ComponentsHandler::LoadComponents() { … }