blob: 0a3afca30d35b6159480791bb4a91b332f2b3deb [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
[email protected]c82da8c42012-06-08 19:49:112// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
EmiliaPazbee48672024-08-26 22:00:275#ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALL_UI_H_
6#define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALL_UI_H_
[email protected]c82da8c42012-06-08 19:49:117
James Cook4068358bd2025-02-20 20:43:258#include <memory>
9
EmiliaPaz723b8ad82024-08-26 19:08:5710#include "base/auto_reset.h"
Keishi Hattori0e45c022021-11-27 09:25:5211#include "base/memory/raw_ptr.h"
EmiliaPaz723b8ad82024-08-26 19:08:5712#include "base/memory/scoped_refptr.h"
pkotwicza57a1f322014-10-21 00:24:3013
14namespace content {
15class BrowserContext;
16}
[email protected]c82da8c42012-06-08 19:49:1117
EmiliaPaz723b8ad82024-08-26 19:08:5718namespace extensions {
19class CrxInstallError;
20class Extension;
21} // namespace extensions
22
[email protected]32fc4ff72012-06-15 21:50:0123class Profile;
EmiliaPaz723b8ad82024-08-26 19:08:5724class SkBitmap;
[email protected]591a59f2012-10-11 01:16:2325
James Cook4068358bd2025-02-20 20:43:2526// Manages the extension install UI bubble.
EmiliaPazbee48672024-08-26 22:00:2727class ExtensionInstallUI {
[email protected]c82da8c42012-06-08 19:49:1128 public:
James Cook4068358bd2025-02-20 20:43:2529 // Creates an ExtensionInstallUI subclass for the current OS platform.
30 static std::unique_ptr<ExtensionInstallUI> Create(
31 content::BrowserContext* context);
Peter Boström53c6c5952021-09-17 09:41:2632
EmiliaPazbee48672024-08-26 22:00:2733 ExtensionInstallUI(const ExtensionInstallUI&) = delete;
34 ExtensionInstallUI& operator=(const ExtensionInstallUI&) = delete;
Peter Boström53c6c5952021-09-17 09:41:2635
James Cook4068358bd2025-02-20 20:43:2536 virtual ~ExtensionInstallUI();
[email protected]c82da8c42012-06-08 19:49:1137
EmiliaPaz723b8ad82024-08-26 19:08:5738 // Called when an extension was installed.
James Cook4068358bd2025-02-20 20:43:2539 virtual void OnInstallSuccess(
40 scoped_refptr<const extensions::Extension> extension,
41 const SkBitmap* icon) = 0;
EmiliaPaz723b8ad82024-08-26 19:08:5742
43 // Called when an extension failed to install.
James Cook4068358bd2025-02-20 20:43:2544 virtual void OnInstallFailure(const extensions::CrxInstallError& error) = 0;
EmiliaPaz723b8ad82024-08-26 19:08:5745
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]c82da8c42012-06-08 19:49:1154
EmiliaPaz723b8ad82024-08-26 19:08:5755 // For testing:
56 static base::AutoReset<bool> disable_ui_for_tests(bool disable);
57
James Cook4068358bd2025-02-20 20:43:2558 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]c82da8c42012-06-08 19:49:1170 private:
Arthur Sonzognie98d2142023-06-01 15:02:2571 raw_ptr<Profile, DanglingUntriaged> profile_;
pkotwicza57a1f322014-10-21 00:24:3072
73 // Whether or not to show the default UI after completing the installation.
James Cook4068358bd2025-02-20 20:43:2574 bool skip_post_install_ui_ = false;
pkotwicza57a1f322014-10-21 00:24:3075
[email protected]c82da8c42012-06-08 19:49:1176 // Whether to show an installed bubble on app install, or use the default
77 // action of opening a new tab page.
James Cook4068358bd2025-02-20 20:43:2578 bool use_app_installed_bubble_ = false;
[email protected]c82da8c42012-06-08 19:49:1179};
80
EmiliaPazbee48672024-08-26 22:00:2781#endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALL_UI_H_