NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / extensions / extension_uninstall_dialog.h
blob9f7c8dcdec0aa4b5f65c03d0cd62cdbc9f73eeea
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"
16 class Browser;
17 class Profile;
19 namespace base {
20 class MessageLoop;
23 namespace extensions {
24 class Extension;
27 namespace gfx {
28 class Image;
31 class ExtensionUninstallDialog
32 : public content::NotificationObserver,
33 public base::SupportsWeakPtr<ExtensionUninstallDialog> {
34 public:
35 class Delegate {
36 public:
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;
43 protected:
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
50 // window.
51 static ExtensionUninstallDialog* Create(Profile* profile,
52 Browser* browser,
53 Delegate* delegate);
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);
63 protected:
64 // Constructor used by the derived classes.
65 ExtensionUninstallDialog(Profile* profile,
66 Browser* browser,
67 Delegate* delegate);
69 Profile* const profile_;
71 Browser* browser_;
73 // The delegate we will call Accepted/Canceled on after confirmation dialog.
74 Delegate* delegate_;
76 // The extension we are showing the dialog for.
77 const extensions::Extension* extension_;
79 // The extensions icon.
80 gfx::ImageSkia icon_;
82 private:
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.
100 enum State {
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.
105 State state_;
107 base::MessageLoop* ui_loop_;
109 content::NotificationRegistrar registrar_;
111 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog);
114 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_