blob: 4b5213faa4e2786ff15381ae4c5251809b04c23c [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2014 The Chromium Authors
xiaolingbao4366f65e2014-12-02 02:25:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_RECOVERY_RECOVERY_INSTALL_GLOBAL_ERROR_H_
6#define CHROME_BROWSER_RECOVERY_RECOVERY_INSTALL_GLOBAL_ERROR_H_
7
xiaolingbaoc2a67e962015-02-10 01:53:218#include <vector>
9
Keishi Hattori0e45c022021-11-27 09:25:5210#include "base/memory/raw_ptr.h"
David Bertoni6a0abc32023-12-05 19:06:1711#include "base/memory/weak_ptr.h"
xiaolingbao4366f65e2014-12-02 02:25:2112#include "chrome/browser/ui/global_error/global_error.h"
13#include "components/keyed_service/core/keyed_service.h"
brettwb1fc1b82016-02-02 00:19:0814#include "components/prefs/pref_change_registrar.h"
xiaolingbao4366f65e2014-12-02 02:25:2115
16class Profile;
17
18// Shows elevation needed for recovery component install on the wrench menu
19// using a bubble view and a menu item.
David Bertoni6a0abc32023-12-05 19:06:1720class RecoveryInstallGlobalError final : public GlobalErrorWithStandardBubble,
21 public KeyedService {
xiaolingbao4366f65e2014-12-02 02:25:2122 public:
23 explicit RecoveryInstallGlobalError(Profile* profile);
Peter Boström53c6c5952021-09-17 09:41:2624
25 RecoveryInstallGlobalError(const RecoveryInstallGlobalError&) = delete;
26 RecoveryInstallGlobalError& operator=(const RecoveryInstallGlobalError&) =
27 delete;
28
dcheng3538e8b2015-01-09 02:56:1729 ~RecoveryInstallGlobalError() override;
xiaolingbao4366f65e2014-12-02 02:25:2130
31 private:
32 // KeyedService:
dcheng3538e8b2015-01-09 02:56:1733 void Shutdown() override;
xiaolingbao4366f65e2014-12-02 02:25:2134
35 // GlobalErrorWithStandardBubble:
dcheng3538e8b2015-01-09 02:56:1736 Severity GetSeverity() override;
37 bool HasMenuItem() override;
38 int MenuItemCommandID() override;
Jan Wilken Dörriedec99122021-03-11 18:02:3039 std::u16string MenuItemLabel() override;
Allen Bauerb25251f12020-04-09 17:01:4440 ui::ImageModel MenuItemIcon() override;
dcheng3538e8b2015-01-09 02:56:1741 void ExecuteMenuItem(Browser* browser) override;
42 bool HasBubbleView() override;
43 bool HasShownBubbleView() override;
44 void ShowBubbleView(Browser* browser) override;
xiaolingbaoc2a67e962015-02-10 01:53:2145 bool ShouldCloseOnDeactivate() const override;
Jan Wilken Dörriedec99122021-03-11 18:02:3046 std::u16string GetBubbleViewTitle() override;
47 std::vector<std::u16string> GetBubbleViewMessages() override;
48 std::u16string GetBubbleViewAcceptButtonLabel() override;
xiaolingbaoc2a67e962015-02-10 01:53:2149 bool ShouldShowCloseButton() const override;
dcheng3538e8b2015-01-09 02:56:1750 bool ShouldAddElevationIconToAcceptButton() override;
Jan Wilken Dörriedec99122021-03-11 18:02:3051 std::u16string GetBubbleViewCancelButtonLabel() override;
dcheng3538e8b2015-01-09 02:56:1752 void OnBubbleViewDidClose(Browser* browser) override;
53 void BubbleViewAcceptButtonPressed(Browser* browser) override;
54 void BubbleViewCancelButtonPressed(Browser* browser) override;
David Bertoni6a0abc32023-12-05 19:06:1755 base::WeakPtr<GlobalErrorWithStandardBubble> AsWeakPtr() override;
xiaolingbao4366f65e2014-12-02 02:25:2156
57 bool HasElevationNotification() const;
58 void OnElevationRequirementChanged();
59
60 bool elevation_needed_;
61
62 // The Profile this service belongs to.
Keishi Hattori0e45c022021-11-27 09:25:5263 raw_ptr<Profile> profile_;
xiaolingbao4366f65e2014-12-02 02:25:2164
65 // Monitors registry change for recovery component install.
66 PrefChangeRegistrar pref_registrar_;
67
68 bool has_shown_bubble_view_;
David Bertoni6a0abc32023-12-05 19:06:1769
70 base::WeakPtrFactory<RecoveryInstallGlobalError> weak_ptr_factory_{this};
xiaolingbao4366f65e2014-12-02 02:25:2171};
72
73#endif // CHROME_BROWSER_RECOVERY_RECOVERY_INSTALL_GLOBAL_ERROR_H_