OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
14 #include "chrome/browser/browser_list.h" | 14 #include "chrome/browser/browser_list.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/download/download_manager.h" | 16 #include "chrome/browser/download/download_manager.h" |
17 #include "chrome/browser/extensions/extension_error_reporter.h" | 17 #include "chrome/browser/extensions/extension_error_reporter.h" |
18 #include "chrome/browser/extensions/extension_process_manager.h" | 18 #include "chrome/browser/extensions/extension_process_manager.h" |
19 #include "chrome/browser/extensions/extensions_service.h" | 19 #include "chrome/browser/extensions/extensions_service.h" |
20 #include "chrome/browser/extensions/user_script_master.h" | 20 #include "chrome/browser/extensions/user_script_master.h" |
21 #include "chrome/browser/history/history.h" | 21 #include "chrome/browser/history/history.h" |
22 #include "chrome/browser/net/chrome_url_request_context.h" | 22 #include "chrome/browser/net/chrome_url_request_context.h" |
| 23 #include "chrome/browser/password_manager/password_store_default.h" |
23 #include "chrome/browser/profile_manager.h" | 24 #include "chrome/browser/profile_manager.h" |
24 #include "chrome/browser/renderer_host/render_process_host.h" | 25 #include "chrome/browser/renderer_host/render_process_host.h" |
25 #include "chrome/browser/search_engines/template_url_fetcher.h" | 26 #include "chrome/browser/search_engines/template_url_fetcher.h" |
26 #include "chrome/browser/search_engines/template_url_model.h" | 27 #include "chrome/browser/search_engines/template_url_model.h" |
27 #include "chrome/browser/sessions/session_service.h" | 28 #include "chrome/browser/sessions/session_service.h" |
28 #include "chrome/browser/sessions/tab_restore_service.h" | 29 #include "chrome/browser/sessions/tab_restore_service.h" |
29 #include "chrome/browser/spellchecker.h" | 30 #include "chrome/browser/spellchecker.h" |
30 #include "chrome/browser/ssl/ssl_host_state.h" | 31 #include "chrome/browser/ssl/ssl_host_state.h" |
31 #include "chrome/browser/browser_theme_provider.h" | 32 #include "chrome/browser/browser_theme_provider.h" |
32 #include "chrome/browser/visitedlink_master.h" | 33 #include "chrome/browser/visitedlink_master.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // static | 82 // static |
82 Profile* Profile::CreateProfile(const FilePath& path) { | 83 Profile* Profile::CreateProfile(const FilePath& path) { |
83 return new ProfileImpl(path); | 84 return new ProfileImpl(path); |
84 } | 85 } |
85 | 86 |
86 // static | 87 // static |
87 URLRequestContext* Profile::GetDefaultRequestContext() { | 88 URLRequestContext* Profile::GetDefaultRequestContext() { |
88 return default_request_context_; | 89 return default_request_context_; |
89 } | 90 } |
90 | 91 |
| 92 #if defined(OS_LINUX) |
| 93 #include "chrome/browser/password_manager/password_store_gnome.h" |
| 94 #include "chrome/browser/password_manager/password_store_kwallet.h" |
| 95 #elif defined(OS_WIN) |
| 96 #include "chrome/browser/password_manager/password_store_win.h" |
| 97 #endif |
91 | 98 |
92 //////////////////////////////////////////////////////////////////////////////// | 99 //////////////////////////////////////////////////////////////////////////////// |
93 // | 100 // |
94 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile | 101 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile |
95 // to make it suitable for the off the record mode. | 102 // to make it suitable for the off the record mode. |
96 // | 103 // |
97 //////////////////////////////////////////////////////////////////////////////// | 104 //////////////////////////////////////////////////////////////////////////////// |
98 class OffTheRecordProfileImpl : public Profile, | 105 class OffTheRecordProfileImpl : public Profile, |
99 public NotificationObserver { | 106 public NotificationObserver { |
100 public: | 107 public: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 197 |
191 virtual WebDataService* GetWebDataService(ServiceAccessType sat) { | 198 virtual WebDataService* GetWebDataService(ServiceAccessType sat) { |
192 if (sat == EXPLICIT_ACCESS) { | 199 if (sat == EXPLICIT_ACCESS) { |
193 return profile_->GetWebDataService(sat); | 200 return profile_->GetWebDataService(sat); |
194 } else { | 201 } else { |
195 NOTREACHED() << "This profile is OffTheRecord"; | 202 NOTREACHED() << "This profile is OffTheRecord"; |
196 return NULL; | 203 return NULL; |
197 } | 204 } |
198 } | 205 } |
199 | 206 |
| 207 virtual PasswordStore* GetPasswordStore(ServiceAccessType sat) { |
| 208 if (sat == EXPLICIT_ACCESS) { |
| 209 return profile_->GetPasswordStore(sat); |
| 210 } else { |
| 211 NOTREACHED() << "This profile is OffTheRecord"; |
| 212 return NULL; |
| 213 } |
| 214 } |
| 215 |
200 virtual PrefService* GetPrefs() { | 216 virtual PrefService* GetPrefs() { |
201 return profile_->GetPrefs(); | 217 return profile_->GetPrefs(); |
202 } | 218 } |
203 | 219 |
204 virtual TemplateURLModel* GetTemplateURLModel() { | 220 virtual TemplateURLModel* GetTemplateURLModel() { |
205 return profile_->GetTemplateURLModel(); | 221 return profile_->GetTemplateURLModel(); |
206 } | 222 } |
207 | 223 |
208 virtual TemplateURLFetcher* GetTemplateURLFetcher() { | 224 virtual TemplateURLFetcher* GetTemplateURLFetcher() { |
209 return profile_->GetTemplateURLFetcher(); | 225 return profile_->GetTemplateURLFetcher(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 DISALLOW_EVIL_CONSTRUCTORS(OffTheRecordProfileImpl); | 425 DISALLOW_EVIL_CONSTRUCTORS(OffTheRecordProfileImpl); |
410 }; | 426 }; |
411 | 427 |
412 ProfileImpl::ProfileImpl(const FilePath& path) | 428 ProfileImpl::ProfileImpl(const FilePath& path) |
413 : path_(path), | 429 : path_(path), |
414 request_context_(NULL), | 430 request_context_(NULL), |
415 media_request_context_(NULL), | 431 media_request_context_(NULL), |
416 extensions_request_context_(NULL), | 432 extensions_request_context_(NULL), |
417 history_service_created_(false), | 433 history_service_created_(false), |
418 created_web_data_service_(false), | 434 created_web_data_service_(false), |
| 435 created_password_store_(false), |
419 created_download_manager_(false), | 436 created_download_manager_(false), |
420 created_theme_provider_(false), | 437 created_theme_provider_(false), |
421 start_time_(Time::Now()), | 438 start_time_(Time::Now()), |
422 spellchecker_(NULL), | 439 spellchecker_(NULL), |
423 shutdown_session_service_(false) { | 440 shutdown_session_service_(false) { |
424 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 441 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
425 "profile files to the root directory!"; | 442 "profile files to the root directory!"; |
426 create_session_service_timer_.Start( | 443 create_session_service_timer_.Start( |
427 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 444 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
428 &ProfileImpl::EnsureSessionServiceCreated); | 445 &ProfileImpl::EnsureSessionServiceCreated); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 | 800 |
784 void ProfileImpl::CreateWebDataService() { | 801 void ProfileImpl::CreateWebDataService() { |
785 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL); | 802 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL); |
786 created_web_data_service_ = true; | 803 created_web_data_service_ = true; |
787 scoped_refptr<WebDataService> wds(new WebDataService()); | 804 scoped_refptr<WebDataService> wds(new WebDataService()); |
788 if (!wds->Init(GetPath())) | 805 if (!wds->Init(GetPath())) |
789 return; | 806 return; |
790 web_data_service_.swap(wds); | 807 web_data_service_.swap(wds); |
791 } | 808 } |
792 | 809 |
| 810 PasswordStore* ProfileImpl::GetPasswordStore(ServiceAccessType sat) { |
| 811 if (!created_password_store_) |
| 812 CreatePasswordStore(); |
| 813 return password_store_.get(); |
| 814 } |
| 815 |
| 816 void ProfileImpl::CreatePasswordStore() { |
| 817 DCHECK(!created_password_store_ && password_store_.get() == NULL); |
| 818 created_password_store_ = true; |
| 819 scoped_refptr<PasswordStore> ps; |
| 820 #if defined(OS_LINUX) |
| 821 if (getenv("KDE_FULL_SESSION")) { |
| 822 ps = new PasswordStoreKWallet(); |
| 823 } else { |
| 824 ps = new PasswordStoreGnome(); |
| 825 } |
| 826 #elif defined(OS_WIN) |
| 827 ps = new PasswordStoreWin(GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 828 #else |
| 829 NOTIMPLEMENTED(); |
| 830 #endif |
| 831 if (!ps || !ps->Init()) { |
| 832 // Try falling back to the default password manager |
| 833 LOG(WARNING) << "Could not initialise native password manager - " |
| 834 "falling back to default"; |
| 835 ps = new PasswordStoreDefault(GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 836 if (!ps->Init()) |
| 837 return; |
| 838 } |
| 839 password_store_.swap(ps); |
| 840 } |
| 841 |
793 DownloadManager* ProfileImpl::GetDownloadManager() { | 842 DownloadManager* ProfileImpl::GetDownloadManager() { |
794 if (!created_download_manager_) { | 843 if (!created_download_manager_) { |
795 scoped_refptr<DownloadManager> dlm(new DownloadManager); | 844 scoped_refptr<DownloadManager> dlm(new DownloadManager); |
796 dlm->Init(this); | 845 dlm->Init(this); |
797 created_download_manager_ = true; | 846 created_download_manager_ = true; |
798 download_manager_.swap(dlm); | 847 download_manager_.swap(dlm); |
799 } | 848 } |
800 return download_manager_.get(); | 849 return download_manager_.get(); |
801 } | 850 } |
802 | 851 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 | 1065 |
1017 void ProfileImpl::StopCreateSessionServiceTimer() { | 1066 void ProfileImpl::StopCreateSessionServiceTimer() { |
1018 create_session_service_timer_.Stop(); | 1067 create_session_service_timer_.Stop(); |
1019 } | 1068 } |
1020 | 1069 |
1021 #ifdef CHROME_PERSONALIZATION | 1070 #ifdef CHROME_PERSONALIZATION |
1022 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { | 1071 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { |
1023 return personalization_.get(); | 1072 return personalization_.get(); |
1024 } | 1073 } |
1025 #endif | 1074 #endif |
OLD | NEW |