OLD | NEW |
---|---|
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 |
11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/location.h" | 17 #include "base/location.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/memory/singleton.h" | 20 #include "base/memory/singleton.h" |
21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
22 #include "base/metrics/sparse_histogram.h" | |
22 #include "base/prefs/pref_member.h" | 23 #include "base/prefs/pref_member.h" |
23 #include "base/prefs/pref_service.h" | 24 #include "base/prefs/pref_service.h" |
24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
26 #include "base/synchronization/lock.h" | 27 #include "base/synchronization/lock.h" |
27 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
28 #include "base/task_runner_util.h" | 29 #include "base/task_runner_util.h" |
29 #include "base/threading/worker_pool.h" | 30 #include "base/threading/worker_pool.h" |
30 #include "base/time/time.h" | 31 #include "base/time/time.h" |
31 #include "chrome/browser/about_flags.h" | 32 #include "chrome/browser/about_flags.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 #include "components/signin/core/browser/signin_manager.h" | 79 #include "components/signin/core/browser/signin_manager.h" |
79 #include "content/public/browser/browser_thread.h" | 80 #include "content/public/browser/browser_thread.h" |
80 #include "content/public/browser/notification_service.h" | 81 #include "content/public/browser/notification_service.h" |
81 #include "google_apis/gaia/gaia_auth_consumer.h" | 82 #include "google_apis/gaia/gaia_auth_consumer.h" |
82 #include "net/base/network_change_notifier.h" | 83 #include "net/base/network_change_notifier.h" |
83 #include "net/url_request/url_request_context.h" | 84 #include "net/url_request/url_request_context.h" |
84 #include "net/url_request/url_request_context_getter.h" | 85 #include "net/url_request/url_request_context_getter.h" |
85 #include "url/gurl.h" | 86 #include "url/gurl.h" |
86 | 87 |
87 using content::BrowserThread; | 88 using content::BrowserThread; |
88 | |
89 namespace chromeos { | 89 namespace chromeos { |
90 | 90 |
91 struct DoBrowserLaunchOnLocaleLoadedData; | 91 struct DoBrowserLaunchOnLocaleLoadedData; |
92 | 92 |
93 namespace { | |
94 | |
95 void ReportCustomFlags(const std::set<std::string>& command_line_difference) { | |
96 const std::map<std::string, int>& switch_histogram_id_map = | |
97 about_flags::GetSwitchesHistogramIds(); | |
98 for (std::set<std::string>::const_iterator it = | |
99 command_line_difference.begin(); | |
100 it != command_line_difference.end(); | |
101 ++it) { | |
102 int uma_id = about_flags::UMA_HISTOGRAM_ID_UNKNOWN_FLAG; | |
103 if (it->size() > 2) { | |
104 // skip '--' before switch name | |
105 std::string switch_name(it->substr(2)); | |
106 | |
107 // kill value, if any | |
108 const size_t value_pos = switch_name.find('='); | |
109 if (value_pos != std::string::npos) | |
110 switch_name.resize(value_pos); | |
111 | |
112 const std::map<std::string, int>::const_iterator pos = | |
113 switch_histogram_id_map.find(switch_name); | |
114 if (pos != switch_histogram_id_map.end()) { | |
115 uma_id = pos->second; | |
116 } else { | |
117 uma_id = about_flags::UMA_HISTOGRAM_ID_UNKNOWN_FLAG; | |
118 LOG(ERROR) << "ReportCustomFlags(): flag '" << *it << "' ('" | |
119 << switch_name << "') is unknown."; | |
120 } | |
121 } else { | |
122 uma_id = about_flags::UMA_HISTOGRAM_ID_BAD_FLAG_FORMAT; | |
123 LOG(ERROR) << "ReportCustomFlags(): flag '" << *it | |
124 << "' has incorrect format."; | |
125 } | |
126 LOG(ERROR) << "ReportCustomFlags(): '" << *it << "', uma_id=" << uma_id; | |
127 VLOG(1) << "ReportCustomFlags(): '" << *it << "', uma_id=" << uma_id; | |
Lei Zhang
2014/06/27 19:46:45
Seems unnecessary to have the LOG(ERROR) and VLOG(
Alexander Alekseev
2014/06/30 15:06:01
Done.
It was a debug print. Removed.
| |
128 UMA_HISTOGRAM_SPARSE_SLOWLY("Login.CustomFlags", uma_id); | |
129 } | |
130 } | |
131 | |
132 } // namespace | |
133 | |
93 class LoginUtilsImpl | 134 class LoginUtilsImpl |
94 : public LoginUtils, | 135 : public LoginUtils, |
95 public base::SupportsWeakPtr<LoginUtilsImpl>, | 136 public base::SupportsWeakPtr<LoginUtilsImpl>, |
96 public SessionManager::Delegate { | 137 public SessionManager::Delegate { |
97 public: | 138 public: |
98 LoginUtilsImpl() | 139 LoginUtilsImpl() |
99 : delegate_(NULL) { | 140 : delegate_(NULL) { |
100 } | 141 } |
101 | 142 |
102 virtual ~LoginUtilsImpl() { | 143 virtual ~LoginUtilsImpl() { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 LoginDisplayHost* login_host) { | 250 LoginDisplayHost* login_host) { |
210 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) { | 251 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) { |
211 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile); | 252 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile); |
212 return; | 253 return; |
213 } | 254 } |
214 | 255 |
215 CommandLine user_flags(CommandLine::NO_PROGRAM); | 256 CommandLine user_flags(CommandLine::NO_PROGRAM); |
216 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); | 257 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); |
217 about_flags::ConvertFlagsToSwitches(&flags_storage_, &user_flags, | 258 about_flags::ConvertFlagsToSwitches(&flags_storage_, &user_flags, |
218 about_flags::kAddSentinels); | 259 about_flags::kAddSentinels); |
260 | |
261 std::set<CommandLine::StringType> command_line_difference; | |
262 | |
219 // Only restart if needed and if not going into managed mode. | 263 // Only restart if needed and if not going into managed mode. |
220 // Don't restart browser if it is not first profile in session. | 264 // Don't restart browser if it is not first profile in session. |
221 if (UserManager::Get()->GetLoggedInUsers().size() == 1 && | 265 if (UserManager::Get()->GetLoggedInUsers().size() == 1 && |
222 !UserManager::Get()->IsLoggedInAsLocallyManagedUser() && | 266 !UserManager::Get()->IsLoggedInAsLocallyManagedUser() && |
223 !about_flags::AreSwitchesIdenticalToCurrentCommandLine( | 267 !about_flags::AreSwitchesIdenticalToCurrentCommandLine( |
224 user_flags, *CommandLine::ForCurrentProcess())) { | 268 user_flags, |
269 *CommandLine::ForCurrentProcess(), | |
270 &command_line_difference)) { | |
225 CommandLine::StringVector flags; | 271 CommandLine::StringVector flags; |
226 // argv[0] is the program name |CommandLine::NO_PROGRAM|. | 272 // argv[0] is the program name |CommandLine::NO_PROGRAM|. |
227 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); | 273 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); |
228 VLOG(1) << "Restarting to apply per-session flags..."; | 274 VLOG(1) << "Restarting to apply per-session flags..."; |
275 | |
276 ReportCustomFlags(command_line_difference); | |
277 | |
229 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( | 278 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( |
230 UserManager::Get()->GetActiveUser()->email(), flags); | 279 UserManager::Get()->GetActiveUser()->email(), flags); |
231 AttemptRestart(profile); | 280 AttemptRestart(profile); |
232 return; | 281 return; |
233 } | 282 } |
234 | 283 |
235 if (login_host) { | 284 if (login_host) { |
236 login_host->SetStatusAreaVisible(true); | 285 login_host->SetStatusAreaVisible(true); |
237 login_host->BeforeSessionStart(); | 286 login_host->BeforeSessionStart(); |
238 } | 287 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 CrosSettings* cros_settings = CrosSettings::Get(); | 449 CrosSettings* cros_settings = CrosSettings::Get(); |
401 bool allow_new_user = false; | 450 bool allow_new_user = false; |
402 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 451 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
403 if (allow_new_user) | 452 if (allow_new_user) |
404 return true; | 453 return true; |
405 return cros_settings->FindEmailInList( | 454 return cros_settings->FindEmailInList( |
406 kAccountsPrefUsers, username, wildcard_match); | 455 kAccountsPrefUsers, username, wildcard_match); |
407 } | 456 } |
408 | 457 |
409 } // namespace chromeos | 458 } // namespace chromeos |
OLD | NEW |