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

Side by Side Diff: chrome/browser/password_manager/password_store_factory.cc

Issue 880943002: UMA statistics for Linux password storage backend usage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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/password_manager/password_store_factory.h" 5 #include "chrome/browser/password_manager/password_store_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 ps = new password_manager::PasswordStoreDefault( 188 ps = new password_manager::PasswordStoreDefault(
189 main_thread_runner, db_thread_runner, login_db.Pass()); 189 main_thread_runner, db_thread_runner, login_db.Pass());
190 #elif defined(USE_X11) 190 #elif defined(USE_X11)
191 // On POSIX systems, we try to use the "native" password management system of 191 // On POSIX systems, we try to use the "native" password management system of
192 // the desktop environment currently running, allowing GNOME Keyring in XFCE. 192 // the desktop environment currently running, allowing GNOME Keyring in XFCE.
193 // (In all cases we fall back on the basic store in case of failure.) 193 // (In all cases we fall back on the basic store in case of failure.)
194 base::nix::DesktopEnvironment desktop_env; 194 base::nix::DesktopEnvironment desktop_env;
195 std::string store_type = 195 std::string store_type =
196 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 196 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
197 switches::kPasswordStore); 197 switches::kPasswordStore);
198 LinuxBackendUsed used_backend = PLAINTEXT;
198 if (store_type == "kwallet") { 199 if (store_type == "kwallet") {
199 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; 200 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4;
200 } else if (store_type == "gnome") { 201 } else if (store_type == "gnome") {
201 desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME; 202 desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME;
202 } else if (store_type == "basic") { 203 } else if (store_type == "basic") {
203 desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER; 204 desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER;
204 } else { 205 } else {
205 // Detect the store to use automatically. 206 // Detect the store to use automatically.
206 scoped_ptr<base::Environment> env(base::Environment::Create()); 207 scoped_ptr<base::Environment> env(base::Environment::Create());
207 desktop_env = base::nix::GetDesktopEnvironment(env.get()); 208 desktop_env = base::nix::GetDesktopEnvironment(env.get());
208 const char* name = base::nix::GetDesktopEnvironmentName(desktop_env); 209 const char* name = base::nix::GetDesktopEnvironmentName(desktop_env);
209 VLOG(1) << "Password storage detected desktop environment: " 210 VLOG(1) << "Password storage detected desktop environment: "
210 << (name ? name : "(unknown)"); 211 << (name ? name : "(unknown)");
211 } 212 }
212 213
213 PrefService* prefs = profile->GetPrefs(); 214 PrefService* prefs = profile->GetPrefs();
214 LocalProfileId id = GetLocalProfileId(prefs); 215 LocalProfileId id = GetLocalProfileId(prefs);
215 216
216 scoped_ptr<PasswordStoreX::NativeBackend> backend; 217 scoped_ptr<PasswordStoreX::NativeBackend> backend;
217 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) { 218 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) {
218 // KDE3 didn't use DBus, which our KWallet store uses. 219 // KDE3 didn't use DBus, which our KWallet store uses.
219 VLOG(1) << "Trying KWallet for password storage."; 220 VLOG(1) << "Trying KWallet for password storage.";
220 backend.reset(new NativeBackendKWallet(id)); 221 backend.reset(new NativeBackendKWallet(id));
221 if (backend->Init()) 222 if (backend->Init()) {
222 VLOG(1) << "Using KWallet for password storage."; 223 VLOG(1) << "Using KWallet for password storage.";
223 else 224 used_backend = KWALLET;
225 } else
224 backend.reset(); 226 backend.reset();
225 } else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME || 227 } else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME ||
226 desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY || 228 desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY ||
227 desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) { 229 desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) {
228 #if defined(USE_LIBSECRET) 230 #if defined(USE_LIBSECRET)
229 if (base::FieldTrialList::FindFullName(kLibsecretFieldTrialName) != 231 if (base::FieldTrialList::FindFullName(kLibsecretFieldTrialName) !=
230 kLibsecretFieldTrialDisabledGroupName) { 232 kLibsecretFieldTrialDisabledGroupName) {
231 VLOG(1) << "Trying libsecret for password storage."; 233 VLOG(1) << "Trying libsecret for password storage.";
232 backend.reset(new NativeBackendLibsecret(id)); 234 backend.reset(new NativeBackendLibsecret(id));
233 if (backend->Init()) 235 if (backend->Init()) {
234 VLOG(1) << "Using libsecret keyring for password storage."; 236 VLOG(1) << "Using libsecret keyring for password storage.";
235 else 237 used_backend = LIBSECRET;
238 } else
236 backend.reset(); 239 backend.reset();
237 } 240 }
238 #endif // defined(USE_LIBSECRET) 241 #endif // defined(USE_LIBSECRET)
239 if (!backend.get()) { 242 if (!backend.get()) {
240 #if defined(USE_GNOME_KEYRING) 243 #if defined(USE_GNOME_KEYRING)
241 VLOG(1) << "Trying GNOME keyring for password storage."; 244 VLOG(1) << "Trying GNOME keyring for password storage.";
242 backend.reset(new NativeBackendGnome(id)); 245 backend.reset(new NativeBackendGnome(id));
243 if (backend->Init()) 246 if (backend->Init()) {
244 VLOG(1) << "Using GNOME keyring for password storage."; 247 VLOG(1) << "Using GNOME keyring for password storage.";
245 else 248 used_backend = GNOME_KEYRING;
249 } else
246 backend.reset(); 250 backend.reset();
247 #endif // defined(USE_GNOME_KEYRING) 251 #endif // defined(USE_GNOME_KEYRING)
248 } 252 }
249 } 253 }
250 254
251 if (!backend.get()) { 255 if (!backend.get()) {
252 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " 256 LOG(WARNING) << "Using basic (unencrypted) store for password storage. "
253 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " 257 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for "
254 "more information about password storage options."; 258 "more information about password storage options.";
255 } 259 }
256 260
257 ps = new PasswordStoreX(main_thread_runner, db_thread_runner, login_db.Pass(), 261 ps = new PasswordStoreX(main_thread_runner, db_thread_runner, login_db.Pass(),
258 backend.release()); 262 backend.release());
263 RecordBackendStatistics(desktop_env, store_type, used_backend);
259 #elif defined(USE_OZONE) 264 #elif defined(USE_OZONE)
260 ps = new password_manager::PasswordStoreDefault( 265 ps = new password_manager::PasswordStoreDefault(
261 main_thread_runner, db_thread_runner, login_db.Pass()); 266 main_thread_runner, db_thread_runner, login_db.Pass());
262 #else 267 #else
263 NOTIMPLEMENTED(); 268 NOTIMPLEMENTED();
264 #endif 269 #endif
265 if (!ps.get() || 270 if (!ps.get() ||
266 !ps->Init( 271 !ps->Init(
267 sync_start_util::GetFlareForSyncableService(profile->GetPath()))) { 272 sync_start_util::GetFlareForSyncableService(profile->GetPath()))) {
268 NOTREACHED() << "Could not initialize password manager."; 273 NOTREACHED() << "Could not initialize password manager.";
(...skipping 16 matching lines...) Expand all
285 } 290 }
286 291
287 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( 292 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse(
288 content::BrowserContext* context) const { 293 content::BrowserContext* context) const {
289 return chrome::GetBrowserContextRedirectedInIncognito(context); 294 return chrome::GetBrowserContextRedirectedInIncognito(context);
290 } 295 }
291 296
292 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { 297 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const {
293 return true; 298 return true;
294 } 299 }
300
301 #if defined(USE_X11)
302 void PasswordStoreFactory::RecordBackendStatistics(
303 base::nix::DesktopEnvironment desktop_env,
304 const std::string& store_type,
305 LinuxBackendUsed used_backend) {
306 LinuxBackendUsage usage = OTHER_PLAINTEXT;
vabr (Chromium) 2015/01/27 16:15:51 But what about cases when the user forces a store
dvadym 2015/01/28 11:47:40 Done.
307 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) {
308 bool is_flag_used = store_type == "kwallet";
309 switch (used_backend) {
310 case KWALLET:
311 usage = is_flag_used ? KDE_FLAG_KWALLET : KDE_NOFLAG_KWALLET;
312 break;
313 case PLAINTEXT:
314 usage = is_flag_used ? KDE_FLAG_PLAINTEXT : KDE_NOFLAG_PLAINTEXT;
315 break;
316 case GNOME_KEYRING:
317 case LIBSECRET:
318 NOTREACHED();
319 }
320 } else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME ||
321 desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY ||
322 desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) {
323 bool is_flag_used = store_type == "gnome";
324 switch (used_backend) {
325 case GNOME_KEYRING:
326 usage = is_flag_used ? GNOME_FLAG_KEYRING : GNOME_NOFLAG_KEYRING;
327 break;
328 case LIBSECRET:
329 usage = is_flag_used ? GNOME_FLAG_LIBSECRET : GNOME_NOFLAG_LIBSECRET;
330 break;
331 case PLAINTEXT:
332 usage = is_flag_used ? GNOME_FLAG_PLAINTEXT : GNOME_NOFLAG_PLAINTEXT;
333 break;
334 case KWALLET:
335 NOTREACHED();
336 }
337 }
338 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage,
339 MAX_BACKEND_USAGE_VALUE);
340 }
341 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698