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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 344883002: Collect UMA statistics on which chrome://flags lead to chrome restart on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 4 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 | « chrome/browser/about_flags_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('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/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #include "content/public/browser/browser_thread.h" 85 #include "content/public/browser/browser_thread.h"
86 #include "content/public/browser/notification_service.h" 86 #include "content/public/browser/notification_service.h"
87 #include "google_apis/gaia/gaia_auth_consumer.h" 87 #include "google_apis/gaia/gaia_auth_consumer.h"
88 #include "net/base/network_change_notifier.h" 88 #include "net/base/network_change_notifier.h"
89 #include "net/url_request/url_request_context.h" 89 #include "net/url_request/url_request_context.h"
90 #include "net/url_request/url_request_context_getter.h" 90 #include "net/url_request/url_request_context_getter.h"
91 #include "url/gurl.h" 91 #include "url/gurl.h"
92 92
93 using content::BrowserThread; 93 using content::BrowserThread;
94 94
95 namespace {
96
97 void LogCustomSwitches(const std::set<std::string>& switches) {
98 if (!VLOG_IS_ON(1))
99 return;
100 for (std::set<std::string>::const_iterator it = switches.begin();
101 it != switches.end();
102 ++it) {
103 VLOG(1) << "Switch leading to restart: '" << *it << "'";
104 }
105 }
106
107 } // anonymous namespace
108
95 namespace chromeos { 109 namespace chromeos {
96 110
97 namespace { 111 namespace {
98 112
99 // Returns new CommandLine with per-user flags. 113 // Returns new CommandLine with per-user flags.
100 CommandLine CreatePerSessionCommandLine(Profile* profile) { 114 CommandLine CreatePerSessionCommandLine(Profile* profile) {
101 CommandLine user_flags(CommandLine::NO_PROGRAM); 115 CommandLine user_flags(CommandLine::NO_PROGRAM);
102 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); 116 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs());
103 about_flags::ConvertFlagsToSwitches( 117 about_flags::ConvertFlagsToSwitches(
104 &flags_storage_, &user_flags, about_flags::kAddSentinels); 118 &flags_storage_, &user_flags, about_flags::kAddSentinels);
105 return user_flags; 119 return user_flags;
106 } 120 }
107 121
108 // Returns true if restart is needed to apply per-session flags. 122 // Returns true if restart is needed to apply per-session flags.
109 bool NeedRestartToApplyPerSessionFlags(const CommandLine& user_flags) { 123 bool NeedRestartToApplyPerSessionFlags(
124 const CommandLine& user_flags,
125 std::set<CommandLine::StringType>* out_command_line_difference) {
110 // Don't restart browser if it is not first profile in session. 126 // Don't restart browser if it is not first profile in session.
111 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() != 1) 127 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() != 1)
112 return false; 128 return false;
113 129
114 // Only restart if needed and if not going into managed mode. 130 // Only restart if needed and if not going into managed mode.
115 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) 131 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser())
116 return false; 132 return false;
117 133
118 if (about_flags::AreSwitchesIdenticalToCurrentCommandLine( 134 if (about_flags::AreSwitchesIdenticalToCurrentCommandLine(
119 user_flags, *CommandLine::ForCurrentProcess())) { 135 user_flags,
136 *CommandLine::ForCurrentProcess(),
137 out_command_line_difference)) {
120 return false; 138 return false;
121 } 139 }
122 140
123 return true; 141 return true;
124 } 142 }
125 143
126 bool CanPerformEarlyRestart() { 144 bool CanPerformEarlyRestart() {
127 // Desktop build is used for development only. Early restart is not supported. 145 // Desktop build is used for development only. Early restart is not supported.
128 if (!base::SysInfo::IsRunningOnChromeOS()) 146 if (!base::SysInfo::IsRunningOnChromeOS())
129 return false; 147 return false;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 370
353 bool LoginUtilsImpl::RestartToApplyPerSessionFlagsIfNeed(Profile* profile, 371 bool LoginUtilsImpl::RestartToApplyPerSessionFlagsIfNeed(Profile* profile,
354 bool early_restart) { 372 bool early_restart) {
355 if (ProfileHelper::IsSigninProfile(profile)) 373 if (ProfileHelper::IsSigninProfile(profile))
356 return false; 374 return false;
357 375
358 if (early_restart && !CanPerformEarlyRestart()) 376 if (early_restart && !CanPerformEarlyRestart())
359 return false; 377 return false;
360 378
361 const CommandLine user_flags(CreatePerSessionCommandLine(profile)); 379 const CommandLine user_flags(CreatePerSessionCommandLine(profile));
362 if (!NeedRestartToApplyPerSessionFlags(user_flags)) 380 std::set<CommandLine::StringType> command_line_difference;
381 if (!NeedRestartToApplyPerSessionFlags(user_flags, &command_line_difference))
363 return false; 382 return false;
364 383
384 LogCustomSwitches(command_line_difference);
385
386 about_flags::ReportCustomFlags("Login.CustomFlags", command_line_difference);
387
365 CommandLine::StringVector flags; 388 CommandLine::StringVector flags;
366 // argv[0] is the program name |CommandLine::NO_PROGRAM|. 389 // argv[0] is the program name |CommandLine::NO_PROGRAM|.
367 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); 390 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end());
368 VLOG(1) << "Restarting to apply per-session flags..."; 391 VLOG(1) << "Restarting to apply per-session flags...";
369 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( 392 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser(
370 user_manager::UserManager::Get()->GetActiveUser()->email(), flags); 393 user_manager::UserManager::Get()->GetActiveUser()->email(), flags);
371 AttemptRestart(profile); 394 AttemptRestart(profile);
372 return true; 395 return true;
373 } 396 }
374 397
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 CrosSettings* cros_settings = CrosSettings::Get(); 486 CrosSettings* cros_settings = CrosSettings::Get();
464 bool allow_new_user = false; 487 bool allow_new_user = false;
465 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 488 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
466 if (allow_new_user) 489 if (allow_new_user)
467 return true; 490 return true;
468 return cros_settings->FindEmailInList( 491 return cros_settings->FindEmailInList(
469 kAccountsPrefUsers, username, wildcard_match); 492 kAccountsPrefUsers, username, wildcard_match);
470 } 493 }
471 494
472 } // namespace chromeos 495 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/about_flags_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698