Chromium Code Reviews| Index: chrome/browser/dom_ui/new_tab_ui.cc |
| diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc |
| index a6621026a946daaeab375912be7b9a32f3450b7f..14b84e3e90e2a2d2f28246c9e93db2613fd43d52 100644 |
| --- a/chrome/browser/dom_ui/new_tab_ui.cc |
| +++ b/chrome/browser/dom_ui/new_tab_ui.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/singleton.h" |
| #include "base/string_number_conversions.h" |
| +#include "base/string_split.h" |
| #include "base/thread.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/browser.h" |
| @@ -40,6 +41,7 @@ |
| #include "chrome/browser/tab_contents/tab_contents.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/extensions/extension.h" |
| +#include "chrome/common/extensions/extension_constants.h" |
| #include "chrome/common/notification_service.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| @@ -620,7 +622,16 @@ void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path, |
| int request_id) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - if (!path.empty() && path[0] != '#') { |
| + if (path.find(extension_misc::kLaunchWebStorePingURL) != std::string::npos) { |
|
Aaron Boodman
2010/11/12 00:29:20
Can you isolate all of this in AppLauncherHandler
|
| + RecordWebStoreLaunch(IsPromoActive(path)); |
| + return; |
| + |
| + } else if (path.find(extension_misc::kLaunchAppPingURL) != |
| + std::string::npos) { |
| + RecordAppLaunch(IsPromoActive(path)); |
| + return; |
| + |
| + } else if (!path.empty() && path[0] != '#') { |
| // A path under new-tab was requested; it's likely a bad relative |
| // URL from the new tab page, but in any case it's an error. |
| NOTREACHED(); |
| @@ -636,3 +647,31 @@ void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path, |
| std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { |
| return "text/html"; |
| } |
| + |
| +void NewTabUI::NewTabHTMLSource::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); |
| +} |
| + |
| +void NewTabUI::NewTabHTMLSource::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); |
| +} |
| + |
| +bool NewTabUI::NewTabHTMLSource::IsPromoActive(const std::string& path) { |
| + std::vector<std::string> params; |
| + base::SplitString(path, '+', ¶ms); |
| + |
| + DCHECK(params.size() == 2); |
|
Aaron Boodman
2010/11/12 00:29:20
You are going to crash below if size < 2, so might
|
| + |
| + return params.at(1) == "true"; |
| +} |