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

Side by Side Diff: chrome/browser/profile.cc

Issue 2730008: Linux: allow using GNOME Keyring and KWallet for password storage via a command line flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/profile.h" 5 #include "chrome/browser/profile.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "app/theme_provider.h" 8 #include "app/theme_provider.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/env_var.h" 10 #include "base/env_var.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // static 277 // static
278 URLRequestContextGetter* Profile::GetDefaultRequestContext() { 278 URLRequestContextGetter* Profile::GetDefaultRequestContext() {
279 return default_request_context_; 279 return default_request_context_;
280 } 280 }
281 281
282 #if defined(OS_WIN) 282 #if defined(OS_WIN)
283 #include "chrome/browser/password_manager/password_store_win.h" 283 #include "chrome/browser/password_manager/password_store_win.h"
284 #elif defined(OS_MACOSX) 284 #elif defined(OS_MACOSX)
285 #include "chrome/browser/keychain_mac.h" 285 #include "chrome/browser/keychain_mac.h"
286 #include "chrome/browser/password_manager/password_store_mac.h" 286 #include "chrome/browser/password_manager/password_store_mac.h"
287 #elif defined(OS_POSIX) 287 #elif defined(OS_POSIX) && !defined(OS_CHROMEOS)
288 // Temporarily disabled while we figure some stuff out. 288 #include "base/xdg_util.h"
289 // http://code.google.com/p/chromium/issues/detail?id=12351 289 #include "chrome/browser/password_manager/native_backend_gnome_x.h"
290 // #include "chrome/browser/password_manager/password_store_gnome.h" 290 #include "chrome/browser/password_manager/native_backend_kwallet_x.h"
291 // #include "chrome/browser/password_manager/password_store_kwallet.h" 291 #include "chrome/browser/password_manager/password_store_x.h"
292 #endif 292 #endif
293 293
294 //////////////////////////////////////////////////////////////////////////////// 294 ////////////////////////////////////////////////////////////////////////////////
295 // 295 //
296 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile 296 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
297 // to make it suitable for the off the record mode. 297 // to make it suitable for the off the record mode.
298 // 298 //
299 //////////////////////////////////////////////////////////////////////////////// 299 ////////////////////////////////////////////////////////////////////////////////
300 class OffTheRecordProfileImpl : public Profile, 300 class OffTheRecordProfileImpl : public Profile,
301 public NotificationObserver { 301 public NotificationObserver {
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 if (!login_db->Init(login_db_file_path)) { 1353 if (!login_db->Init(login_db_file_path)) {
1354 LOG(ERROR) << "Could not initialize login database."; 1354 LOG(ERROR) << "Could not initialize login database.";
1355 delete login_db; 1355 delete login_db;
1356 return; 1356 return;
1357 } 1357 }
1358 #if defined(OS_WIN) 1358 #if defined(OS_WIN)
1359 ps = new PasswordStoreWin(login_db, this, 1359 ps = new PasswordStoreWin(login_db, this,
1360 GetWebDataService(Profile::IMPLICIT_ACCESS)); 1360 GetWebDataService(Profile::IMPLICIT_ACCESS));
1361 #elif defined(OS_MACOSX) 1361 #elif defined(OS_MACOSX)
1362 ps = new PasswordStoreMac(new MacKeychain(), login_db); 1362 ps = new PasswordStoreMac(new MacKeychain(), login_db);
1363 #elif defined(OS_POSIX) 1363 #elif defined(OS_CHROMEOS)
1364 // TODO(evanm): implement "native" password management. 1364 // For now, we use PasswordStoreDefault. We might want to make a native
1365 // This bug describes the issues. 1365 // backend for PasswordStoreX (see below) in the future though.
1366 // http://code.google.com/p/chromium/issues/detail?id=12351
1367 ps = new PasswordStoreDefault(login_db, this, 1366 ps = new PasswordStoreDefault(login_db, this,
1368 GetWebDataService(Profile::IMPLICIT_ACCESS)); 1367 GetWebDataService(Profile::IMPLICIT_ACCESS));
1368 #elif defined(OS_POSIX)
1369 // On POSIX systems, we try to use the "native" password management system of
1370 // the desktop environment currently running, allowing GNOME Keyring in XFCE.
1371 // (In all cases we fall back on the default store in case of failure.)
1372 base::DesktopEnvironment desktop_env;
1373 std::wstring store_type = CommandLine::ForCurrentProcess()->GetSwitchValue(
1374 switches::kPasswordStore);
1375 if (store_type == L"kwallet") {
1376 desktop_env = base::DESKTOP_ENVIRONMENT_KDE4;
1377 } else if (store_type == L"gnome") {
1378 desktop_env = base::DESKTOP_ENVIRONMENT_GNOME;
1379 } else if (store_type == L"detect") {
1380 scoped_ptr<base::EnvVarGetter> env_getter(base::EnvVarGetter::Create());
1381 desktop_env = base::GetDesktopEnvironment(env_getter.get());
1382 LOG(INFO) << "Password storage detected desktop environment: " <<
1383 base::GetDesktopEnvironmentName(desktop_env);
1384 } else {
1385 // TODO(mdm): If the flag is not given, or has an unknown value, use the
1386 // default store for now. Once we're confident in the other stores, we can
1387 // default to detecting the desktop environment instead.
1388 desktop_env = base::DESKTOP_ENVIRONMENT_OTHER;
1389 }
1390
1391 scoped_ptr<PasswordStoreX::NativeBackend> backend;
1392 if (desktop_env == base::DESKTOP_ENVIRONMENT_KDE4) {
1393 // KDE3 didn't use DBus, which our KWallet store uses.
1394 LOG(INFO) << "Trying KWallet for password storage.";
1395 backend.reset(new NativeBackendKWallet());
1396 if (backend->Init())
1397 LOG(INFO) << "Using KWallet for password storage.";
1398 else
1399 backend.reset();
1400 } else if (desktop_env == base::DESKTOP_ENVIRONMENT_GNOME ||
1401 desktop_env == base::DESKTOP_ENVIRONMENT_XFCE) {
1402 LOG(INFO) << "Trying GNOME keyring for password storage.";
1403 backend.reset(new NativeBackendGnome());
1404 if (backend->Init())
1405 LOG(INFO) << "Using GNOME keyring for password storage.";
1406 else
1407 backend.reset();
1408 }
1409 // TODO(mdm): this can change to a WARNING when we detect by default.
1410 if (!backend.get())
1411 LOG(INFO) << "Using default (unencrypted) store for password storage.";
1412
1413 ps = new PasswordStoreX(login_db, this,
1414 GetWebDataService(Profile::IMPLICIT_ACCESS),
1415 backend.release());
1369 #else 1416 #else
1370 NOTIMPLEMENTED(); 1417 NOTIMPLEMENTED();
1371 #endif 1418 #endif
1372 if (!ps) 1419 if (!ps)
1373 delete login_db; 1420 delete login_db;
1374 1421
1375 if (!ps || !ps->Init()) { 1422 if (!ps || !ps->Init()) {
1376 NOTREACHED() << "Could not initialise password manager"; 1423 NOTREACHED() << "Could not initialize password manager.";
1377 return; 1424 return;
1378 } 1425 }
1379 password_store_.swap(ps); 1426 password_store_.swap(ps);
1380 } 1427 }
1381 1428
1382 DownloadManager* ProfileImpl::GetDownloadManager() { 1429 DownloadManager* ProfileImpl::GetDownloadManager() {
1383 if (!created_download_manager_) { 1430 if (!created_download_manager_) {
1384 scoped_refptr<DownloadManager> dlm(new DownloadManager); 1431 scoped_refptr<DownloadManager> dlm(new DownloadManager);
1385 dlm->Init(this); 1432 dlm->Init(this);
1386 created_download_manager_ = true; 1433 created_download_manager_ = true;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 CommandLine::ForCurrentProcess())); 1688 CommandLine::ForCurrentProcess()));
1642 sync_service_.reset( 1689 sync_service_.reset(
1643 profile_sync_factory_->CreateProfileSyncService()); 1690 profile_sync_factory_->CreateProfileSyncService());
1644 sync_service_->Initialize(); 1691 sync_service_->Initialize();
1645 } 1692 }
1646 1693
1647 void ProfileImpl::InitCloudPrintProxyService() { 1694 void ProfileImpl::InitCloudPrintProxyService() {
1648 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this)); 1695 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this));
1649 cloud_print_proxy_service_->Initialize(); 1696 cloud_print_proxy_service_->Initialize();
1650 } 1697 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698