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

Unified Diff: chrome/browser/browser_init.cc

Issue 27313: Merge r9344.... (Closed) Base URL: svn://chrome-svn/chrome/branches/release_154.next/src/
Patch Set: '' Created 11 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_init.cc
===================================================================
--- chrome/browser/browser_init.cc (revision 10439)
+++ chrome/browser/browser_init.cc (working copy)
@@ -13,6 +13,7 @@
#include "base/histogram.h"
#include "base/path_service.h"
#include "base/string_util.h"
+#include "base/sys_info.h"
#include "base/win_util.h"
#include "chrome/app/locales/locale_settings.h"
#include "chrome/app/result_codes.h"
@@ -76,6 +77,55 @@
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 GetLaunchShortcutKind() {
+ 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 GetLaunchShortcutKind() {
+ 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) ? GetLaunchShortcutKind() : mode;
+ UMA_HISTOGRAM_COUNTS_100(L"Launch.Modes", bucket);
+}
+
} // namespace
// MessageWindow --------------------------------------------------------------
@@ -429,6 +479,8 @@
}
#ifndef NDEBUG
+ // Because this is debug-only in 154, we cannot record histograms for
+ // LM_AS_WEBAPP.
cpu_(ooo_6.6-7.5) 2009/03/01 02:17:03 !Gasp!
if (parsed_command_line.HasSwitch(switches::kApp)) {
NOTREACHED();
}
@@ -436,6 +488,8 @@
std::vector<GURL> urls_to_open = GetURLsFromCommandLine(parsed_command_line,
profile_);
+ RecordLaunchModeHistogram(urls_to_open.empty()?
+ LM_TO_BE_DECIDED : LM_WITH_URLS);
Browser* browser = NULL;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698