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 "base/basictypes.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/extensions/image_loading_tracker.h" | 12 #include "chrome/browser/extensions/image_loading_tracker.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
14 | 14 |
15 class MessageLoop; | 15 class MessageLoop; |
16 class Profile; | 16 class Profile; |
17 | 17 |
| 18 namespace extensions { |
| 19 class Extension; |
| 20 } |
| 21 |
18 class ExtensionUninstallDialog | 22 class ExtensionUninstallDialog |
19 : public ImageLoadingTracker::Observer, | 23 : public ImageLoadingTracker::Observer, |
20 public base::SupportsWeakPtr<ExtensionUninstallDialog> { | 24 public base::SupportsWeakPtr<ExtensionUninstallDialog> { |
21 public: | 25 public: |
22 class Delegate { | 26 class Delegate { |
23 public: | 27 public: |
24 // We call this method to signal that the uninstallation should continue. | 28 // We call this method to signal that the uninstallation should continue. |
25 virtual void ExtensionUninstallAccepted() = 0; | 29 virtual void ExtensionUninstallAccepted() = 0; |
26 | 30 |
27 // We call this method to signal that the uninstallation should stop. | 31 // We call this method to signal that the uninstallation should stop. |
28 virtual void ExtensionUninstallCanceled() = 0; | 32 virtual void ExtensionUninstallCanceled() = 0; |
29 | 33 |
30 protected: | 34 protected: |
31 virtual ~Delegate() {} | 35 virtual ~Delegate() {} |
32 }; | 36 }; |
33 | 37 |
34 // Creates a platform specific implementation of ExtensionUninstallDialog. | 38 // Creates a platform specific implementation of ExtensionUninstallDialog. |
35 static ExtensionUninstallDialog* Create( | 39 static ExtensionUninstallDialog* Create( |
36 Profile* profile, Delegate* delegate); | 40 Profile* profile, Delegate* delegate); |
37 | 41 |
38 virtual ~ExtensionUninstallDialog(); | 42 virtual ~ExtensionUninstallDialog(); |
39 | 43 |
40 // This is called to verify whether the uninstallation should proceed. | 44 // This is called to verify whether the uninstallation should proceed. |
41 // Starts the process of showing a confirmation UI, which is split into two. | 45 // Starts the process of showing a confirmation UI, which is split into two. |
42 // 1) Set off a 'load icon' task. | 46 // 1) Set off a 'load icon' task. |
43 // 2) Handle the load icon response and show the UI (OnImageLoaded). | 47 // 2) Handle the load icon response and show the UI (OnImageLoaded). |
44 void ConfirmUninstall(const Extension* extension); | 48 void ConfirmUninstall(const extensions::Extension* extension); |
45 | 49 |
46 protected: | 50 protected: |
47 // Constructor used by the derived classes. | 51 // Constructor used by the derived classes. |
48 explicit ExtensionUninstallDialog(Profile* profile, Delegate* delegate); | 52 explicit ExtensionUninstallDialog(Profile* profile, Delegate* delegate); |
49 | 53 |
50 Profile* profile_; | 54 Profile* profile_; |
51 | 55 |
52 // The delegate we will call Accepted/Canceled on after confirmation dialog. | 56 // The delegate we will call Accepted/Canceled on after confirmation dialog. |
53 Delegate* delegate_; | 57 Delegate* delegate_; |
54 | 58 |
55 // The extension we are showing the dialog for. | 59 // The extension we are showing the dialog for. |
56 const Extension* extension_; | 60 const extensions::Extension* extension_; |
57 | 61 |
58 // The extensions icon. | 62 // The extensions icon. |
59 SkBitmap icon_; | 63 SkBitmap icon_; |
60 | 64 |
61 private: | 65 private: |
62 // Sets the icon that will be used in the dialog. If |icon| contains an empty | 66 // Sets the icon that will be used in the dialog. If |icon| contains an empty |
63 // bitmap, then we use a default icon instead. | 67 // bitmap, then we use a default icon instead. |
64 void SetIcon(const gfx::Image& image); | 68 void SetIcon(const gfx::Image& image); |
65 | 69 |
66 // ImageLoadingTracker::Observer: | 70 // ImageLoadingTracker::Observer: |
67 virtual void OnImageLoaded(const gfx::Image& image, | 71 virtual void OnImageLoaded(const gfx::Image& image, |
68 const std::string& extension_id, | 72 const std::string& extension_id, |
69 int index) OVERRIDE; | 73 int index) OVERRIDE; |
70 | 74 |
71 // Displays the prompt. This should only be called after loading the icon. | 75 // Displays the prompt. This should only be called after loading the icon. |
72 // The implementations of this method are platform-specific. | 76 // The implementations of this method are platform-specific. |
73 virtual void Show() = 0; | 77 virtual void Show() = 0; |
74 | 78 |
75 MessageLoop* ui_loop_; | 79 MessageLoop* ui_loop_; |
76 | 80 |
77 // Keeps track of extension images being loaded on the File thread for the | 81 // Keeps track of extension images being loaded on the File thread for the |
78 // purpose of showing the dialog. | 82 // purpose of showing the dialog. |
79 ImageLoadingTracker tracker_; | 83 ImageLoadingTracker tracker_; |
80 | 84 |
81 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog); | 85 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog); |
82 }; | 86 }; |
83 | 87 |
84 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ | 88 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ |
OLD | NEW |