OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "chrome/browser/extensions/extension_uninstall_ui.h" |
10 #include "base/compiler_specific.h" | |
11 #include "chrome/browser/extensions/image_loading_tracker.h" | |
12 #include "third_party/skia/include/core/SkBitmap.h" | |
13 | 10 |
14 class MessageLoop; | 11 class Extension; |
15 class Profile; | 12 class Profile; |
| 13 class SkBitmap; |
16 | 14 |
17 class ExtensionUninstallDialog : public ImageLoadingTracker::Observer { | 15 // The common base class for connecting the ExtensionUninstallUI to |
| 16 // platform-specific UI. |
| 17 class ExtensionUninstallDialog { |
18 public: | 18 public: |
19 class Delegate { | 19 ExtensionUninstallDialog(Profile* profile, |
20 public: | 20 ExtensionUninstallUI::Delegate* delegate, |
21 // We call this method to signal that the uninstallation should continue. | 21 const Extension* extension, |
22 virtual void ExtensionDialogAccepted() = 0; | 22 SkBitmap* icon); |
23 | |
24 // We call this method to signal that the uninstallation should stop. | |
25 virtual void ExtensionDialogCanceled() = 0; | |
26 | |
27 protected: | |
28 virtual ~Delegate() {} | |
29 }; | |
30 | |
31 explicit ExtensionUninstallDialog(Profile* profile); | |
32 virtual ~ExtensionUninstallDialog(); | 23 virtual ~ExtensionUninstallDialog(); |
33 | 24 |
34 // This is called by the extensions management page to verify whether the | 25 protected: |
35 // uninstallation should proceed. | |
36 // Starts the process of showing a confirmation UI, which is split into two. | |
37 // 1) Set off a 'load icon' task. | |
38 // 2) Handle the load icon response and show the UI (OnImageLoaded). | |
39 void ConfirmUninstall(Delegate* delegate, const Extension* extension); | |
40 | |
41 private: | |
42 // Creates an appropriate ExtensionUninstallDialog for the platform. | |
43 static void Show(Profile* profile, | |
44 Delegate* delegate, | |
45 const Extension* extension, | |
46 SkBitmap* icon); | |
47 | |
48 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains | |
49 // an empty bitmap, then a default icon will be used instead. | |
50 void SetIcon(SkBitmap* icon); | |
51 | |
52 // ImageLoadingTracker::Observer: | |
53 virtual void OnImageLoaded(SkBitmap* image, | |
54 const ExtensionResource& resource, | |
55 int index) OVERRIDE; | |
56 | |
57 Profile* profile_; | 26 Profile* profile_; |
58 MessageLoop* ui_loop_; | 27 ExtensionUninstallUI::Delegate* delegate_; |
59 | |
60 // The delegate we will call Accepted/Canceled on after confirmation UI. | |
61 Delegate* delegate_; | |
62 | |
63 // The extension we are showing the UI for. | |
64 const Extension* extension_; | 28 const Extension* extension_; |
65 | 29 SkBitmap* icon_; |
66 // Keeps track of extension images being loaded on the File thread for the | |
67 // purpose of showing the install UI. | |
68 ImageLoadingTracker tracker_; | |
69 | |
70 // The extensions icon. | |
71 SkBitmap icon_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog); | |
74 }; | 30 }; |
75 | 31 |
76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ | 32 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ |
OLD | NEW |