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_process_manager.h" | 17 #include "chrome/browser/extensions/extension_process_manager.h" |
18 #include "chrome/browser/extensions/extensions_service.h" | 18 #include "chrome/browser/extensions/extensions_service.h" |
19 #include "chrome/browser/extensions/user_script_master.h" | 19 #include "chrome/browser/extensions/user_script_master.h" |
20 #include "chrome/browser/history/history.h" | 20 #include "chrome/browser/history/history.h" |
21 #include "chrome/browser/net/chrome_url_request_context.h" | 21 #include "chrome/browser/net/chrome_url_request_context.h" |
| 22 #include "chrome/browser/password_manager/password_store_default.h" |
22 #include "chrome/browser/profile_manager.h" | 23 #include "chrome/browser/profile_manager.h" |
23 #include "chrome/browser/renderer_host/render_process_host.h" | 24 #include "chrome/browser/renderer_host/render_process_host.h" |
24 #include "chrome/browser/search_engines/template_url_fetcher.h" | 25 #include "chrome/browser/search_engines/template_url_fetcher.h" |
25 #include "chrome/browser/search_engines/template_url_model.h" | 26 #include "chrome/browser/search_engines/template_url_model.h" |
26 #include "chrome/browser/sessions/session_service.h" | 27 #include "chrome/browser/sessions/session_service.h" |
27 #include "chrome/browser/sessions/tab_restore_service.h" | 28 #include "chrome/browser/sessions/tab_restore_service.h" |
28 #include "chrome/browser/spellchecker.h" | 29 #include "chrome/browser/spellchecker.h" |
29 #include "chrome/browser/ssl/ssl_host_state.h" | 30 #include "chrome/browser/ssl/ssl_host_state.h" |
30 #include "chrome/browser/browser_theme_provider.h" | 31 #include "chrome/browser/browser_theme_provider.h" |
31 #include "chrome/browser/visitedlink_master.h" | 32 #include "chrome/browser/visitedlink_master.h" |
(...skipping 49 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 // Temporarily disabled while we figure some stuff out. |
| 94 // http://code.google.com/p/chromium/issues/detail?id=12351 |
| 95 // #include "chrome/browser/password_manager/password_store_gnome.h" |
| 96 // #include "chrome/browser/password_manager/password_store_kwallet.h" |
| 97 #elif defined(OS_WIN) |
| 98 #include "chrome/browser/password_manager/password_store_win.h" |
| 99 #endif |
91 | 100 |
92 //////////////////////////////////////////////////////////////////////////////// | 101 //////////////////////////////////////////////////////////////////////////////// |
93 // | 102 // |
94 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile | 103 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile |
95 // to make it suitable for the off the record mode. | 104 // to make it suitable for the off the record mode. |
96 // | 105 // |
97 //////////////////////////////////////////////////////////////////////////////// | 106 //////////////////////////////////////////////////////////////////////////////// |
98 class OffTheRecordProfileImpl : public Profile, | 107 class OffTheRecordProfileImpl : public Profile, |
99 public NotificationObserver { | 108 public NotificationObserver { |
100 public: | 109 public: |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 191 |
183 virtual WebDataService* GetWebDataService(ServiceAccessType sat) { | 192 virtual WebDataService* GetWebDataService(ServiceAccessType sat) { |
184 if (sat == EXPLICIT_ACCESS) { | 193 if (sat == EXPLICIT_ACCESS) { |
185 return profile_->GetWebDataService(sat); | 194 return profile_->GetWebDataService(sat); |
186 } else { | 195 } else { |
187 NOTREACHED() << "This profile is OffTheRecord"; | 196 NOTREACHED() << "This profile is OffTheRecord"; |
188 return NULL; | 197 return NULL; |
189 } | 198 } |
190 } | 199 } |
191 | 200 |
| 201 virtual PasswordStore* GetPasswordStore(ServiceAccessType sat) { |
| 202 if (sat == EXPLICIT_ACCESS) { |
| 203 return profile_->GetPasswordStore(sat); |
| 204 } else { |
| 205 NOTREACHED() << "This profile is OffTheRecord"; |
| 206 return NULL; |
| 207 } |
| 208 } |
| 209 |
192 virtual PrefService* GetPrefs() { | 210 virtual PrefService* GetPrefs() { |
193 return profile_->GetPrefs(); | 211 return profile_->GetPrefs(); |
194 } | 212 } |
195 | 213 |
196 virtual TemplateURLModel* GetTemplateURLModel() { | 214 virtual TemplateURLModel* GetTemplateURLModel() { |
197 return profile_->GetTemplateURLModel(); | 215 return profile_->GetTemplateURLModel(); |
198 } | 216 } |
199 | 217 |
200 virtual TemplateURLFetcher* GetTemplateURLFetcher() { | 218 virtual TemplateURLFetcher* GetTemplateURLFetcher() { |
201 return profile_->GetTemplateURLFetcher(); | 219 return profile_->GetTemplateURLFetcher(); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 DISALLOW_EVIL_CONSTRUCTORS(OffTheRecordProfileImpl); | 400 DISALLOW_EVIL_CONSTRUCTORS(OffTheRecordProfileImpl); |
383 }; | 401 }; |
384 | 402 |
385 ProfileImpl::ProfileImpl(const FilePath& path) | 403 ProfileImpl::ProfileImpl(const FilePath& path) |
386 : path_(path), | 404 : path_(path), |
387 request_context_(NULL), | 405 request_context_(NULL), |
388 media_request_context_(NULL), | 406 media_request_context_(NULL), |
389 extensions_request_context_(NULL), | 407 extensions_request_context_(NULL), |
390 history_service_created_(false), | 408 history_service_created_(false), |
391 created_web_data_service_(false), | 409 created_web_data_service_(false), |
| 410 created_password_store_(false), |
392 created_download_manager_(false), | 411 created_download_manager_(false), |
393 created_theme_provider_(false), | 412 created_theme_provider_(false), |
394 start_time_(Time::Now()), | 413 start_time_(Time::Now()), |
395 spellchecker_(NULL), | 414 spellchecker_(NULL), |
396 shutdown_session_service_(false) { | 415 shutdown_session_service_(false) { |
397 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 416 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
398 "profile files to the root directory!"; | 417 "profile files to the root directory!"; |
399 create_session_service_timer_.Start( | 418 create_session_service_timer_.Start( |
400 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 419 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
401 &ProfileImpl::EnsureSessionServiceCreated); | 420 &ProfileImpl::EnsureSessionServiceCreated); |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 774 |
756 void ProfileImpl::CreateWebDataService() { | 775 void ProfileImpl::CreateWebDataService() { |
757 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL); | 776 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL); |
758 created_web_data_service_ = true; | 777 created_web_data_service_ = true; |
759 scoped_refptr<WebDataService> wds(new WebDataService()); | 778 scoped_refptr<WebDataService> wds(new WebDataService()); |
760 if (!wds->Init(GetPath())) | 779 if (!wds->Init(GetPath())) |
761 return; | 780 return; |
762 web_data_service_.swap(wds); | 781 web_data_service_.swap(wds); |
763 } | 782 } |
764 | 783 |
| 784 PasswordStore* ProfileImpl::GetPasswordStore(ServiceAccessType sat) { |
| 785 if (!created_password_store_) |
| 786 CreatePasswordStore(); |
| 787 return password_store_.get(); |
| 788 } |
| 789 |
| 790 void ProfileImpl::CreatePasswordStore() { |
| 791 DCHECK(!created_password_store_ && password_store_.get() == NULL); |
| 792 created_password_store_ = true; |
| 793 scoped_refptr<PasswordStore> ps; |
| 794 #if defined(OS_LINUX) |
| 795 // Temporarily disabled while we figure some stuff out. |
| 796 // http://code.google.com/p/chromium/issues/detail?id=12351 |
| 797 // if (getenv("KDE_FULL_SESSION")) { |
| 798 // ps = new PasswordStoreKWallet(); |
| 799 // } else { |
| 800 // ps = new PasswordStoreGnome(); |
| 801 // } |
| 802 NOTIMPLEMENTED(); |
| 803 #elif defined(OS_WIN) |
| 804 ps = new PasswordStoreWin(GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 805 #else |
| 806 NOTIMPLEMENTED(); |
| 807 #endif |
| 808 if (!ps || !ps->Init()) { |
| 809 // Try falling back to the default password manager |
| 810 LOG(WARNING) << "Could not initialise native password manager - " |
| 811 "falling back to default"; |
| 812 ps = new PasswordStoreDefault(GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 813 if (!ps->Init()) |
| 814 return; |
| 815 } |
| 816 password_store_.swap(ps); |
| 817 } |
| 818 |
765 DownloadManager* ProfileImpl::GetDownloadManager() { | 819 DownloadManager* ProfileImpl::GetDownloadManager() { |
766 if (!created_download_manager_) { | 820 if (!created_download_manager_) { |
767 scoped_refptr<DownloadManager> dlm(new DownloadManager); | 821 scoped_refptr<DownloadManager> dlm(new DownloadManager); |
768 dlm->Init(this); | 822 dlm->Init(this); |
769 created_download_manager_ = true; | 823 created_download_manager_ = true; |
770 download_manager_.swap(dlm); | 824 download_manager_.swap(dlm); |
771 } | 825 } |
772 return download_manager_.get(); | 826 return download_manager_.get(); |
773 } | 827 } |
774 | 828 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 | 1042 |
989 void ProfileImpl::StopCreateSessionServiceTimer() { | 1043 void ProfileImpl::StopCreateSessionServiceTimer() { |
990 create_session_service_timer_.Stop(); | 1044 create_session_service_timer_.Stop(); |
991 } | 1045 } |
992 | 1046 |
993 #ifdef CHROME_PERSONALIZATION | 1047 #ifdef CHROME_PERSONALIZATION |
994 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { | 1048 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { |
995 return personalization_.get(); | 1049 return personalization_.get(); |
996 } | 1050 } |
997 #endif | 1051 #endif |
OLD | NEW |