| 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/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 "chrome/browser/password_manager/login_database.h" | 9 #include "chrome/browser/password_manager/login_database.h" |
| 10 #include "chrome/browser/password_manager/password_store.h" | 10 #include "chrome/browser/password_manager/password_store.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 profile->GetWebDataService(Profile::IMPLICIT_ACCESS)); | 111 profile->GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 112 #elif defined(OS_MACOSX) | 112 #elif defined(OS_MACOSX) |
| 113 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseMockKeychain)) { | 113 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseMockKeychain)) { |
| 114 ps = new PasswordStoreMac(new crypto::MockKeychain(), login_db); | 114 ps = new PasswordStoreMac(new crypto::MockKeychain(), login_db); |
| 115 } else { | 115 } else { |
| 116 ps = new PasswordStoreMac(new crypto::MacKeychain(), login_db); | 116 ps = new PasswordStoreMac(new crypto::MacKeychain(), login_db); |
| 117 } | 117 } |
| 118 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID) | 118 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 119 // For now, we use PasswordStoreDefault. We might want to make a native | 119 // For now, we use PasswordStoreDefault. We might want to make a native |
| 120 // backend for PasswordStoreX (see below) in the future though. | 120 // backend for PasswordStoreX (see below) in the future though. |
| 121 ps = new PasswordStoreDefault( | 121 ps = new PasswordStoreDefault(login_db, profile); |
| 122 login_db, profile, profile->GetWebDataService(Profile::IMPLICIT_ACCESS)); | |
| 123 #elif defined(OS_POSIX) | 122 #elif defined(OS_POSIX) |
| 124 // On POSIX systems, we try to use the "native" password management system of | 123 // On POSIX systems, we try to use the "native" password management system of |
| 125 // the desktop environment currently running, allowing GNOME Keyring in XFCE. | 124 // the desktop environment currently running, allowing GNOME Keyring in XFCE. |
| 126 // (In all cases we fall back on the basic store in case of failure.) | 125 // (In all cases we fall back on the basic store in case of failure.) |
| 127 base::nix::DesktopEnvironment desktop_env; | 126 base::nix::DesktopEnvironment desktop_env; |
| 128 std::string store_type = | 127 std::string store_type = |
| 129 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 128 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 130 switches::kPasswordStore); | 129 switches::kPasswordStore); |
| 131 if (store_type == "kwallet") { | 130 if (store_type == "kwallet") { |
| 132 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; | 131 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 backend.reset(); | 165 backend.reset(); |
| 167 #endif // defined(USE_GNOME_KEYRING) | 166 #endif // defined(USE_GNOME_KEYRING) |
| 168 } | 167 } |
| 169 | 168 |
| 170 if (!backend.get()) { | 169 if (!backend.get()) { |
| 171 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " | 170 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " |
| 172 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " | 171 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " |
| 173 "more information about password storage options."; | 172 "more information about password storage options."; |
| 174 } | 173 } |
| 175 | 174 |
| 176 ps = new PasswordStoreX(login_db, profile, | 175 ps = new PasswordStoreX(login_db, profile, backend.release()); |
| 177 profile->GetWebDataService(Profile::IMPLICIT_ACCESS), | |
| 178 backend.release()); | |
| 179 #else | 176 #else |
| 180 NOTIMPLEMENTED(); | 177 NOTIMPLEMENTED(); |
| 181 #endif | 178 #endif |
| 182 if (!ps) | 179 if (!ps) |
| 183 delete login_db; | 180 delete login_db; |
| 184 | 181 |
| 185 if (!ps || !ps->Init()) { | 182 if (!ps || !ps->Init()) { |
| 186 NOTREACHED() << "Could not initialize password manager."; | 183 NOTREACHED() << "Could not initialize password manager."; |
| 187 return NULL; | 184 return NULL; |
| 188 } | 185 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 203 #endif | 200 #endif |
| 204 } | 201 } |
| 205 | 202 |
| 206 bool PasswordStoreFactory::ServiceRedirectedInIncognito() { | 203 bool PasswordStoreFactory::ServiceRedirectedInIncognito() { |
| 207 return true; | 204 return true; |
| 208 } | 205 } |
| 209 | 206 |
| 210 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() { | 207 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() { |
| 211 return true; | 208 return true; |
| 212 } | 209 } |
| OLD | NEW |