1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90

ash / webui / help_app_ui / help_app_page_handler.cc [blame]

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

#include "ash/webui/help_app_ui/help_app_page_handler.h"

#include <utility>

#include "ash/constants/ash_features.h"
#include "ash/webui/help_app_ui/help_app_prefs.h"
#include "ash/webui/help_app_ui/help_app_ui.h"
#include "ash/webui/help_app_ui/help_app_ui_delegate.h"
#include "base/feature_list.h"
#include "components/prefs/pref_service.h"
#include "url/gurl.h"

namespace ash {

HelpAppPageHandler::HelpAppPageHandler(
    HelpAppUI* help_app_ui,
    mojo::PendingReceiver<help_app::mojom::PageHandler> receiver,
    base::raw_ref<PrefService> pref_service)
    : receiver_(this, std::move(receiver)),
      help_app_ui_(help_app_ui),
      is_launcher_search_enabled_(
          base::FeatureList::IsEnabled(features::kHelpAppLauncherSearch)),
      pref_service_(pref_service) {}

HelpAppPageHandler::~HelpAppPageHandler() = default;

void HelpAppPageHandler::OpenFeedbackDialog(
    OpenFeedbackDialogCallback callback) {
  auto error_message = help_app_ui_->delegate()->OpenFeedbackDialog();
  std::move(callback).Run(std::move(error_message));
}

void HelpAppPageHandler::ShowOnDeviceAppControls() {
  help_app_ui_->delegate()->ShowOnDeviceAppControls();
}

void HelpAppPageHandler::ShowParentalControls() {
  help_app_ui_->delegate()->ShowParentalControls();
}

void HelpAppPageHandler::TriggerWelcomeTipCallToAction(
    help_app::mojom::ActionTypeId action_type_id) {
  help_app_ui_->delegate()->TriggerWelcomeTipCallToAction(action_type_id);
}

void HelpAppPageHandler::IsLauncherSearchEnabled(
    IsLauncherSearchEnabledCallback callback) {
  std::move(callback).Run(is_launcher_search_enabled_);
}

void HelpAppPageHandler::LaunchMicrosoft365Setup() {
  help_app_ui_->delegate()->LaunchMicrosoft365Setup();
}

void HelpAppPageHandler::MaybeShowReleaseNotesNotification() {
  help_app_ui_->delegate()->MaybeShowReleaseNotesNotification();
}

void HelpAppPageHandler::GetDeviceInfo(GetDeviceInfoCallback callback) {
  help_app_ui_->delegate()->GetDeviceInfo(std::move(callback));
}

void HelpAppPageHandler::OpenUrlInBrowserAndTriggerInstallDialog(
    const GURL& url) {
  auto error_message =
      help_app_ui_->delegate()->OpenUrlInBrowserAndTriggerInstallDialog(url);
  if (error_message.has_value()) {
    receiver_.ReportBadMessage(error_message.value());
  }
}

void HelpAppPageHandler::OpenSettings(
    help_app::mojom::SettingsComponent component) {
  help_app_ui_->delegate()->OpenSettings(component);
}

void HelpAppPageHandler::SetHasCompletedNewDeviceChecklist() {
  pref_service_->SetBoolean(
      help_app::prefs::kHelpAppHasCompletedNewDeviceChecklist, true);
}

void HelpAppPageHandler::SetHasVisitedHowToPage() {
  pref_service_->SetBoolean(help_app::prefs::kHelpAppHasVisitedHowToPage, true);
}

}  // namespace ash