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 "base/metrics/histogram_macros.h" |
9 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "chrome/browser/password_manager/password_manager_util.h" |
10 #include "chrome/browser/password_manager/sync_metrics.h" | 12 #include "chrome/browser/password_manager/sync_metrics.h" |
11 #include "chrome/browser/profiles/incognito_helpers.h" | 13 #include "chrome/browser/profiles/incognito_helpers.h" |
12 #include "chrome/browser/sync/glue/sync_start_util.h" | 14 #include "chrome/browser/sync/glue/sync_start_util.h" |
13 #include "chrome/browser/webdata/web_data_service_factory.h" | 15 #include "chrome/browser/webdata/web_data_service_factory.h" |
14 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
17 #include "components/os_crypt/os_crypt_switches.h" | 19 #include "components/os_crypt/os_crypt_switches.h" |
18 #include "components/password_manager/core/browser/login_database.h" | 20 #include "components/password_manager/core/browser/login_database.h" |
19 #include "components/password_manager/core/browser/password_store.h" | 21 #include "components/password_manager/core/browser/password_store.h" |
(...skipping 15 matching lines...) Expand all Loading... |
35 #include "base/nix/xdg_util.h" | 37 #include "base/nix/xdg_util.h" |
36 #if defined(USE_GNOME_KEYRING) | 38 #if defined(USE_GNOME_KEYRING) |
37 #include "chrome/browser/password_manager/native_backend_gnome_x.h" | 39 #include "chrome/browser/password_manager/native_backend_gnome_x.h" |
38 #endif | 40 #endif |
39 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" | 41 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" |
40 #include "chrome/browser/password_manager/password_store_x.h" | 42 #include "chrome/browser/password_manager/password_store_x.h" |
41 #endif | 43 #endif |
42 | 44 |
43 using password_manager::PasswordStore; | 45 using password_manager::PasswordStore; |
44 | 46 |
45 #if !defined(OS_CHROMEOS) && defined(USE_X11) | |
46 namespace { | 47 namespace { |
47 | 48 |
| 49 #if !defined(OS_CHROMEOS) && defined(USE_X11) |
48 const LocalProfileId kInvalidLocalProfileId = | 50 const LocalProfileId kInvalidLocalProfileId = |
49 static_cast<LocalProfileId>(0); | 51 static_cast<LocalProfileId>(0); |
| 52 #endif |
| 53 |
| 54 void ReportOsPassword() { |
| 55 password_manager_util::OsPasswordStatus status = |
| 56 password_manager_util::GetOsPasswordStatus(); |
| 57 |
| 58 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OsPasswordStatus", |
| 59 status, |
| 60 password_manager_util::MAX_PASSWORD_STATUS); |
| 61 } |
| 62 |
| 63 void DelayReportOsPassword() { |
| 64 // Avoid checking OS password until later on in browser startup |
| 65 // since it calls a few Windows APIs. |
| 66 content::BrowserThread::PostDelayedTask( |
| 67 content::BrowserThread::FILE, |
| 68 FROM_HERE, |
| 69 base::Bind(&ReportOsPassword), |
| 70 base::TimeDelta::FromSeconds(40)); |
| 71 } |
50 | 72 |
51 } // namespace | 73 } // namespace |
52 #endif | 74 |
53 | 75 |
54 PasswordStoreService::PasswordStoreService( | 76 PasswordStoreService::PasswordStoreService( |
55 scoped_refptr<PasswordStore> password_store) | 77 scoped_refptr<PasswordStore> password_store) |
56 : password_store_(password_store) {} | 78 : password_store_(password_store) {} |
57 | 79 |
58 PasswordStoreService::~PasswordStoreService() {} | 80 PasswordStoreService::~PasswordStoreService() {} |
59 | 81 |
60 scoped_refptr<PasswordStore> PasswordStoreService::GetPasswordStore() { | 82 scoped_refptr<PasswordStore> PasswordStoreService::GetPasswordStore() { |
61 return password_store_; | 83 return password_store_; |
62 } | 84 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // TODO(mdm): scan other profiles to make sure they are not using this id? | 137 // TODO(mdm): scan other profiles to make sure they are not using this id? |
116 } while (id == kInvalidLocalProfileId); | 138 } while (id == kInvalidLocalProfileId); |
117 prefs->SetInteger(password_manager::prefs::kLocalProfileId, id); | 139 prefs->SetInteger(password_manager::prefs::kLocalProfileId, id); |
118 } | 140 } |
119 return id; | 141 return id; |
120 } | 142 } |
121 #endif | 143 #endif |
122 | 144 |
123 KeyedService* PasswordStoreFactory::BuildServiceInstanceFor( | 145 KeyedService* PasswordStoreFactory::BuildServiceInstanceFor( |
124 content::BrowserContext* context) const { | 146 content::BrowserContext* context) const { |
| 147 DelayReportOsPassword(); |
125 Profile* profile = static_cast<Profile*>(context); | 148 Profile* profile = static_cast<Profile*>(context); |
126 | 149 |
127 base::FilePath login_db_file_path = profile->GetPath(); | 150 base::FilePath login_db_file_path = profile->GetPath(); |
128 login_db_file_path = login_db_file_path.Append(chrome::kLoginDataFileName); | 151 login_db_file_path = login_db_file_path.Append(chrome::kLoginDataFileName); |
129 scoped_ptr<password_manager::LoginDatabase> login_db( | 152 scoped_ptr<password_manager::LoginDatabase> login_db( |
130 new password_manager::LoginDatabase()); | 153 new password_manager::LoginDatabase()); |
131 { | 154 { |
132 // TODO(paivanof@gmail.com): execution of login_db->Init() should go | 155 // TODO(paivanof@gmail.com): execution of login_db->Init() should go |
133 // to DB thread. http://crbug.com/138903 | 156 // to DB thread. http://crbug.com/138903 |
134 base::ThreadRestrictions::ScopedAllowIO allow_io; | 157 base::ThreadRestrictions::ScopedAllowIO allow_io; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 273 } |
251 | 274 |
252 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( | 275 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( |
253 content::BrowserContext* context) const { | 276 content::BrowserContext* context) const { |
254 return chrome::GetBrowserContextRedirectedInIncognito(context); | 277 return chrome::GetBrowserContextRedirectedInIncognito(context); |
255 } | 278 } |
256 | 279 |
257 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { | 280 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { |
258 return true; | 281 return true; |
259 } | 282 } |
OLD | NEW |