 Chromium Code Reviews
 Chromium Code Reviews Issue 2118443002:
  Forward password-store switch to OSCrypt component  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 2118443002:
  Forward password-store switch to OSCrypt component  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/os_crypt/key_storage_linux.h" | 5 #include "components/os_crypt/key_storage_linux.h" | 
| 6 | 6 | 
| 7 #include <string.h> | |
| 8 | |
| 9 #include "base/environment.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "base/nix/xdg_util.h" | |
| 12 | |
| 13 #if defined(USE_LIBSECRET) | |
| 7 #include "components/os_crypt/key_storage_libsecret.h" | 14 #include "components/os_crypt/key_storage_libsecret.h" | 
| 15 #endif // defined(USE_LIBSECRET) | |
| 
Lei Zhang
2016/07/12 19:12:24
Personally, I'm kind of meh about the match commen
 
cfroussios
2016/07/13 09:33:10
Done.
 | |
| 16 | |
| 17 base::LazyInstance<std::string> g_store_ = LAZY_INSTANCE_INITIALIZER; | |
| 18 | |
| 19 // static | |
| 20 void KeyStorageLinux::SetStore(const std::string& store_type) { | |
| 21 g_store_.Get() = store_type; | |
| 22 VLOG(1) << "OSCrypt store set to " << store_type; | |
| 23 } | |
| 8 | 24 | 
| 9 // static | 25 // static | 
| 10 std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() { | 26 std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() { | 
| 11 std::unique_ptr<KeyStorageLinux> key_storage(new KeyStorageLibsecret()); | 27 base::nix::DesktopEnvironment used_desktop_env; | 
| 28 if (g_store_.Get() == "kwallet") { | |
| 29 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; | |
| 30 } else if (g_store_.Get() == "kwallet5") { | |
| 31 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE5; | |
| 32 } else if (g_store_.Get() == "gnome") { | |
| 33 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME; | |
| 34 } else if (g_store_.Get() == "basic") { | |
| 35 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER; | |
| 36 } else { | |
| 37 std::unique_ptr<base::Environment> env(base::Environment::Create()); | |
| 38 used_desktop_env = base::nix::GetDesktopEnvironment(env.get()); | |
| 39 } | |
| 12 | 40 | 
| 13 if (key_storage->Init()) | 41 // Try initializing the appropriate store for our environment. | 
| 14 return key_storage; | 42 std::unique_ptr<KeyStorageLinux> key_storage; | 
| 43 if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME || | |
| 44 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY || | |
| 45 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) { | |
| 46 #if defined(USE_LIBSECRET) | |
| 47 key_storage.reset(new KeyStorageLibsecret()); | |
| 48 if (key_storage->Init()) { | |
| 49 VLOG(1) << "OSCrypt using Libsecret as backend."; | |
| 50 return key_storage; | |
| 51 } | |
| 52 #endif | |
| 53 } | |
| 15 | 54 | 
| 55 // The appropriate store was not available. | |
| 56 VLOG(1) << "OSCrypt could not initialize a backend."; | |
| 16 return nullptr; | 57 return nullptr; | 
| 17 } | 58 } | 
| OLD | NEW |