Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 2 | // 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 | |
xiaolingbao | c2a67e96 | 2015-02-10 01:53:21 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 10 | #include "base/memory/raw_ptr.h" |
David Bertoni | 6a0abc3 | 2023-12-05 19:06:17 | [diff] [blame] | 11 | #include "base/memory/weak_ptr.h" |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 12 | #include "chrome/browser/ui/global_error/global_error.h" |
| 13 | #include "components/keyed_service/core/keyed_service.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 14 | #include "components/prefs/pref_change_registrar.h" |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 15 | |
| 16 | class Profile; |
| 17 | |
| 18 | // Shows elevation needed for recovery component install on the wrench menu |
| 19 | // using a bubble view and a menu item. |
David Bertoni | 6a0abc3 | 2023-12-05 19:06:17 | [diff] [blame] | 20 | class RecoveryInstallGlobalError final : public GlobalErrorWithStandardBubble, |
| 21 | public KeyedService { |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 22 | public: |
| 23 | explicit RecoveryInstallGlobalError(Profile* profile); |
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame] | 24 | |
| 25 | RecoveryInstallGlobalError(const RecoveryInstallGlobalError&) = delete; |
| 26 | RecoveryInstallGlobalError& operator=(const RecoveryInstallGlobalError&) = |
| 27 | delete; |
| 28 | |
dcheng | 3538e8b | 2015-01-09 02:56:17 | [diff] [blame] | 29 | ~RecoveryInstallGlobalError() override; |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 30 | |
| 31 | private: |
| 32 | // KeyedService: |
dcheng | 3538e8b | 2015-01-09 02:56:17 | [diff] [blame] | 33 | void Shutdown() override; |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 34 | |
| 35 | // GlobalErrorWithStandardBubble: |
dcheng | 3538e8b | 2015-01-09 02:56:17 | [diff] [blame] | 36 | Severity GetSeverity() override; |
| 37 | bool HasMenuItem() override; |
| 38 | int MenuItemCommandID() override; |
Jan Wilken Dörrie | dec9912 | 2021-03-11 18:02:30 | [diff] [blame] | 39 | std::u16string MenuItemLabel() override; |
Allen Bauer | b25251f1 | 2020-04-09 17:01:44 | [diff] [blame] | 40 | ui::ImageModel MenuItemIcon() override; |
dcheng | 3538e8b | 2015-01-09 02:56:17 | [diff] [blame] | 41 | void ExecuteMenuItem(Browser* browser) override; |
| 42 | bool HasBubbleView() override; |
| 43 | bool HasShownBubbleView() override; |
| 44 | void ShowBubbleView(Browser* browser) override; |
xiaolingbao | c2a67e96 | 2015-02-10 01:53:21 | [diff] [blame] | 45 | bool ShouldCloseOnDeactivate() const override; |
Jan Wilken Dörrie | dec9912 | 2021-03-11 18:02:30 | [diff] [blame] | 46 | std::u16string GetBubbleViewTitle() override; |
| 47 | std::vector<std::u16string> GetBubbleViewMessages() override; |
| 48 | std::u16string GetBubbleViewAcceptButtonLabel() override; |
xiaolingbao | c2a67e96 | 2015-02-10 01:53:21 | [diff] [blame] | 49 | bool ShouldShowCloseButton() const override; |
dcheng | 3538e8b | 2015-01-09 02:56:17 | [diff] [blame] | 50 | bool ShouldAddElevationIconToAcceptButton() override; |
Jan Wilken Dörrie | dec9912 | 2021-03-11 18:02:30 | [diff] [blame] | 51 | std::u16string GetBubbleViewCancelButtonLabel() override; |
dcheng | 3538e8b | 2015-01-09 02:56:17 | [diff] [blame] | 52 | void OnBubbleViewDidClose(Browser* browser) override; |
| 53 | void BubbleViewAcceptButtonPressed(Browser* browser) override; |
| 54 | void BubbleViewCancelButtonPressed(Browser* browser) override; |
David Bertoni | 6a0abc3 | 2023-12-05 19:06:17 | [diff] [blame] | 55 | base::WeakPtr<GlobalErrorWithStandardBubble> AsWeakPtr() override; |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 56 | |
| 57 | bool HasElevationNotification() const; |
| 58 | void OnElevationRequirementChanged(); |
| 59 | |
| 60 | bool elevation_needed_; |
| 61 | |
| 62 | // The Profile this service belongs to. |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 63 | raw_ptr<Profile> profile_; |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 64 | |
| 65 | // Monitors registry change for recovery component install. |
| 66 | PrefChangeRegistrar pref_registrar_; |
| 67 | |
| 68 | bool has_shown_bubble_view_; |
David Bertoni | 6a0abc3 | 2023-12-05 19:06:17 | [diff] [blame] | 69 | |
| 70 | base::WeakPtrFactory<RecoveryInstallGlobalError> weak_ptr_factory_{this}; |
xiaolingbao | 4366f65e | 2014-12-02 02:25:21 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | #endif // CHROME_BROWSER_RECOVERY_RECOVERY_INSTALL_GLOBAL_ERROR_H_ |