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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_impl.cc

Issue 2902963002: Add a new LaunchMode value for launches from a user experiment. (Closed)
Patch Set: LM_OTHER Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/startup/startup_browser_creator_impl.h" 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 using content::ChildProcessSecurityPolicy; 127 using content::ChildProcessSecurityPolicy;
128 using content::WebContents; 128 using content::WebContents;
129 using extensions::Extension; 129 using extensions::Extension;
130 130
131 namespace { 131 namespace {
132 132
133 // Utility functions ---------------------------------------------------------- 133 // Utility functions ----------------------------------------------------------
134 134
135 enum LaunchMode { 135 enum LaunchMode {
136 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. 136 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut.
137 LM_AS_WEBAPP, // Launched as a installed web application. 137 LM_AS_WEBAPP, // Launched as a installed web application.
138 LM_WITH_URLS, // Launched with urls in the cmd line. 138 LM_WITH_URLS, // Launched with urls in the cmd line.
139 LM_SHORTCUT_NONE, // Not launched from a shortcut. 139 LM_OTHER, // Not launched from a shortcut.
140 LM_SHORTCUT_NONAME, // Launched from shortcut but no name available. 140 LM_SHORTCUT_NONAME, // Launched from shortcut but no name available.
141 LM_SHORTCUT_UNKNOWN, // Launched from user-defined shortcut. 141 LM_SHORTCUT_UNKNOWN, // Launched from user-defined shortcut.
142 LM_SHORTCUT_QUICKLAUNCH, // Launched from the quick launch bar. 142 LM_SHORTCUT_QUICKLAUNCH, // Launched from the quick launch bar.
143 LM_SHORTCUT_DESKTOP, // Launched from a desktop shortcut. 143 LM_SHORTCUT_DESKTOP, // Launched from a desktop shortcut.
144 LM_SHORTCUT_TASKBAR, // Launched from the taskbar. 144 LM_SHORTCUT_TASKBAR, // Launched from the taskbar.
145 LM_LINUX_MAC_BEOS // Other OS buckets start here. 145 LM_USER_EXPERIMENT, // Launched after acceptance of a user experiment.
146 LM_LINUX_MAC_BEOS // Other OS buckets start here.
146 }; 147 };
147 148
148 #if defined(OS_WIN) 149 #if defined(OS_WIN)
149 // Undocumented flag in the startup info structure tells us what shortcut was 150 // Undocumented flag in the startup info structure tells us what shortcut was
150 // used to launch the browser. See http://www.catch22.net/tuts/undoc01 for 151 // used to launch the browser. See http://www.catch22.net/tuts/undoc01 for
151 // more information. Confirmed to work on XP, Vista and Win7. 152 // more information. Confirmed to work on XP, Vista and Win7.
152 LaunchMode GetLaunchShortcutKind() { 153 LaunchMode GetLaunchShortcutKind() {
153 STARTUPINFOW si = { sizeof(si) }; 154 STARTUPINFOW si = { sizeof(si) };
154 GetStartupInfoW(&si); 155 GetStartupInfoW(&si);
155 if (si.dwFlags & 0x800) { 156 if (si.dwFlags & 0x800) {
156 if (!si.lpTitle) 157 if (!si.lpTitle)
157 return LM_SHORTCUT_NONAME; 158 return LM_SHORTCUT_NONAME;
158 base::string16 shortcut(si.lpTitle); 159 base::string16 shortcut(si.lpTitle);
159 // The windows quick launch path is not localized. 160 // The windows quick launch path is not localized.
160 if (shortcut.find(L"\\Quick Launch\\") != base::string16::npos) { 161 if (shortcut.find(L"\\Quick Launch\\") != base::string16::npos) {
161 if (base::win::GetVersion() >= base::win::VERSION_WIN7) 162 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
162 return LM_SHORTCUT_TASKBAR; 163 return LM_SHORTCUT_TASKBAR;
163 else 164 else
164 return LM_SHORTCUT_QUICKLAUNCH; 165 return LM_SHORTCUT_QUICKLAUNCH;
165 } 166 }
166 std::unique_ptr<base::Environment> env(base::Environment::Create()); 167 std::unique_ptr<base::Environment> env(base::Environment::Create());
167 std::string appdata_path; 168 std::string appdata_path;
168 env->GetVar("USERPROFILE", &appdata_path); 169 env->GetVar("USERPROFILE", &appdata_path);
169 if (!appdata_path.empty() && 170 if (!appdata_path.empty() &&
170 shortcut.find(base::UTF8ToUTF16(appdata_path)) != base::string16::npos) 171 shortcut.find(base::UTF8ToUTF16(appdata_path)) != base::string16::npos)
171 return LM_SHORTCUT_DESKTOP; 172 return LM_SHORTCUT_DESKTOP;
172 return LM_SHORTCUT_UNKNOWN; 173 return LM_SHORTCUT_UNKNOWN;
173 } 174 }
174 return LM_SHORTCUT_NONE; 175 return LM_OTHER;
175 } 176 }
176 #else 177 #else
177 // TODO(cpu): Port to other platforms. 178 // TODO(cpu): Port to other platforms.
178 LaunchMode GetLaunchShortcutKind() { 179 LaunchMode GetLaunchShortcutKind() {
179 return LM_LINUX_MAC_BEOS; 180 return LM_LINUX_MAC_BEOS;
180 } 181 }
181 #endif 182 #endif
182 183
183 // Log in a histogram the frequency of launching by the different methods. See 184 // Log in a histogram the frequency of launching by the different methods. See
184 // LaunchMode enum for the actual values of the buckets. 185 // LaunchMode enum for the actual values of the buckets.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 is_first_run_(is_first_run == chrome::startup::IS_FIRST_RUN), 334 is_first_run_(is_first_run == chrome::startup::IS_FIRST_RUN),
334 welcome_run_type_(WelcomeRunType::NONE) { 335 welcome_run_type_(WelcomeRunType::NONE) {
335 } 336 }
336 337
337 StartupBrowserCreatorImpl::~StartupBrowserCreatorImpl() { 338 StartupBrowserCreatorImpl::~StartupBrowserCreatorImpl() {
338 } 339 }
339 340
340 bool StartupBrowserCreatorImpl::Launch(Profile* profile, 341 bool StartupBrowserCreatorImpl::Launch(Profile* profile,
341 const std::vector<GURL>& urls_to_open, 342 const std::vector<GURL>& urls_to_open,
342 bool process_startup) { 343 bool process_startup) {
343 UMA_HISTOGRAM_COUNTS_100("Startup.BrowserLaunchURLCount", 344 UMA_HISTOGRAM_COUNTS_100(
345 "Startup.BrowserLaunchURLCount",
344 static_cast<base::HistogramBase::Sample>(urls_to_open.size())); 346 static_cast<base::HistogramBase::Sample>(urls_to_open.size()));
345 RecordRapporOnStartupURLs(urls_to_open); 347 RecordRapporOnStartupURLs(urls_to_open);
346 348
347 DCHECK(profile); 349 DCHECK(profile);
348 profile_ = profile; 350 profile_ = profile;
349 351
350 if (AppListService::HandleLaunchCommandLine(command_line_, profile)) 352 if (AppListService::HandleLaunchCommandLine(command_line_, profile))
351 return true; 353 return true;
352 354
353 if (command_line_.HasSwitch(switches::kAppId)) { 355 if (command_line_.HasSwitch(switches::kAppId)) {
(...skipping 16 matching lines...) Expand all
370 // Open the required browser windows and tabs. First, see if 372 // Open the required browser windows and tabs. First, see if
371 // we're being run as an application window. If so, the user 373 // we're being run as an application window. If so, the user
372 // opened an app shortcut. Don't restore tabs or open initial 374 // opened an app shortcut. Don't restore tabs or open initial
373 // URLs in that case. The user should see the window as an app, 375 // URLs in that case. The user should see the window as an app,
374 // not as chrome. 376 // not as chrome.
375 // Special case is when app switches are passed but we do want to restore 377 // Special case is when app switches are passed but we do want to restore
376 // session. In that case open app window + focus it after session is restored. 378 // session. In that case open app window + focus it after session is restored.
377 if (OpenApplicationWindow(profile)) { 379 if (OpenApplicationWindow(profile)) {
378 RecordLaunchModeHistogram(LM_AS_WEBAPP); 380 RecordLaunchModeHistogram(LM_AS_WEBAPP);
379 } else { 381 } else {
380 RecordLaunchModeHistogram(urls_to_open.empty() ? 382 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
381 LM_TO_BE_DECIDED : LM_WITH_URLS); 383 switches::kTryChromeAgain)) {
384 RecordLaunchModeHistogram(LM_USER_EXPERIMENT);
385 } else {
386 RecordLaunchModeHistogram(urls_to_open.empty() ? LM_TO_BE_DECIDED
387 : LM_WITH_URLS);
388 }
382 389
383 if (StartupBrowserCreator::UseConsolidatedFlow()) 390 if (StartupBrowserCreator::UseConsolidatedFlow())
384 ProcessLaunchUrlsUsingConsolidatedFlow(process_startup, urls_to_open); 391 ProcessLaunchUrlsUsingConsolidatedFlow(process_startup, urls_to_open);
385 else 392 else
386 ProcessLaunchURLs(process_startup, urls_to_open); 393 ProcessLaunchURLs(process_startup, urls_to_open);
387 394
388 if (command_line_.HasSwitch(switches::kInstallChromeApp)) { 395 if (command_line_.HasSwitch(switches::kInstallChromeApp)) {
389 install_chrome_app::InstallChromeApp( 396 install_chrome_app::InstallChromeApp(
390 command_line_.GetSwitchValueASCII(switches::kInstallChromeApp)); 397 command_line_.GetSwitchValueASCII(switches::kInstallChromeApp));
391 } 398 }
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 #if defined(OS_WIN) 1262 #if defined(OS_WIN)
1256 TriggeredProfileResetter* triggered_profile_resetter = 1263 TriggeredProfileResetter* triggered_profile_resetter =
1257 TriggeredProfileResetterFactory::GetForBrowserContext(profile_); 1264 TriggeredProfileResetterFactory::GetForBrowserContext(profile_);
1258 // TriggeredProfileResetter instance will be nullptr for incognito profiles. 1265 // TriggeredProfileResetter instance will be nullptr for incognito profiles.
1259 if (triggered_profile_resetter) { 1266 if (triggered_profile_resetter) {
1260 has_reset_trigger = triggered_profile_resetter->HasResetTrigger(); 1267 has_reset_trigger = triggered_profile_resetter->HasResetTrigger();
1261 } 1268 }
1262 #endif // defined(OS_WIN) 1269 #endif // defined(OS_WIN)
1263 return has_reset_trigger; 1270 return has_reset_trigger;
1264 } 1271 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698