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/weak_ptr.h"
11 #include "ui/gfx/image/image_skia.h"
12 #include "ui/gfx/native_widget_types.h"
24 namespace extensions
{
27 class ExtensionUninstallDialog
28 : public base::SupportsWeakPtr
<ExtensionUninstallDialog
> {
32 // We call this method to signal that the uninstallation should continue.
33 virtual void ExtensionUninstallAccepted() = 0;
35 // We call this method to signal that the uninstallation should stop.
36 virtual void ExtensionUninstallCanceled() = 0;
39 virtual ~Delegate() {}
42 // Creates a platform specific implementation of ExtensionUninstallDialog. The
43 // dialog will be modal to |parent|, or a non-modal dialog if |parent| is
45 static ExtensionUninstallDialog
* Create(Profile
* profile
,
46 gfx::NativeWindow parent
,
49 virtual ~ExtensionUninstallDialog();
51 // This is called to verify whether the uninstallation should proceed.
52 // Starts the process of showing a confirmation UI, which is split into two.
53 // 1) Set off a 'load icon' task.
54 // 2) Handle the load icon response and show the UI (OnImageLoaded).
55 void ConfirmUninstall(const Extension
* extension
);
57 // This shows the same dialog as above, except it also shows which extension
58 // triggered the dialog by calling chrome.management.uninstall API.
59 void ConfirmProgrammaticUninstall(const Extension
* extension
,
60 const Extension
* triggering_extension
);
62 std::string
GetHeadingText();
64 // Returns true if a checkbox for reporting abuse should be shown.
65 bool ShouldShowReportAbuseCheckbox() const;
68 // Constructor used by the derived classes.
69 ExtensionUninstallDialog(Profile
* profile
, Delegate
* delegate
);
71 // Handles the "report abuse" checkbox being checked at the close of the
73 void HandleReportAbuse();
75 // TODO(sashab): Remove protected members: crbug.com/397395
76 Profile
* const profile_
;
78 // The delegate we will call Accepted/Canceled on after confirmation dialog.
81 // The extension we are showing the dialog for.
82 const Extension
* extension_
;
84 // The extension triggering the dialog if the dialog was shown by
85 // chrome.management.uninstall.
86 const Extension
* triggering_extension_
;
88 // The extensions icon.
92 // Sets the icon that will be used in the dialog. If |icon| contains an empty
93 // image, then we use a default icon instead.
94 void SetIcon(const gfx::Image
& image
);
96 void OnImageLoaded(const std::string
& extension_id
, const gfx::Image
& image
);
98 // Displays the prompt. This should only be called after loading the icon.
99 // The implementations of this method are platform-specific.
100 virtual void Show() = 0;
102 base::MessageLoop
* ui_loop_
;
104 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog
);
107 } // namespace extensions
109 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_