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
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_MAGIC_BOOST_MAGIC_BOOST_CONTROLLER_ASH_H_
#define CHROME_BROWSER_ASH_MAGIC_BOOST_MAGIC_BOOST_CONTROLLER_ASH_H_
#include "base/memory/weak_ptr.h"
#include "chromeos/crosapi/mojom/magic_boost.mojom.h"
#include "ui/views/widget/unique_widget_ptr.h"
namespace ash {
using OptInFeatures = crosapi::mojom::MagicBoostController::OptInFeatures;
// `MagicBoostControllerAsh` is the central point to deal with the ChromeOS -
// Chrome browser communication. it is responsible for showing the disclaimer UI
// and connect with Orca services in ash.
class MagicBoostControllerAsh : public crosapi::mojom::MagicBoostController {
public:
static MagicBoostControllerAsh* Get();
MagicBoostControllerAsh();
MagicBoostControllerAsh(const MagicBoostControllerAsh&) = delete;
MagicBoostControllerAsh& operator=(const MagicBoostControllerAsh&) = delete;
~MagicBoostControllerAsh() override;
// crosapi::mojom::MagicBoostController:
void ShowDisclaimerUi(
int64_t display_id,
crosapi::mojom::MagicBoostController::TransitionAction action,
OptInFeatures opt_in_features) override;
void CloseDisclaimerUi() override;
views::Widget* disclaimer_widget_for_test() {
return disclaimer_widget_.get();
}
private:
friend class MagicBoostControllerAshTest;
// Called when the disclaimer view's accept button is clicked. `display_id`
// indicates the display where the disclaimer view shows. `action` specifies
// the action to take after the opt-in flow.
void OnDisclaimerAcceptButtonPressed(
int64_t display_id,
crosapi::mojom::MagicBoostController::TransitionAction action);
// Called when the diclaimer view's declination button is clicked.
void OnDisclaimerDeclineButtonPressed();
void OnLinkPressed(const std::string& url);
views::UniqueWidgetPtr disclaimer_widget_;
OptInFeatures opt_in_features_;
base::WeakPtrFactory<MagicBoostControllerAsh> weak_ptr_factory_{this};
};
} // namespace ash
#endif // CHROME_BROWSER_ASH_MAGIC_BOOST_MAGIC_BOOST_CONTROLLER_ASH_H_
|