Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [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 | |||||
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
6 | #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | ||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 7 | |
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 10 | #include "base/auto_reset.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 11 | #include "base/memory/raw_ptr.h" |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 12 | #include "base/memory/scoped_refptr.h" |
pkotwicz | a57a1f32 | 2014-10-21 00:24:30 | [diff] [blame] | 13 | |
14 | namespace content { | ||||
15 | class BrowserContext; | ||||
16 | } | ||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 17 | |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 18 | namespace extensions { |
19 | class CrxInstallError; | ||||
20 | class Extension; | ||||
21 | } // namespace extensions | ||||
22 | |||||
[email protected] | 32fc4ff7 | 2012-06-15 21:50:01 | [diff] [blame] | 23 | class Profile; |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 24 | class SkBitmap; |
[email protected] | 591a59f | 2012-10-11 01:16:23 | [diff] [blame] | 25 | |
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 26 | // Manages the extension install UI bubble. |
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 27 | class ExtensionInstallUI { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 28 | public: |
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 29 | // Creates an ExtensionInstallUI subclass for the current OS platform. |
30 | static std::unique_ptr<ExtensionInstallUI> Create( | ||||
31 | content::BrowserContext* context); | ||||
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame] | 32 | |
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 33 | ExtensionInstallUI(const ExtensionInstallUI&) = delete; |
34 | ExtensionInstallUI& operator=(const ExtensionInstallUI&) = delete; | ||||
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame] | 35 | |
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 36 | virtual ~ExtensionInstallUI(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 37 | |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 38 | // Called when an extension was installed. |
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 39 | virtual void OnInstallSuccess( |
40 | scoped_refptr<const extensions::Extension> extension, | ||||
41 | const SkBitmap* icon) = 0; | ||||
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 42 | |
43 | // Called when an extension failed to install. | ||||
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 44 | virtual void OnInstallFailure(const extensions::CrxInstallError& error) = 0; |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 45 | |
46 | // TODO(asargent) Normally we navigate to the new tab page when an app is | ||||
47 | // installed, but we're experimenting with instead showing a bubble when | ||||
48 | // an app is installed which points to the new tab button. This may become | ||||
49 | // the default behavior in the future. | ||||
50 | void SetUseAppInstalledBubble(bool use_bubble); | ||||
51 | |||||
52 | // Sets whether to show the default UI after completing the installation. | ||||
53 | void SetSkipPostInstallUI(bool skip_ui); | ||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 54 | |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 55 | // For testing: |
56 | static base::AutoReset<bool> disable_ui_for_tests(bool disable); | ||||
57 | |||||
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 58 | protected: |
59 | explicit ExtensionInstallUI(content::BrowserContext* context); | ||||
60 | |||||
61 | Profile* profile() { return profile_; } | ||||
62 | bool skip_post_install_ui() const { return skip_post_install_ui_; } | ||||
63 | bool use_app_installed_bubble() const { return use_app_installed_bubble_; } | ||||
64 | |||||
65 | // Whether the UI is disabled for testing. The method cannot have ForTest() in | ||||
66 | // the name, otherwise the presubmits get confused when it is called from | ||||
67 | // production code. | ||||
68 | static bool IsUiDisabled(); | ||||
69 | |||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 70 | private: |
Arthur Sonzogni | e98d214 | 2023-06-01 15:02:25 | [diff] [blame] | 71 | raw_ptr<Profile, DanglingUntriaged> profile_; |
pkotwicz | a57a1f32 | 2014-10-21 00:24:30 | [diff] [blame] | 72 | |
73 | // Whether or not to show the default UI after completing the installation. | ||||
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 74 | bool skip_post_install_ui_ = false; |
pkotwicz | a57a1f32 | 2014-10-21 00:24:30 | [diff] [blame] | 75 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 76 | // Whether to show an installed bubble on app install, or use the default |
77 | // action of opening a new tab page. | ||||
James Cook | 4068358bd | 2025-02-20 20:43:25 | [diff] [blame] | 78 | bool use_app_installed_bubble_ = false; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 79 | }; |
80 | |||||
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 81 | #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |