Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1130)

Side by Side Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 4708002: Add a histogram for tracking web store promo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: incorporate feedback, use ping attribute Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/dom_ui/new_tab_ui.h" 7 #include "chrome/browser/dom_ui/new_tab_ui.h"
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/singleton.h" 16 #include "base/singleton.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/string_split.h"
18 #include "base/thread.h" 19 #include "base/thread.h"
19 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
20 #include "chrome/browser/browser.h" 21 #include "chrome/browser/browser.h"
21 #include "chrome/browser/browser_thread.h" 22 #include "chrome/browser/browser_thread.h"
22 #include "chrome/browser/dom_ui/app_launcher_handler.h" 23 #include "chrome/browser/dom_ui/app_launcher_handler.h"
23 #include "chrome/browser/dom_ui/dom_ui_theme_source.h" 24 #include "chrome/browser/dom_ui/dom_ui_theme_source.h"
24 #include "chrome/browser/dom_ui/foreign_session_handler.h" 25 #include "chrome/browser/dom_ui/foreign_session_handler.h"
25 #include "chrome/browser/dom_ui/most_visited_handler.h" 26 #include "chrome/browser/dom_ui/most_visited_handler.h"
26 #include "chrome/browser/dom_ui/new_tab_page_sync_handler.h" 27 #include "chrome/browser/dom_ui/new_tab_page_sync_handler.h"
27 #include "chrome/browser/dom_ui/ntp_login_handler.h" 28 #include "chrome/browser/dom_ui/ntp_login_handler.h"
28 #include "chrome/browser/dom_ui/ntp_resource_cache.h" 29 #include "chrome/browser/dom_ui/ntp_resource_cache.h"
29 #include "chrome/browser/dom_ui/shown_sections_handler.h" 30 #include "chrome/browser/dom_ui/shown_sections_handler.h"
30 #include "chrome/browser/dom_ui/tips_handler.h" 31 #include "chrome/browser/dom_ui/tips_handler.h"
31 #include "chrome/browser/metrics/user_metrics.h" 32 #include "chrome/browser/metrics/user_metrics.h"
32 #include "chrome/browser/themes/browser_theme_provider.h" 33 #include "chrome/browser/themes/browser_theme_provider.h"
33 #include "chrome/browser/prefs/pref_service.h" 34 #include "chrome/browser/prefs/pref_service.h"
34 #include "chrome/browser/profile.h" 35 #include "chrome/browser/profile.h"
35 #include "chrome/browser/renderer_host/render_view_host.h" 36 #include "chrome/browser/renderer_host/render_view_host.h"
36 #include "chrome/browser/sessions/session_types.h" 37 #include "chrome/browser/sessions/session_types.h"
37 #include "chrome/browser/sessions/tab_restore_service.h" 38 #include "chrome/browser/sessions/tab_restore_service.h"
38 #include "chrome/browser/sessions/tab_restore_service_observer.h" 39 #include "chrome/browser/sessions/tab_restore_service_observer.h"
39 #include "chrome/browser/sync/profile_sync_service.h" 40 #include "chrome/browser/sync/profile_sync_service.h"
40 #include "chrome/browser/tab_contents/tab_contents.h" 41 #include "chrome/browser/tab_contents/tab_contents.h"
41 #include "chrome/common/chrome_switches.h" 42 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/extensions/extension.h" 43 #include "chrome/common/extensions/extension.h"
44 #include "chrome/common/extensions/extension_constants.h"
43 #include "chrome/common/notification_service.h" 45 #include "chrome/common/notification_service.h"
44 #include "chrome/common/pref_names.h" 46 #include "chrome/common/pref_names.h"
45 #include "chrome/common/url_constants.h" 47 #include "chrome/common/url_constants.h"
46 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
47 #include "grit/theme_resources.h" 49 #include "grit/theme_resources.h"
48 50
49 namespace { 51 namespace {
50 52
51 // The number of recent bookmarks we show. 53 // The number of recent bookmarks we show.
52 const int kRecentBookmarks = 9; 54 const int kRecentBookmarks = 9;
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile) 615 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile)
614 : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()), 616 : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()),
615 profile_(profile) { 617 profile_(profile) {
616 } 618 }
617 619
618 void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path, 620 void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path,
619 bool is_off_the_record, 621 bool is_off_the_record,
620 int request_id) { 622 int request_id) {
621 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 623 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
622 624
623 if (!path.empty() && path[0] != '#') { 625 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
626 RecordWebStoreLaunch(IsPromoActive(path));
627 return;
628
629 } else if (path.find(extension_misc::kLaunchAppPingURL) !=
630 std::string::npos) {
631 RecordAppLaunch(IsPromoActive(path));
632 return;
633
634 } else if (!path.empty() && path[0] != '#') {
624 // A path under new-tab was requested; it's likely a bad relative 635 // A path under new-tab was requested; it's likely a bad relative
625 // URL from the new tab page, but in any case it's an error. 636 // URL from the new tab page, but in any case it's an error.
626 NOTREACHED(); 637 NOTREACHED();
627 return; 638 return;
628 } 639 }
629 640
630 scoped_refptr<RefCountedBytes> html_bytes( 641 scoped_refptr<RefCountedBytes> html_bytes(
631 profile_->GetNTPResourceCache()->GetNewTabHTML(is_off_the_record)); 642 profile_->GetNTPResourceCache()->GetNewTabHTML(is_off_the_record));
632 643
633 SendResponse(request_id, html_bytes); 644 SendResponse(request_id, html_bytes);
634 } 645 }
635 646
636 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { 647 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const {
637 return "text/html"; 648 return "text/html";
638 } 649 }
650
651 void NewTabUI::NewTabHTMLSource::RecordWebStoreLaunch(bool promo_active) {
652 if (!promo_active) return;
653
654 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
655 extension_misc::PROMO_LAUNCH_WEB_STORE,
656 extension_misc::PROMO_BUCKET_BOUNDARY);
657 }
658
659 void NewTabUI::NewTabHTMLSource::RecordAppLaunch(bool promo_active) {
660 // TODO(jstritar): record app launches that occur when the promo is not
661 // active using a different histogram.
662
663 if (!promo_active) return;
664
665 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
666 extension_misc::PROMO_LAUNCH_APP,
667 extension_misc::PROMO_BUCKET_BOUNDARY);
668 }
669
670 bool NewTabUI::NewTabHTMLSource::IsPromoActive(const std::string& path) {
671 std::vector<std::string> params;
672 base::SplitString(path, '+', &params);
673
674 DCHECK(params.size() == 2);
Aaron Boodman 2010/11/12 00:29:20 You are going to crash below if size < 2, so might
675
676 return params.at(1) == "true";
677 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698