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

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

Issue 152683002: Passwords: Remove references to BrowserThread from PasswordStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 10 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 | Annotate | Revision Log
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/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/password_manager/login_database.h" 10 #include "chrome/browser/password_manager/login_database.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 { 105 {
106 // TODO(paivanof@gmail.com): execution of login_db->Init() should go 106 // TODO(paivanof@gmail.com): execution of login_db->Init() should go
107 // to DB thread. http://crbug.com/138903 107 // to DB thread. http://crbug.com/138903
108 base::ThreadRestrictions::ScopedAllowIO allow_io; 108 base::ThreadRestrictions::ScopedAllowIO allow_io;
109 if (!login_db->Init(login_db_file_path)) { 109 if (!login_db->Init(login_db_file_path)) {
110 LOG(ERROR) << "Could not initialize login database."; 110 LOG(ERROR) << "Could not initialize login database.";
111 delete login_db; 111 delete login_db;
112 return NULL; 112 return NULL;
113 } 113 }
114 } 114 }
115
116 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner(
117 base::MessageLoopProxy::current());
118 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner(
119 content::BrowserThread::GetMessageLoopProxyForThread(
120 content::BrowserThread::DB));
121
115 #if defined(OS_WIN) 122 #if defined(OS_WIN)
116 ps = new PasswordStoreWin( 123 ps = new PasswordStoreWin(main_thread_runner,
117 login_db, profile, 124 db_thread_runner,
118 WebDataService::FromBrowserContext(profile)); 125 login_db,
126 profile,
127 WebDataService::FromBrowserContext(profile));
119 #elif defined(OS_MACOSX) 128 #elif defined(OS_MACOSX)
120 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseMockKeychain)) { 129 crypto::AppleKeychain* keychain =
121 ps = new PasswordStoreMac(new crypto::MockAppleKeychain(), login_db); 130 CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseMockKeychain) ?
122 } else { 131 new crypto::MockAppleKeychain() : new crypto::AppleKeychain();
123 ps = new PasswordStoreMac(new crypto::AppleKeychain(), login_db); 132 ps = new PasswordStoreMac(
124 } 133 main_thread_runner, db_thread_runner, keychain, login_db);
125 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID) 134 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID)
126 // For now, we use PasswordStoreDefault. We might want to make a native 135 // For now, we use PasswordStoreDefault. We might want to make a native
127 // backend for PasswordStoreX (see below) in the future though. 136 // backend for PasswordStoreX (see below) in the future though.
128 ps = new PasswordStoreDefault(login_db, profile); 137 ps = new PasswordStoreDefault(
138 main_thread_runner, db_thread_runner, login_db, profile);
129 #elif defined(USE_X11) 139 #elif defined(USE_X11)
130 // On POSIX systems, we try to use the "native" password management system of 140 // On POSIX systems, we try to use the "native" password management system of
131 // the desktop environment currently running, allowing GNOME Keyring in XFCE. 141 // the desktop environment currently running, allowing GNOME Keyring in XFCE.
132 // (In all cases we fall back on the basic store in case of failure.) 142 // (In all cases we fall back on the basic store in case of failure.)
133 base::nix::DesktopEnvironment desktop_env; 143 base::nix::DesktopEnvironment desktop_env;
134 std::string store_type = 144 std::string store_type =
135 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 145 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
136 switches::kPasswordStore); 146 switches::kPasswordStore);
137 if (store_type == "kwallet") { 147 if (store_type == "kwallet") {
138 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; 148 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 backend.reset(); 183 backend.reset();
174 #endif // defined(USE_GNOME_KEYRING) 184 #endif // defined(USE_GNOME_KEYRING)
175 } 185 }
176 186
177 if (!backend.get()) { 187 if (!backend.get()) {
178 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " 188 LOG(WARNING) << "Using basic (unencrypted) store for password storage. "
179 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " 189 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for "
180 "more information about password storage options."; 190 "more information about password storage options.";
181 } 191 }
182 192
183 ps = new PasswordStoreX(login_db, profile, backend.release()); 193 ps = new PasswordStoreX(main_thread_runner,
194 db_thread_runner,
195 login_db,
196 profile,
197 backend.release());
184 #elif defined(USE_OZONE) 198 #elif defined(USE_OZONE)
185 ps = new PasswordStoreDefault(login_db, profile); 199 ps = new PasswordStoreDefault(
200 main_thread_runner, db_thread_runner, login_db, profile);
186 #else 201 #else
187 NOTIMPLEMENTED(); 202 NOTIMPLEMENTED();
188 #endif 203 #endif
204
189 if (!ps.get()) 205 if (!ps.get())
190 delete login_db; 206 delete login_db;
191 207
192 if (!ps.get() || !ps->Init()) { 208 if (!ps.get() || !ps->Init()) {
193 NOTREACHED() << "Could not initialize password manager."; 209 NOTREACHED() << "Could not initialize password manager.";
194 return NULL; 210 return NULL;
195 } 211 }
196 212
197 return ps; 213 return ps;
198 } 214 }
(...skipping 13 matching lines...) Expand all
212 } 228 }
213 229
214 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( 230 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse(
215 content::BrowserContext* context) const { 231 content::BrowserContext* context) const {
216 return chrome::GetBrowserContextRedirectedInIncognito(context); 232 return chrome::GetBrowserContextRedirectedInIncognito(context);
217 } 233 }
218 234
219 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { 235 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const {
220 return true; 236 return true;
221 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698