OLD | NEW |
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/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 tab_restore_service_ = NULL; | 459 tab_restore_service_ = NULL; |
460 | 460 |
461 StopCreateSessionServiceTimer(); | 461 StopCreateSessionServiceTimer(); |
462 // TemplateURLModel schedules a task on the WebDataService from its | 462 // TemplateURLModel schedules a task on the WebDataService from its |
463 // destructor. Delete it first to ensure the task gets scheduled before we | 463 // destructor. Delete it first to ensure the task gets scheduled before we |
464 // shut down the database. | 464 // shut down the database. |
465 template_url_model_.reset(); | 465 template_url_model_.reset(); |
466 | 466 |
467 // DownloadManager is lazily created, so check before accessing it. | 467 // DownloadManager is lazily created, so check before accessing it. |
468 if (download_manager_.get()) { | 468 if (download_manager_.get()) { |
469 // The download manager queries the history system and should be shutdown | 469 // The download manager queries the history system and should be shut down |
470 // before the history is shutdown so it can properly cancel all requests. | 470 // before the history is shut down so it can properly cancel all requests. |
471 download_manager_->Shutdown(); | 471 download_manager_->Shutdown(); |
472 download_manager_ = NULL; | 472 download_manager_ = NULL; |
473 } | 473 } |
474 | 474 |
475 // The theme provider provides bitmaps to whoever wants them. | 475 // The theme provider provides bitmaps to whoever wants them. |
476 theme_provider_.reset(); | 476 theme_provider_.reset(); |
477 | 477 |
478 // Remove pref observers | 478 // Remove pref observers |
479 pref_change_registrar_.RemoveAll(); | 479 pref_change_registrar_.RemoveAll(); |
480 | 480 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 #elif defined(OS_MACOSX) | 916 #elif defined(OS_MACOSX) |
917 ps = new PasswordStoreMac(new MacKeychain(), login_db); | 917 ps = new PasswordStoreMac(new MacKeychain(), login_db); |
918 #elif defined(OS_CHROMEOS) | 918 #elif defined(OS_CHROMEOS) |
919 // For now, we use PasswordStoreDefault. We might want to make a native | 919 // For now, we use PasswordStoreDefault. We might want to make a native |
920 // backend for PasswordStoreX (see below) in the future though. | 920 // backend for PasswordStoreX (see below) in the future though. |
921 ps = new PasswordStoreDefault(login_db, this, | 921 ps = new PasswordStoreDefault(login_db, this, |
922 GetWebDataService(Profile::IMPLICIT_ACCESS)); | 922 GetWebDataService(Profile::IMPLICIT_ACCESS)); |
923 #elif defined(OS_POSIX) | 923 #elif defined(OS_POSIX) |
924 // On POSIX systems, we try to use the "native" password management system of | 924 // On POSIX systems, we try to use the "native" password management system of |
925 // the desktop environment currently running, allowing GNOME Keyring in XFCE. | 925 // the desktop environment currently running, allowing GNOME Keyring in XFCE. |
926 // (In all cases we fall back on the default store in case of failure.) | 926 // (In all cases we fall back on the basic store in case of failure.) |
927 base::nix::DesktopEnvironment desktop_env; | 927 base::nix::DesktopEnvironment desktop_env; |
928 std::string store_type = | 928 std::string store_type = |
929 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 929 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
930 switches::kPasswordStore); | 930 switches::kPasswordStore); |
931 if (store_type == "kwallet") { | 931 if (store_type == "kwallet") { |
932 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; | 932 desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; |
933 } else if (store_type == "gnome") { | 933 } else if (store_type == "gnome") { |
934 desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME; | 934 desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME; |
935 } else if (store_type == "detect") { | 935 } else if (store_type == "basic") { |
| 936 desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER; |
| 937 } else { // Detect the store to use automatically. |
936 scoped_ptr<base::Environment> env(base::Environment::Create()); | 938 scoped_ptr<base::Environment> env(base::Environment::Create()); |
937 desktop_env = base::nix::GetDesktopEnvironment(env.get()); | 939 desktop_env = base::nix::GetDesktopEnvironment(env.get()); |
938 VLOG(1) << "Password storage detected desktop environment: " | 940 VLOG(1) << "Password storage detected desktop environment: " |
939 << base::nix::GetDesktopEnvironmentName(desktop_env); | 941 << base::nix::GetDesktopEnvironmentName(desktop_env); |
940 } else { | |
941 // TODO(mdm): If the flag is not given, or has an unknown value, use the | |
942 // default store for now. Once we're confident in the other stores, we can | |
943 // default to detecting the desktop environment instead. | |
944 desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER; | |
945 } | 942 } |
946 | 943 |
947 scoped_ptr<PasswordStoreX::NativeBackend> backend; | 944 scoped_ptr<PasswordStoreX::NativeBackend> backend; |
948 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) { | 945 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) { |
949 // KDE3 didn't use DBus, which our KWallet store uses. | 946 // KDE3 didn't use DBus, which our KWallet store uses. |
950 VLOG(1) << "Trying KWallet for password storage."; | 947 VLOG(1) << "Trying KWallet for password storage."; |
951 backend.reset(new NativeBackendKWallet()); | 948 backend.reset(new NativeBackendKWallet()); |
952 if (backend->Init()) | 949 if (backend->Init()) |
953 VLOG(1) << "Using KWallet for password storage."; | 950 VLOG(1) << "Using KWallet for password storage."; |
954 else | 951 else |
955 backend.reset(); | 952 backend.reset(); |
956 } else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME || | 953 } else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME || |
957 desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) { | 954 desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) { |
958 #if defined(USE_GNOME_KEYRING) | 955 #if defined(USE_GNOME_KEYRING) |
959 VLOG(1) << "Trying GNOME keyring for password storage."; | 956 VLOG(1) << "Trying GNOME keyring for password storage."; |
960 backend.reset(new NativeBackendGnome()); | 957 backend.reset(new NativeBackendGnome()); |
961 if (backend->Init()) | 958 if (backend->Init()) |
962 VLOG(1) << "Using GNOME keyring for password storage."; | 959 VLOG(1) << "Using GNOME keyring for password storage."; |
963 else | 960 else |
964 backend.reset(); | 961 backend.reset(); |
965 #endif // defined(USE_GNOME_KEYRING) | 962 #endif // defined(USE_GNOME_KEYRING) |
966 } | 963 } |
967 // TODO(mdm): this can change to a WARNING when we detect by default. | 964 if (!backend.get()) { |
968 if (!backend.get()) | 965 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " |
969 VLOG(1) << "Using default (unencrypted) store for password storage."; | 966 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " |
| 967 "more information about password storage options."; |
| 968 } |
970 | 969 |
971 ps = new PasswordStoreX(login_db, this, | 970 ps = new PasswordStoreX(login_db, this, |
972 GetWebDataService(Profile::IMPLICIT_ACCESS), | 971 GetWebDataService(Profile::IMPLICIT_ACCESS), |
973 backend.release()); | 972 backend.release()); |
974 #else | 973 #else |
975 NOTIMPLEMENTED(); | 974 NOTIMPLEMENTED(); |
976 #endif | 975 #endif |
977 if (!ps) | 976 if (!ps) |
978 delete login_db; | 977 delete login_db; |
979 | 978 |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 } | 1362 } |
1364 | 1363 |
1365 PrerenderManager* ProfileImpl::GetPrerenderManager() { | 1364 PrerenderManager* ProfileImpl::GetPrerenderManager() { |
1366 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1365 CommandLine* cl = CommandLine::ForCurrentProcess(); |
1367 if (!cl->HasSwitch(switches::kEnablePagePrerender)) | 1366 if (!cl->HasSwitch(switches::kEnablePagePrerender)) |
1368 return NULL; | 1367 return NULL; |
1369 if (!prerender_manager_.get()) | 1368 if (!prerender_manager_.get()) |
1370 prerender_manager_.reset(new PrerenderManager(this)); | 1369 prerender_manager_.reset(new PrerenderManager(this)); |
1371 return prerender_manager_.get(); | 1370 return prerender_manager_.get(); |
1372 } | 1371 } |
OLD | NEW |