1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "ui/gfx/image/image_skia.h"
23 namespace extensions
{
31 class ExtensionUninstallDialog
32 : public content::NotificationObserver
,
33 public base::SupportsWeakPtr
<ExtensionUninstallDialog
> {
37 // We call this method to signal that the uninstallation should continue.
38 virtual void ExtensionUninstallAccepted() = 0;
40 // We call this method to signal that the uninstallation should stop.
41 virtual void ExtensionUninstallCanceled() = 0;
44 virtual ~Delegate() {}
47 // Creates a platform specific implementation of ExtensionUninstallDialog.
48 // |profile| and |delegate| can never be NULL.
49 // |browser| can be NULL only for Ash when this is used with the applist
51 static ExtensionUninstallDialog
* Create(Profile
* profile
,
55 virtual ~ExtensionUninstallDialog();
57 // This is called to verify whether the uninstallation should proceed.
58 // Starts the process of showing a confirmation UI, which is split into two.
59 // 1) Set off a 'load icon' task.
60 // 2) Handle the load icon response and show the UI (OnImageLoaded).
61 void ConfirmUninstall(const extensions::Extension
* extension
);
64 // Constructor used by the derived classes.
65 ExtensionUninstallDialog(Profile
* profile
,
69 Profile
* const profile_
;
73 // The delegate we will call Accepted/Canceled on after confirmation dialog.
76 // The extension we are showing the dialog for.
77 const extensions::Extension
* extension_
;
79 // The extensions icon.
83 // Sets the icon that will be used in the dialog. If |icon| contains an empty
84 // image, then we use a default icon instead.
85 void SetIcon(const gfx::Image
& image
);
87 void OnImageLoaded(const gfx::Image
& image
);
89 // content::NotificationObserver implementation.
90 virtual void Observe(int type
,
91 const content::NotificationSource
& source
,
92 const content::NotificationDetails
& details
) OVERRIDE
;
94 // Displays the prompt. This should only be called after loading the icon.
95 // The implementations of this method are platform-specific.
96 virtual void Show() = 0;
98 // Keeps track of whether we're still waiting for an image to load before
99 // we show the dialog.
101 kImageIsLoading
, // Image is loading asynchronously.
102 kDialogIsShowing
, // Dialog is shown after image is loaded.
103 kBrowserIsClosing
// Browser is closed while image is still loading.
107 base::MessageLoop
* ui_loop_
;
109 content::NotificationRegistrar registrar_
;
111 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog
);
114 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_