diff options
author | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-06 22:23:55 +0000 |
---|---|---|
committer | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-06 22:23:55 +0000 |
commit | 6fbd6270986ff2025105154aed81b0c1a44e3260 (patch) | |
tree | e090441534aa8be398da67ef9ecdbd07f20709ea /chrome/browser/browser_init.cc | |
parent | 9850f6d793b20ea76dc33e48ec75eb9e8e4e6c88 (diff) | |
download | chromium_src-6fbd6270986ff2025105154aed81b0c1a44e3260.zip chromium_src-6fbd6270986ff2025105154aed81b0c1a44e3260.tar.gz chromium_src-6fbd6270986ff2025105154aed81b0c1a44e3260.tar.bz2 |
Add UMA counter to track how users launch Chrome
- Histogram is named Launch.Modes
- We have different buckets for : direct execution, webapp, shell, quicklaunch and desktop shortcuts
BUG=7216
Review URL: http://codereview.chromium.org/21109
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9344 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_init.cc')
-rw-r--r-- | chrome/browser/browser_init.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index 47032cf..721ebf2 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -7,8 +7,10 @@ #include "base/basictypes.h" #include "base/command_line.h" #include "base/event_recorder.h" +#include "base/histogram.h" #include "base/path_service.h" #include "base/string_util.h" +#include "base/sys_info.h" #include "chrome/app/result_codes.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" @@ -131,6 +133,55 @@ SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, return pref; } +enum LaunchMode { + LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. + LM_AS_WEBAPP, // Launched as a installed web application. + LM_WITH_URLS, // Launched with urls in the cmd line. + LM_SHORTCUT_NONE, // Not launched from a shortcut. + LM_SHORTCUT_NONAME, // Launched from shortcut but no name available. + LM_SHORTCUT_UNKNOWN, // Launched from user-defined shortcut. + LM_SHORTCUT_QUICKLAUNCH, // Launched from the quick launch bar. + LM_SHORTCUT_DESKTOP, // Launched from a desktop shortcut. + LM_SHORTCUT_STARTMENU, // Launched from start menu. + LM_LINUX_MAC_BEOS // Other OS buckets start here. +}; + +#if defined(OS_WIN) +// Undocumented flag in the startup info structure tells us what shortcut was +// used to launch the browser. See http://www.catch22.net/tuts/undoc01 for +// more information. Confirmed to work on XP, Vista and Win7. +LaunchMode GetLaunchSortcutKind() { + STARTUPINFOW si = { sizeof(si) }; + GetStartupInfoW(&si); + if (si.dwFlags & 0x800) { + if (!si.lpTitle) + return LM_SHORTCUT_NONAME; + std::wstring shortcut(si.lpTitle); + // The windows quick launch path is not localized. + if (shortcut.find(L"\\Quick Launch\\") != std::wstring::npos) + return LM_SHORTCUT_QUICKLAUNCH; + std::wstring appdata_path = base::SysInfo::GetEnvVar(L"USERPROFILE"); + if (!appdata_path.empty() && + shortcut.find(appdata_path) != std::wstring::npos) + return LM_SHORTCUT_DESKTOP; + return LM_SHORTCUT_UNKNOWN; + } + return LM_SHORTCUT_NONE; +} +#else +// TODO(cpu): Port to other platforms. +LaunchMode GetLaunchSortcutKind() { + return LM_LINUX_MAC_BEOS; +} +#endif + +// Log in a histogram the frequency of launching by the different methods. See +// LaunchMode enum for the actual values of the buckets. +void RecordLaunchModeHistogram(LaunchMode mode) { + int bucket = (mode == LM_TO_BE_DECIDED) ? GetLaunchSortcutKind() : mode; + UMA_HISTOGRAM_COUNTS_100(L"Launch.Modes", bucket); +} + } // namespace static bool in_startup = false; @@ -190,6 +241,8 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile, // First, see if we're being run as a web application (thin frame window). if (!OpenApplicationURL(profile)) { std::vector<GURL> urls_to_open = GetURLsFromCommandLine(profile_); + RecordLaunchModeHistogram(urls_to_open.empty()? + LM_TO_BE_DECIDED : LM_WITH_URLS); // Always attempt to restore the last session. OpenStartupURLs only opens // the home pages if no additional URLs were passed on the command line. if (!OpenStartupURLs(process_startup, urls_to_open)) { @@ -201,6 +254,8 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile, browser = BrowserList::GetLastActive(); OpenURLsInBrowser(browser, process_startup, urls_to_open); } + } else { + RecordLaunchModeHistogram(LM_AS_WEBAPP); } // If we're recording or playing back, startup the EventRecorder now |