chromium/chrome/browser/ui/webui/components/components_handler.cc

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

#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  // BUILDFLAG(IS_CHROMEOS)

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) {}

// This function is called when user presses button from html UI.
// TODO(shrikant): We need to make this button available based on current
// state e.g. If component state is currently updating then we need to disable
// button. (https://code.google.com/p/chromium/issues/detail?id=272540)
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
  // Note: This will only be called by the UI when Lacros is available.
  DCHECK(crosapi::BrowserManager::Get());
  crosapi::BrowserManager::Get()->SwitchToTab(
      GURL(chrome::kChromeUIComponentsUrl),
      /*path_behavior=*/NavigateParams::RESPECT);
#endif
}
#endif  // BUILDFLAG(IS_CHROMEOS)

void ComponentsHandler::OnDemandUpdate(const std::string& component_id) {}

base::Value::List ComponentsHandler::LoadComponents() {}