| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/app_launcher_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 if (!is_web_store_ping && !is_app_launch_ping) | 126 if (!is_web_store_ping && !is_app_launch_ping) |
| 127 return false; | 127 return false; |
| 128 | 128 |
| 129 CHECK(params.size() >= 2); | 129 CHECK(params.size() >= 2); |
| 130 | 130 |
| 131 bool is_promo_active = params.at(1) == "true"; | 131 bool is_promo_active = params.at(1) == "true"; |
| 132 | 132 |
| 133 // At this point, the user must have used the app launcher, so we hide the | 133 // At this point, the user must have used the app launcher, so we hide the |
| 134 // promo if its still displayed. | 134 // promo if its still displayed. |
| 135 if (is_promo_active) | 135 if (is_promo_active) { |
| 136 DCHECK(profile->GetExtensionService()); |
| 136 profile->GetExtensionService()->default_apps()->SetPromoHidden(); | 137 profile->GetExtensionService()->default_apps()->SetPromoHidden(); |
| 138 } |
| 137 | 139 |
| 138 if (is_web_store_ping) { | 140 if (is_web_store_ping) { |
| 139 RecordWebStoreLaunch(is_promo_active); | 141 RecordWebStoreLaunch(is_promo_active); |
| 140 } else { | 142 } else { |
| 141 CHECK(params.size() == 3); | 143 CHECK(params.size() == 3); |
| 142 RecordAppLaunchByID(is_promo_active, ParseLaunchSource(params.at(2))); | 144 RecordAppLaunchByID(is_promo_active, ParseLaunchSource(params.at(2))); |
| 143 } | 145 } |
| 144 | 146 |
| 145 return true; | 147 return true; |
| 146 } | 148 } |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 } | 472 } |
| 471 | 473 |
| 472 // static | 474 // static |
| 473 void AppLauncherHandler::RecordAppLaunchByURL( | 475 void AppLauncherHandler::RecordAppLaunchByURL( |
| 474 Profile* profile, | 476 Profile* profile, |
| 475 std::string escaped_url, | 477 std::string escaped_url, |
| 476 extension_misc::AppLaunchBucket bucket) { | 478 extension_misc::AppLaunchBucket bucket) { |
| 477 CHECK(bucket != extension_misc::APP_LAUNCH_BUCKET_INVALID); | 479 CHECK(bucket != extension_misc::APP_LAUNCH_BUCKET_INVALID); |
| 478 | 480 |
| 479 GURL url(UnescapeURLComponent(escaped_url, kUnescapeRules)); | 481 GURL url(UnescapeURLComponent(escaped_url, kUnescapeRules)); |
| 480 // TODO: the ExtensionService should never be NULL, but in some cases it is, | 482 DCHECK(profile->GetExtensionService()); |
| 481 // see bug 73768. After it is resolved, the explicit test can go away. | 483 if (!profile->GetExtensionService()->IsInstalledApp(url)) |
| 482 ExtensionService* service = profile->GetExtensionService(); | |
| 483 if (!service || !service->IsInstalledApp(url)) | |
| 484 return; | 484 return; |
| 485 | 485 |
| 486 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, bucket, | 486 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, bucket, |
| 487 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | 487 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); |
| 488 } | 488 } |
| 489 | 489 |
| 490 void AppLauncherHandler::InstallUIProceed() { | 490 void AppLauncherHandler::InstallUIProceed() { |
| 491 DCHECK(!extension_id_prompting_.empty()); | 491 DCHECK(!extension_id_prompting_.empty()); |
| 492 | 492 |
| 493 // The extension can be uninstalled in another window while the UI was | 493 // The extension can be uninstalled in another window while the UI was |
| (...skipping 20 matching lines...) Expand all Loading... |
| 514 | 514 |
| 515 void AppLauncherHandler::UninstallDefaultApps() { | 515 void AppLauncherHandler::UninstallDefaultApps() { |
| 516 DefaultApps* default_apps = extensions_service_->default_apps(); | 516 DefaultApps* default_apps = extensions_service_->default_apps(); |
| 517 const ExtensionIdSet& app_ids = default_apps->default_apps(); | 517 const ExtensionIdSet& app_ids = default_apps->default_apps(); |
| 518 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 518 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
| 519 iter != app_ids.end(); ++iter) { | 519 iter != app_ids.end(); ++iter) { |
| 520 if (extensions_service_->GetExtensionById(*iter, true)) | 520 if (extensions_service_->GetExtensionById(*iter, true)) |
| 521 extensions_service_->UninstallExtension(*iter, false); | 521 extensions_service_->UninstallExtension(*iter, false); |
| 522 } | 522 } |
| 523 } | 523 } |
| OLD | NEW |