Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8440)

Unified Diff: chrome/browser/ui/webui/app_launcher_handler.cc

Issue 6721013: extensions: Refactor ExtensionInstallUI class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: indentation Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/app_launcher_handler.cc
diff --git a/chrome/browser/ui/webui/app_launcher_handler.cc b/chrome/browser/ui/webui/app_launcher_handler.cc
index c9631594a42b2b71f206f7b3d06c9521fda5daa2..5ed5a307f212821f10ad7419c9b612566ba7ba12 100644
--- a/chrome/browser/ui/webui/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/app_launcher_handler.cc
@@ -63,7 +63,6 @@ extension_misc::AppLaunchBucket ParseLaunchSource(std::string launch_source) {
AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service)
: extensions_service_(extension_service),
- extension_prompt_type_(ExtensionInstallUI::UNSET_PROMPT_TYPE),
promo_active_(false),
ignore_changes_(false) {
}
@@ -406,8 +405,7 @@ void AppLauncherHandler::HandleUninstallApp(const ListValue* args) {
return; // Only one prompt at a time.
extension_id_prompting_ = extension_id;
- extension_prompt_type_ = ExtensionInstallUI::UNINSTALL_PROMPT;
- GetExtensionInstallUI()->ConfirmUninstall(this, extension);
+ GetExtensionUninstallDialog()->ConfirmUninstall(this, extension);
}
void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
@@ -538,11 +536,32 @@ void AppLauncherHandler::PromptToEnableApp(std::string extension_id) {
return; // Only one prompt at a time.
extension_id_prompting_ = extension_id;
- extension_prompt_type_ = ExtensionInstallUI::RE_ENABLE_PROMPT;
GetExtensionInstallUI()->ConfirmReEnable(this, extension);
}
+void AppLauncherHandler::ExtensionDialogAccepted() {
+ // Do the uninstall work here.
+ DCHECK(!extension_id_prompting_.empty());
+
+ // The extension can be uninstalled in another window while the UI was
+ // showing. Do nothing in that case.
+ const Extension* extension =
+ extensions_service_->GetExtensionById(extension_id_prompting_, true);
+ if (!extension)
+ return;
+
+ extensions_service_->UninstallExtension(extension_id_prompting_,
+ false /* external_uninstall */);
+
+ extension_id_prompting_ = "";
+}
+
+void AppLauncherHandler::ExtensionDialogCanceled() {
+ extension_id_prompting_ = "";
+}
+
void AppLauncherHandler::InstallUIProceed() {
+ // Do the re-enable work here.
DCHECK(!extension_id_prompting_.empty());
// The extension can be uninstalled in another window while the UI was
@@ -552,38 +571,36 @@ void AppLauncherHandler::InstallUIProceed() {
if (!extension)
return;
- switch (extension_prompt_type_) {
- case ExtensionInstallUI::UNINSTALL_PROMPT:
- extensions_service_->UninstallExtension(extension_id_prompting_,
- false /* external_uninstall */);
- break;
- case ExtensionInstallUI::RE_ENABLE_PROMPT: {
- extensions_service_->GrantPermissionsAndEnableExtension(extension);
-
- // We bounce this off the NTP so the browser can update the apps icon.
- // If we don't launch the app asynchronously, then the app's disabled
- // icon disappears but isn't replaced by the enabled icon, making a poor
- // visual experience.
- StringValue* app_id = Value::CreateStringValue(extension->id());
- web_ui_->CallJavascriptFunction("launchAppAfterEnable", *app_id);
- break;
- }
- default:
- NOTREACHED();
- break;
- }
+ extensions_service_->GrantPermissionsAndEnableExtension(extension);
+
+ // We bounce this off the NTP so the browser can update the apps icon.
+ // If we don't launch the app asynchronously, then the app's disabled
+ // icon disappears but isn't replaced by the enabled icon, making a poor
+ // visual experience.
+ StringValue* app_id = Value::CreateStringValue(extension->id());
+ web_ui_->CallJavascriptFunction("launchAppAfterEnable", *app_id);
extension_id_prompting_ = "";
}
void AppLauncherHandler::InstallUIAbort() {
- extension_id_prompting_ = "";
+ ExtensionDialogCanceled();
+}
+
+ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() {
+ if (!extension_uninstall_dialog_.get()) {
+ extension_uninstall_dialog_.reset(
+ new ExtensionUninstallDialog(web_ui_->GetProfile()));
+ }
+ return extension_uninstall_dialog_.get();
}
ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() {
- if (!install_ui_.get())
- install_ui_.reset(new ExtensionInstallUI(web_ui_->GetProfile()));
- return install_ui_.get();
+ if (!extension_install_ui_.get()) {
+ extension_install_ui_.reset(
+ new ExtensionInstallUI(web_ui_->GetProfile()));
+ }
+ return extension_install_ui_.get();
}
void AppLauncherHandler::UninstallDefaultApps() {
« no previous file with comments | « chrome/browser/ui/webui/app_launcher_handler.h ('k') | chrome/browser/ui/webui/options/extension_settings_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698