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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "apps/metrics_names.h" | 9 #include "apps/metrics_names.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "ui/base/webui/web_ui_util.h" | 62 #include "ui/base/webui/web_ui_util.h" |
63 #include "url/gurl.h" | 63 #include "url/gurl.h" |
64 | 64 |
65 using content::WebContents; | 65 using content::WebContents; |
66 using extensions::AppSorting; | 66 using extensions::AppSorting; |
67 using extensions::CrxInstaller; | 67 using extensions::CrxInstaller; |
68 using extensions::Extension; | 68 using extensions::Extension; |
69 using extensions::ExtensionPrefs; | 69 using extensions::ExtensionPrefs; |
70 using extensions::ExtensionRegistry; | 70 using extensions::ExtensionRegistry; |
71 using extensions::ExtensionSet; | 71 using extensions::ExtensionSet; |
| 72 using extensions::UninstalledExtensionInfo; |
72 using extensions::UnloadedExtensionInfo; | 73 using extensions::UnloadedExtensionInfo; |
73 | 74 |
74 namespace { | 75 namespace { |
75 | 76 |
76 void RecordAppLauncherPromoHistogram( | 77 void RecordAppLauncherPromoHistogram( |
77 apps::AppLauncherPromoHistogramValues value) { | 78 apps::AppLauncherPromoHistogramValues value) { |
78 DCHECK_LT(value, apps::APP_LAUNCHER_PROMO_MAX); | 79 DCHECK_LT(value, apps::APP_LAUNCHER_PROMO_MAX); |
79 UMA_HISTOGRAM_ENUMERATION( | 80 UMA_HISTOGRAM_ENUMERATION( |
80 "Apps.AppLauncherPromo", value, apps::APP_LAUNCHER_PROMO_MAX); | 81 "Apps.AppLauncherPromo", value, apps::APP_LAUNCHER_PROMO_MAX); |
81 } | 82 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 "ntp.appAdded", *app_info, *highlight); | 280 "ntp.appAdded", *app_info, *highlight); |
280 } | 281 } |
281 | 282 |
282 break; | 283 break; |
283 } | 284 } |
284 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: | 285 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: |
285 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: { | 286 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: { |
286 const Extension* extension = NULL; | 287 const Extension* extension = NULL; |
287 bool uninstalled = false; | 288 bool uninstalled = false; |
288 if (type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED) { | 289 if (type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED) { |
289 extension = content::Details<const Extension>(details).ptr(); | 290 extension = content::Details<extensions::UninstalledExtensionInfo>( |
| 291 details)->extension; |
290 uninstalled = true; | 292 uninstalled = true; |
291 } else { // NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED | 293 } else { // NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED |
292 if (content::Details<UnloadedExtensionInfo>(details)->reason == | 294 if (content::Details<UnloadedExtensionInfo>(details)->reason == |
293 UnloadedExtensionInfo::REASON_UNINSTALL) { | 295 UnloadedExtensionInfo::REASON_UNINSTALL) { |
294 // Uninstalls are tracked by | 296 // Uninstalls are tracked by |
295 // NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED. | 297 // NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED. |
296 return; | 298 return; |
297 } | 299 } |
298 extension = content::Details<extensions::UnloadedExtensionInfo>( | 300 extension = content::Details<extensions::UnloadedExtensionInfo>( |
299 details)->extension; | 301 details)->extension; |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 | 789 |
788 // The extension can be uninstalled in another window while the UI was | 790 // The extension can be uninstalled in another window while the UI was |
789 // showing. Do nothing in that case. | 791 // showing. Do nothing in that case. |
790 const Extension* extension = | 792 const Extension* extension = |
791 extension_service_->GetInstalledExtension(extension_id_prompting_); | 793 extension_service_->GetInstalledExtension(extension_id_prompting_); |
792 if (!extension) | 794 if (!extension) |
793 return; | 795 return; |
794 | 796 |
795 extension_service_->UninstallExtension( | 797 extension_service_->UninstallExtension( |
796 extension_id_prompting_, | 798 extension_id_prompting_, |
797 ExtensionService::UNINSTALL_REASON_USER_INITIATED, | 799 UninstalledExtensionInfo::REASON_USER_INITIATED, |
798 NULL); | 800 NULL); |
799 CleanupAfterUninstall(); | 801 CleanupAfterUninstall(); |
800 } | 802 } |
801 | 803 |
802 void AppLauncherHandler::ExtensionUninstallCanceled() { | 804 void AppLauncherHandler::ExtensionUninstallCanceled() { |
803 CleanupAfterUninstall(); | 805 CleanupAfterUninstall(); |
804 } | 806 } |
805 | 807 |
806 void AppLauncherHandler::ExtensionEnableFlowFinished() { | 808 void AppLauncherHandler::ExtensionEnableFlowFinished() { |
807 DCHECK_EQ(extension_id_prompting_, extension_enable_flow_->extension_id()); | 809 DCHECK_EQ(extension_id_prompting_, extension_enable_flow_->extension_id()); |
(...skipping 30 matching lines...) Expand all Loading... |
838 AppLauncherHandler::GetExtensionUninstallDialog() { | 840 AppLauncherHandler::GetExtensionUninstallDialog() { |
839 if (!extension_uninstall_dialog_.get()) { | 841 if (!extension_uninstall_dialog_.get()) { |
840 Browser* browser = chrome::FindBrowserWithWebContents( | 842 Browser* browser = chrome::FindBrowserWithWebContents( |
841 web_ui()->GetWebContents()); | 843 web_ui()->GetWebContents()); |
842 extension_uninstall_dialog_.reset( | 844 extension_uninstall_dialog_.reset( |
843 extensions::ExtensionUninstallDialog::Create( | 845 extensions::ExtensionUninstallDialog::Create( |
844 extension_service_->profile(), browser, this)); | 846 extension_service_->profile(), browser, this)); |
845 } | 847 } |
846 return extension_uninstall_dialog_.get(); | 848 return extension_uninstall_dialog_.get(); |
847 } | 849 } |
OLD | NEW |