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/ui/webui/ntp/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 // Launch app asynchronously so the image will update. | 899 // Launch app asynchronously so the image will update. |
900 StringValue app_id(extension_id); | 900 StringValue app_id(extension_id); |
901 web_ui()->CallJavascriptFunction("ntp.launchAppAfterEnable", app_id); | 901 web_ui()->CallJavascriptFunction("ntp.launchAppAfterEnable", app_id); |
902 return; | 902 return; |
903 } | 903 } |
904 | 904 |
905 if (!extension_id_prompting_.empty()) | 905 if (!extension_id_prompting_.empty()) |
906 return; // Only one prompt at a time. | 906 return; // Only one prompt at a time. |
907 | 907 |
908 extension_id_prompting_ = extension_id; | 908 extension_id_prompting_ = extension_id; |
909 GetExtensionInstallUI()->ConfirmReEnable(this, extension); | 909 GetExtensionInstallPrompt()->ConfirmReEnable(this, extension); |
910 } | 910 } |
911 | 911 |
912 void AppLauncherHandler::ExtensionUninstallAccepted() { | 912 void AppLauncherHandler::ExtensionUninstallAccepted() { |
913 // Do the uninstall work here. | 913 // Do the uninstall work here. |
914 DCHECK(!extension_id_prompting_.empty()); | 914 DCHECK(!extension_id_prompting_.empty()); |
915 | 915 |
916 // The extension can be uninstalled in another window while the UI was | 916 // The extension can be uninstalled in another window while the UI was |
917 // showing. Do nothing in that case. | 917 // showing. Do nothing in that case. |
918 const Extension* extension = | 918 const Extension* extension = |
919 extension_service_->GetExtensionById(extension_id_prompting_, true); | 919 extension_service_->GetExtensionById(extension_id_prompting_, true); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 } | 967 } |
968 | 968 |
969 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { | 969 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { |
970 if (!extension_uninstall_dialog_.get()) { | 970 if (!extension_uninstall_dialog_.get()) { |
971 extension_uninstall_dialog_.reset( | 971 extension_uninstall_dialog_.reset( |
972 ExtensionUninstallDialog::Create(Profile::FromWebUI(web_ui()), this)); | 972 ExtensionUninstallDialog::Create(Profile::FromWebUI(web_ui()), this)); |
973 } | 973 } |
974 return extension_uninstall_dialog_.get(); | 974 return extension_uninstall_dialog_.get(); |
975 } | 975 } |
976 | 976 |
977 ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() { | 977 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { |
978 if (!extension_install_ui_.get()) { | 978 if (!extension_install_ui_.get()) { |
979 extension_install_ui_.reset( | 979 extension_install_ui_.reset( |
980 new ExtensionInstallUI(Profile::FromWebUI(web_ui()))); | 980 new ExtensionInstallPrompt(Profile::FromWebUI(web_ui()))); |
981 } | 981 } |
982 return extension_install_ui_.get(); | 982 return extension_install_ui_.get(); |
983 } | 983 } |
984 | 984 |
985 void AppLauncherHandler::UninstallDefaultApps() { | 985 void AppLauncherHandler::UninstallDefaultApps() { |
986 AppsPromo* apps_promo = extension_service_->apps_promo(); | 986 AppsPromo* apps_promo = extension_service_->apps_promo(); |
987 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 987 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
988 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin(); | 988 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin(); |
989 iter != app_ids.end(); ++iter) { | 989 iter != app_ids.end(); ++iter) { |
990 if (extension_service_->GetExtensionById(*iter, true)) | 990 if (extension_service_->GetExtensionById(*iter, true)) |
991 extension_service_->UninstallExtension(*iter, false, NULL); | 991 extension_service_->UninstallExtension(*iter, false, NULL); |
992 } | 992 } |
993 } | 993 } |
OLD | NEW |