| Index: chrome/browser/dom_ui/app_launcher_handler.cc
|
| diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
|
| index 9bc27d250843a7881f8d5f725dd1338701c4aa54..c32ebb3787948fa93c99953e75986cfc5ae119ea 100644
|
| --- a/chrome/browser/dom_ui/app_launcher_handler.cc
|
| +++ b/chrome/browser/dom_ui/app_launcher_handler.cc
|
| @@ -5,7 +5,9 @@
|
| #include "chrome/browser/dom_ui/app_launcher_handler.h"
|
|
|
| #include "app/animation.h"
|
| +#include "base/metrics/histogram.h"
|
| #include "base/string_number_conversions.h"
|
| +#include "base/string_split.h"
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "base/values.h"
|
| @@ -32,6 +34,11 @@
|
|
|
| namespace {
|
|
|
| +// The URL prefixes used by the NTP to signal when the web store or an app
|
| +// has launched. These are used for histogram purposes.
|
| +const char* kLaunchAppPingURL = "record-app-launch";
|
| +const char* kLaunchWebStorePingURL = "record-webstore-launch";
|
| +
|
| // This extracts an int from a ListValue at the given |index|.
|
| bool ExtractInt(const ListValue* list, size_t index, int* out_int) {
|
| std::string string_value;
|
| @@ -53,10 +60,21 @@ std::string GetIconURL(const Extension* extension, Extension::Icons icon,
|
| return default_val;
|
| }
|
|
|
| +// Extracts the promo parameter from the |path| generated by a ping on the NTP.
|
| +bool IsPromoActive(const std::string& path) {
|
| + std::vector<std::string> params;
|
| + base::SplitString(path, '+', ¶ms);
|
| +
|
| + CHECK(params.size() == 2);
|
| +
|
| + return params.at(1) == "true";
|
| +}
|
| +
|
| } // namespace
|
|
|
| AppLauncherHandler::AppLauncherHandler(ExtensionsService* extension_service)
|
| - : extensions_service_(extension_service) {
|
| + : extensions_service_(extension_service),
|
| + promo_active_(false) {
|
| }
|
|
|
| AppLauncherHandler::~AppLauncherHandler() {}
|
| @@ -150,8 +168,10 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
|
| if (default_apps->ShouldShowPromo(extensions_service_->GetAppIds())) {
|
| dictionary->SetBoolean("showPromo", true);
|
| default_apps->DidShowPromo();
|
| + promo_active_ = true;
|
| } else {
|
| dictionary->SetBoolean("showPromo", false);
|
| + promo_active_ = false;
|
| }
|
|
|
| bool showLauncher =
|
| @@ -220,6 +240,9 @@ void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
|
|
|
| if (new_contents != old_contents && browser->tab_count() > 1)
|
| browser->CloseTabContents(old_contents);
|
| +
|
| + if (extension_id != extension_misc::kWebStoreAppId)
|
| + RecordAppLaunch(promo_active_);
|
| }
|
|
|
| void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) {
|
| @@ -271,6 +294,9 @@ void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
|
| // If the user has intentionally hidden the promotion, we'll uninstall all the
|
| // default apps (we know the user hasn't installed any apps on their own at
|
| // this point, or the promotion wouldn't have been shown).
|
| + UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
|
| + extension_misc::PROMO_CLOSE,
|
| + extension_misc::PROMO_BUCKET_BOUNDARY);
|
| DefaultApps* default_apps = extensions_service_->default_apps();
|
| const ExtensionIdSet* app_ids = default_apps->GetDefaultApps();
|
| DCHECK(*app_ids == extensions_service_->GetAppIds());
|
| @@ -284,6 +310,19 @@ void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
|
| extensions_service_->default_apps()->SetPromoHidden();
|
| }
|
|
|
| +// static
|
| +bool AppLauncherHandler::HandlePing(const std::string& path) {
|
| + if (path.find(kLaunchWebStorePingURL) != std::string::npos) {
|
| + RecordWebStoreLaunch(IsPromoActive(path));
|
| + return true;
|
| + } else if (path.find(kLaunchAppPingURL) != std::string::npos) {
|
| + RecordAppLaunch(IsPromoActive(path));
|
| + return true;
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() {
|
| if (!install_ui_.get())
|
| install_ui_.reset(new ExtensionInstallUI(dom_ui_->GetProfile()));
|
| @@ -308,3 +347,24 @@ void AppLauncherHandler::InstallUIProceed() {
|
| void AppLauncherHandler::InstallUIAbort() {
|
| extension_id_prompting_ = "";
|
| }
|
| +
|
| +//static
|
| +void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) {
|
| + if (!promo_active) return;
|
| +
|
| + UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
|
| + extension_misc::PROMO_LAUNCH_WEB_STORE,
|
| + extension_misc::PROMO_BUCKET_BOUNDARY);
|
| +}
|
| +
|
| +//static
|
| +void AppLauncherHandler::RecordAppLaunch(bool promo_active) {
|
| + // TODO(jstritar): record app launches that occur when the promo is not
|
| + // active using a different histogram.
|
| +
|
| + if (!promo_active) return;
|
| +
|
| + UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
|
| + extension_misc::PROMO_LAUNCH_APP,
|
| + extension_misc::PROMO_BUCKET_BOUNDARY);
|
| +}
|
|
|