OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 // The type of action the dialog took at close. | 28 // The type of action the dialog took at close. |
29 // Do not reorder this enum, as it is used in UMA histograms. | 29 // Do not reorder this enum, as it is used in UMA histograms. |
30 enum CloseAction { | 30 enum CloseAction { |
31 CLOSE_ACTION_UNINSTALL = 0, | 31 CLOSE_ACTION_UNINSTALL = 0, |
32 CLOSE_ACTION_UNINSTALL_AND_REPORT_ABUSE = 1, | 32 CLOSE_ACTION_UNINSTALL_AND_REPORT_ABUSE = 1, |
33 CLOSE_ACTION_CANCELED = 2, | 33 CLOSE_ACTION_CANCELED = 2, |
34 CLOSE_ACTION_LAST = 3, | 34 CLOSE_ACTION_LAST = 3, |
35 }; | 35 }; |
36 | 36 |
37 // A setting to cause extension/app installs from the webstore skip the normal | |
38 // confirmation dialog. This should only be used in tests. | |
39 enum AutoConfirmForTests { | |
40 NONE, // The prompt will show normally. | |
41 ACCEPT, // The prompt will always accept. | |
42 CANCEL, // The prompt will always cancel. | |
43 }; | |
44 class ScopedAutoConfirm { | |
45 public: | |
46 explicit ScopedAutoConfirm(AutoConfirmForTests new_value); | |
47 ~ScopedAutoConfirm(); | |
48 | |
49 private: | |
50 AutoConfirmForTests original_value_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(ScopedAutoConfirm); | |
53 }; | |
54 | |
55 // TODO(devlin): For a single method like this, a callback is probably more | 37 // TODO(devlin): For a single method like this, a callback is probably more |
56 // appropriate than a delegate. | 38 // appropriate than a delegate. |
57 class Delegate { | 39 class Delegate { |
58 public: | 40 public: |
59 // Called when the dialog closes. | 41 // Called when the dialog closes. |
60 // |did_start_uninstall| indicates whether the uninstall process for the | 42 // |did_start_uninstall| indicates whether the uninstall process for the |
61 // extension started. If this is false, |error| will contain the reason. | 43 // extension started. If this is false, |error| will contain the reason. |
62 virtual void OnExtensionUninstallDialogClosed( | 44 virtual void OnExtensionUninstallDialogClosed( |
63 bool did_start_uninstall, | 45 bool did_start_uninstall, |
64 const base::string16& error) = 0; | 46 const base::string16& error) = 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 86 |
105 // Accessors for members. | 87 // Accessors for members. |
106 const Profile* profile() const { return profile_; } | 88 const Profile* profile() const { return profile_; } |
107 Delegate* delegate() const { return delegate_; } | 89 Delegate* delegate() const { return delegate_; } |
108 const Extension* extension() const { return extension_.get(); } | 90 const Extension* extension() const { return extension_.get(); } |
109 const Extension* triggering_extension() const { | 91 const Extension* triggering_extension() const { |
110 return triggering_extension_.get(); } | 92 return triggering_extension_.get(); } |
111 const gfx::ImageSkia& icon() const { return icon_; } | 93 const gfx::ImageSkia& icon() const { return icon_; } |
112 | 94 |
113 private: | 95 private: |
114 static AutoConfirmForTests g_auto_confirm_for_testing; | |
115 | |
116 // Handles the "report abuse" checkbox being checked at the close of the | 96 // Handles the "report abuse" checkbox being checked at the close of the |
117 // dialog. | 97 // dialog. |
118 void HandleReportAbuse(); | 98 void HandleReportAbuse(); |
119 | 99 |
120 // Sets the icon that will be used in the dialog. If |icon| contains an empty | 100 // Sets the icon that will be used in the dialog. If |icon| contains an empty |
121 // image, then we use a default icon instead. | 101 // image, then we use a default icon instead. |
122 void SetIcon(const gfx::Image& image); | 102 void SetIcon(const gfx::Image& image); |
123 | 103 |
124 void OnImageLoaded(const std::string& extension_id, const gfx::Image& image); | 104 void OnImageLoaded(const std::string& extension_id, const gfx::Image& image); |
125 | 105 |
(...skipping 19 matching lines...) Expand all Loading... |
145 UninstallReason uninstall_reason_; | 125 UninstallReason uninstall_reason_; |
146 | 126 |
147 base::ThreadChecker thread_checker_; | 127 base::ThreadChecker thread_checker_; |
148 | 128 |
149 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog); | 129 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog); |
150 }; | 130 }; |
151 | 131 |
152 } // namespace extensions | 132 } // namespace extensions |
153 | 133 |
154 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ | 134 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ |
OLD | NEW |