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 #include "chrome/browser/extensions/extension_disabled_ui.h" | 5 #include "chrome/browser/extensions/extension_disabled_ui.h" |
6 | 6 |
7 #include <bitset> | 7 #include <bitset> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 "Extensions.Permissions_ReEnableAbort"; | 132 "Extensions.Permissions_ReEnableAbort"; |
133 ExtensionService::RecordPermissionMessagesHistogram( | 133 ExtensionService::RecordPermissionMessagesHistogram( |
134 extension_, histogram_name.c_str()); | 134 extension_, histogram_name.c_str()); |
135 | 135 |
136 // Do nothing. The extension will remain disabled. | 136 // Do nothing. The extension will remain disabled. |
137 Release(); | 137 Release(); |
138 } | 138 } |
139 | 139 |
140 // ExtensionDisabledGlobalError ----------------------------------------------- | 140 // ExtensionDisabledGlobalError ----------------------------------------------- |
141 | 141 |
142 class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble, | 142 class ExtensionDisabledGlobalError |
143 public content::NotificationObserver, | 143 : public GlobalErrorWithStandardBubble, |
144 public ExtensionUninstallDialog::Delegate { | 144 public content::NotificationObserver, |
| 145 public extensions::ExtensionUninstallDialog::Delegate { |
145 public: | 146 public: |
146 ExtensionDisabledGlobalError(ExtensionService* service, | 147 ExtensionDisabledGlobalError(ExtensionService* service, |
147 const Extension* extension, | 148 const Extension* extension, |
148 bool is_remote_install, | 149 bool is_remote_install, |
149 const gfx::Image& icon); | 150 const gfx::Image& icon); |
150 virtual ~ExtensionDisabledGlobalError(); | 151 virtual ~ExtensionDisabledGlobalError(); |
151 | 152 |
152 // GlobalError implementation. | 153 // GlobalError implementation. |
153 virtual Severity GetSeverity() OVERRIDE; | 154 virtual Severity GetSeverity() OVERRIDE; |
154 virtual bool HasMenuItem() OVERRIDE; | 155 virtual bool HasMenuItem() OVERRIDE; |
(...skipping 26 matching lines...) Expand all Loading... |
181 | 182 |
182 // How the user responded to the error; used for metrics. | 183 // How the user responded to the error; used for metrics. |
183 enum UserResponse { | 184 enum UserResponse { |
184 IGNORED, | 185 IGNORED, |
185 REENABLE, | 186 REENABLE, |
186 UNINSTALL, | 187 UNINSTALL, |
187 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY | 188 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY |
188 }; | 189 }; |
189 UserResponse user_response_; | 190 UserResponse user_response_; |
190 | 191 |
191 scoped_ptr<ExtensionUninstallDialog> uninstall_dialog_; | 192 scoped_ptr<extensions::ExtensionUninstallDialog> uninstall_dialog_; |
192 | 193 |
193 // Menu command ID assigned for this extension's error. | 194 // Menu command ID assigned for this extension's error. |
194 int menu_command_id_; | 195 int menu_command_id_; |
195 | 196 |
196 content::NotificationRegistrar registrar_; | 197 content::NotificationRegistrar registrar_; |
197 }; | 198 }; |
198 | 199 |
199 // TODO(yoz): create error at startup for disabled extensions. | 200 // TODO(yoz): create error at startup for disabled extensions. |
200 ExtensionDisabledGlobalError::ExtensionDisabledGlobalError( | 201 ExtensionDisabledGlobalError::ExtensionDisabledGlobalError( |
201 ExtensionService* service, | 202 ExtensionService* service, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 Browser* browser) { | 335 Browser* browser) { |
335 // Delay extension reenabling so this bubble closes properly. | 336 // Delay extension reenabling so this bubble closes properly. |
336 base::MessageLoop::current()->PostTask(FROM_HERE, | 337 base::MessageLoop::current()->PostTask(FROM_HERE, |
337 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, | 338 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, |
338 service_->AsWeakPtr(), extension_)); | 339 service_->AsWeakPtr(), extension_)); |
339 } | 340 } |
340 | 341 |
341 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( | 342 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( |
342 Browser* browser) { | 343 Browser* browser) { |
343 #if !defined(OS_ANDROID) | 344 #if !defined(OS_ANDROID) |
344 uninstall_dialog_.reset( | 345 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( |
345 ExtensionUninstallDialog::Create(service_->profile(), browser, this)); | 346 service_->profile(), browser, this)); |
346 // Delay showing the uninstall dialog, so that this function returns | 347 // Delay showing the uninstall dialog, so that this function returns |
347 // immediately, to close the bubble properly. See crbug.com/121544. | 348 // immediately, to close the bubble properly. See crbug.com/121544. |
348 base::MessageLoop::current()->PostTask(FROM_HERE, | 349 base::MessageLoop::current()->PostTask( |
349 base::Bind(&ExtensionUninstallDialog::ConfirmUninstall, | 350 FROM_HERE, |
350 uninstall_dialog_->AsWeakPtr(), extension_)); | 351 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, |
| 352 uninstall_dialog_->AsWeakPtr(), |
| 353 extension_)); |
351 #endif // !defined(OS_ANDROID) | 354 #endif // !defined(OS_ANDROID) |
352 } | 355 } |
353 | 356 |
354 void ExtensionDisabledGlobalError::ExtensionUninstallAccepted() { | 357 void ExtensionDisabledGlobalError::ExtensionUninstallAccepted() { |
355 service_->UninstallExtension(extension_->id(), false, NULL); | 358 service_->UninstallExtension(extension_->id(), false, NULL); |
356 } | 359 } |
357 | 360 |
358 void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() { | 361 void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() { |
359 // Nothing happens, and the error is still there. | 362 // Nothing happens, and the error is still there. |
360 } | 363 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 void ShowExtensionDisabledDialog(ExtensionService* service, | 424 void ShowExtensionDisabledDialog(ExtensionService* service, |
422 content::WebContents* web_contents, | 425 content::WebContents* web_contents, |
423 const Extension* extension) { | 426 const Extension* extension) { |
424 scoped_ptr<ExtensionInstallPrompt> install_ui( | 427 scoped_ptr<ExtensionInstallPrompt> install_ui( |
425 new ExtensionInstallPrompt(web_contents)); | 428 new ExtensionInstallPrompt(web_contents)); |
426 // This object manages its own lifetime. | 429 // This object manages its own lifetime. |
427 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); | 430 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); |
428 } | 431 } |
429 | 432 |
430 } // namespace extensions | 433 } // namespace extensions |
OLD | NEW |