Chromium Code Reviews| 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_default.h" | 10 #include "chrome/browser/password_manager/password_store_default.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 "PasswordStore", | 62 "PasswordStore", |
| 63 ProfileDependencyManager::GetInstance()) { | 63 ProfileDependencyManager::GetInstance()) { |
| 64 // TODO(erg): We must always depend on WebDB; we don't want the dependency | 64 // TODO(erg): We must always depend on WebDB; we don't want the dependency |
| 65 // graph to be different based on platform. | 65 // graph to be different based on platform. |
| 66 // | 66 // |
| 67 // DependsOn(WebDataServiceFactory::GetInstance()); | 67 // DependsOn(WebDataServiceFactory::GetInstance()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 PasswordStoreFactory::~PasswordStoreFactory() {} | 70 PasswordStoreFactory::~PasswordStoreFactory() {} |
| 71 | 71 |
| 72 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) | 72 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) |
|
Elliot Glaysher
2012/03/14 17:19:54
Do you need a !defined(ANDROID) here, too?
| |
| 73 LocalProfileId PasswordStoreFactory::GetLocalProfileId( | 73 LocalProfileId PasswordStoreFactory::GetLocalProfileId( |
| 74 PrefService* prefs) const { | 74 PrefService* prefs) const { |
| 75 LocalProfileId id = prefs->GetInteger(prefs::kLocalProfileId); | 75 LocalProfileId id = prefs->GetInteger(prefs::kLocalProfileId); |
| 76 if (id == kInvalidLocalProfileId) { | 76 if (id == kInvalidLocalProfileId) { |
| 77 // Note that there are many more users than this. Thus, by design, this is | 77 // Note that there are many more users than this. Thus, by design, this is |
| 78 // not a unique id. However, it is large enough that it is very unlikely | 78 // not a unique id. However, it is large enough that it is very unlikely |
| 79 // that it would be repeated twice on a single machine. It is still possible | 79 // that it would be repeated twice on a single machine. It is still possible |
| 80 // for that to occur though, so the potential results of it actually | 80 // for that to occur though, so the potential results of it actually |
| 81 // happening should be considered when using this value. | 81 // happening should be considered when using this value. |
| 82 static const LocalProfileId kLocalProfileIdMask = | 82 static const LocalProfileId kLocalProfileIdMask = |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 105 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
| 106 ps = new PasswordStoreWin( | 106 ps = new PasswordStoreWin( |
| 107 login_db, profile, | 107 login_db, profile, |
| 108 profile->GetWebDataService(Profile::IMPLICIT_ACCESS)); | 108 profile->GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 109 #elif defined(OS_MACOSX) | 109 #elif defined(OS_MACOSX) |
| 110 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseMockKeychain)) { | 110 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseMockKeychain)) { |
| 111 ps = new PasswordStoreMac(new MockKeychain(), login_db); | 111 ps = new PasswordStoreMac(new MockKeychain(), login_db); |
| 112 } else { | 112 } else { |
| 113 ps = new PasswordStoreMac(new MacKeychain(), login_db); | 113 ps = new PasswordStoreMac(new MacKeychain(), login_db); |
| 114 } | 114 } |
| 115 #elif defined(OS_CHROMEOS) | 115 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 116 // For now, we use PasswordStoreDefault. We might want to make a native | 116 // For now, we use PasswordStoreDefault. We might want to make a native |
| 117 // backend for PasswordStoreX (see below) in the future though. | 117 // backend for PasswordStoreX (see below) in the future though. |
| 118 ps = new PasswordStoreDefault( | 118 ps = new PasswordStoreDefault( |
| 119 login_db, profile, | 119 login_db, profile, profile->GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 120 profile->GetWebDataService(Profile::IMPLICIT_ACCESS)); | |
| 121 #elif defined(OS_POSIX) | 120 #elif defined(OS_POSIX) |
| 122 // On POSIX systems, we try to use the "native" password management system of | 121 // On POSIX systems, we try to use the "native" password management system of |
| 123 // the desktop environment currently running, allowing GNOME Keyring in XFCE. | 122 // the desktop environment currently running, allowing GNOME Keyring in XFCE. |
| 124 // (In all cases we fall back on the basic store in case of failure.) | 123 // (In all cases we fall back on the basic store in case of failure.) |
| 125 base::nix::DesktopEnvironment desktop_env; | 124 base::nix::DesktopEnvironment desktop_env; |
| 126 std::string store_type = | 125 std::string store_type = |
| 127 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 126 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 128 switches::kPasswordStore); | 127 switches::kPasswordStore); |
| 129 if (store_type == "kwallet") { | 128 if (store_type == "kwallet") { |
| 130 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; | 129 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 | 181 |
| 183 if (!ps || !ps->Init()) { | 182 if (!ps || !ps->Init()) { |
| 184 NOTREACHED() << "Could not initialize password manager."; | 183 NOTREACHED() << "Could not initialize password manager."; |
| 185 return NULL; | 184 return NULL; |
| 186 } | 185 } |
| 187 | 186 |
| 188 return ps.release(); | 187 return ps.release(); |
| 189 } | 188 } |
| 190 | 189 |
| 191 void PasswordStoreFactory::RegisterUserPrefs(PrefService* prefs) { | 190 void PasswordStoreFactory::RegisterUserPrefs(PrefService* prefs) { |
| 192 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) | 191 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) \ |
| 192 && defined(OS_POSIX) | |
| 193 prefs->RegisterIntegerPref(prefs::kLocalProfileId, | 193 prefs->RegisterIntegerPref(prefs::kLocalProfileId, |
| 194 kInvalidLocalProfileId, | 194 kInvalidLocalProfileId, |
| 195 PrefService::UNSYNCABLE_PREF); | 195 PrefService::UNSYNCABLE_PREF); |
| 196 | 196 |
| 197 // Notice that the preprocessor conditions above are exactly those that will | 197 // Notice that the preprocessor conditions above are exactly those that will |
| 198 // result in using PasswordStoreX in CreatePasswordStore() below. | 198 // result in using PasswordStoreX in CreatePasswordStore() below. |
| 199 PasswordStoreX::RegisterUserPrefs(prefs); | 199 PasswordStoreX::RegisterUserPrefs(prefs); |
| 200 #endif | 200 #endif |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool PasswordStoreFactory::ServiceRedirectedInIncognito() { | 203 bool PasswordStoreFactory::ServiceRedirectedInIncognito() { |
| 204 return true; | 204 return true; |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() { | 207 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() { |
| 208 return true; | 208 return true; |
| 209 } | 209 } |
| OLD | NEW |