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 | |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 8 | #include "base/auto_reset.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 9 | #include "base/memory/raw_ptr.h" |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 10 | #include "base/memory/scoped_refptr.h" |
pkotwicz | a57a1f32 | 2014-10-21 00:24:30 | [diff] [blame] | 11 | |
12 | namespace content { | ||||
13 | class BrowserContext; | ||||
14 | } | ||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 15 | |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 16 | namespace extensions { |
17 | class CrxInstallError; | ||||
18 | class Extension; | ||||
19 | } // namespace extensions | ||||
20 | |||||
Elly Fong-Jones | 7c3ab03 | 2020-03-12 23:02:19 | [diff] [blame] | 21 | class Browser; |
[email protected] | 32fc4ff7 | 2012-06-15 21:50:01 | [diff] [blame] | 22 | class Profile; |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 23 | class SkBitmap; |
[email protected] | 591a59f | 2012-10-11 01:16:23 | [diff] [blame] | 24 | |
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 25 | class ExtensionInstallUI { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 26 | public: |
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 27 | explicit ExtensionInstallUI(content::BrowserContext* context); |
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame] | 28 | |
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 29 | ExtensionInstallUI(const ExtensionInstallUI&) = delete; |
30 | ExtensionInstallUI& operator=(const ExtensionInstallUI&) = delete; | ||||
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame] | 31 | |
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 32 | ~ExtensionInstallUI(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 33 | |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 34 | // Called when an extension was installed. |
Dana Fried | c3c3022 | 2018-12-11 23:34:56 | [diff] [blame] | 35 | void OnInstallSuccess(scoped_refptr<const extensions::Extension> extension, |
EmiliaPaz | 723b8ad8 | 2024-08-26 19:08:57 | [diff] [blame] | 36 | const SkBitmap* icon); |
37 | |||||
38 | // Called when an extension failed to install. | ||||
39 | void OnInstallFailure(const extensions::CrxInstallError& error); | ||||
40 | |||||
41 | // TODO(asargent) Normally we navigate to the new tab page when an app is | ||||
42 | // installed, but we're experimenting with instead showing a bubble when | ||||
43 | // an app is installed which points to the new tab button. This may become | ||||
44 | // the default behavior in the future. | ||||
45 | void SetUseAppInstalledBubble(bool use_bubble); | ||||
46 | |||||
47 | // Sets whether to show the default UI after completing the installation. | ||||
48 | void SetSkipPostInstallUI(bool skip_ui); | ||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 49 | |
EmiliaPaz | d28b77cfd | 2024-08-26 23:26:44 | [diff] [blame] | 50 | // Show the install bubble UI. |
51 | static void ShowBubble(scoped_refptr<const extensions::Extension> extension, | ||||
52 | Browser* browser, | ||||
53 | const SkBitmap& icon); | ||||
Elly Fong-Jones | 7c3ab03 | 2020-03-12 23:02:19 | [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 | |||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 58 | private: |
Arthur Sonzogni | e98d214 | 2023-06-01 15:02:25 | [diff] [blame] | 59 | raw_ptr<Profile, DanglingUntriaged> profile_; |
pkotwicz | a57a1f32 | 2014-10-21 00:24:30 | [diff] [blame] | 60 | |
61 | // Whether or not to show the default UI after completing the installation. | ||||
62 | bool skip_post_install_ui_; | ||||
63 | |||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 64 | // Whether to show an installed bubble on app install, or use the default |
65 | // action of opening a new tab page. | ||||
66 | bool use_app_installed_bubble_; | ||||
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 67 | }; |
68 | |||||
EmiliaPaz | bee4867 | 2024-08-26 22:00:27 | [diff] [blame] | 69 | #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |