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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 | 767 |
749 void ProfileImpl::CreateWebDataService() { | 768 void ProfileImpl::CreateWebDataService() { |
750 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL); | 769 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL); |
751 created_web_data_service_ = true; | 770 created_web_data_service_ = true; |
752 scoped_refptr<WebDataService> wds(new WebDataService()); | 771 scoped_refptr<WebDataService> wds(new WebDataService()); |
753 if (!wds->Init(GetPath())) | 772 if (!wds->Init(GetPath())) |
754 return; | 773 return; |
755 web_data_service_.swap(wds); | 774 web_data_service_.swap(wds); |
756 } | 775 } |
757 | 776 |
| 777 PasswordStore* ProfileImpl::GetPasswordStore(ServiceAccessType sat) { |
| 778 if (!created_password_store_) |
| 779 CreatePasswordStore(); |
| 780 return password_store_.get(); |
| 781 } |
| 782 |
| 783 void ProfileImpl::CreatePasswordStore() { |
| 784 DCHECK(!created_password_store_ && password_store_.get() == NULL); |
| 785 created_password_store_ = true; |
| 786 scoped_refptr<PasswordStore> ps; |
| 787 #if defined(OS_LINUX) |
| 788 // Temporarily disabled while we figure some stuff out. |
| 789 // http://code.google.com/p/chromium/issues/detail?id=12351 |
| 790 // if (getenv("KDE_FULL_SESSION")) { |
| 791 // ps = new PasswordStoreKWallet(); |
| 792 // } else { |
| 793 // ps = new PasswordStoreGnome(); |
| 794 // } |
| 795 NOTIMPLEMENTED(); |
| 796 #elif defined(OS_WIN) |
| 797 ps = new PasswordStoreWin(GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 798 #else |
| 799 NOTIMPLEMENTED(); |
| 800 #endif |
| 801 if (!ps || !ps->Init()) { |
| 802 // Try falling back to the default password manager |
| 803 LOG(WARNING) << "Could not initialise native password manager - " |
| 804 "falling back to default"; |
| 805 ps = new PasswordStoreDefault(GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 806 if (!ps->Init()) |
| 807 return; |
| 808 } |
| 809 password_store_.swap(ps); |
| 810 } |
| 811 |
758 DownloadManager* ProfileImpl::GetDownloadManager() { | 812 DownloadManager* ProfileImpl::GetDownloadManager() { |
759 if (!created_download_manager_) { | 813 if (!created_download_manager_) { |
760 scoped_refptr<DownloadManager> dlm(new DownloadManager); | 814 scoped_refptr<DownloadManager> dlm(new DownloadManager); |
761 dlm->Init(this); | 815 dlm->Init(this); |
762 created_download_manager_ = true; | 816 created_download_manager_ = true; |
763 download_manager_.swap(dlm); | 817 download_manager_.swap(dlm); |
764 } | 818 } |
765 return download_manager_.get(); | 819 return download_manager_.get(); |
766 } | 820 } |
767 | 821 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 | 1035 |
982 void ProfileImpl::StopCreateSessionServiceTimer() { | 1036 void ProfileImpl::StopCreateSessionServiceTimer() { |
983 create_session_service_timer_.Stop(); | 1037 create_session_service_timer_.Stop(); |
984 } | 1038 } |
985 | 1039 |
986 #ifdef CHROME_PERSONALIZATION | 1040 #ifdef CHROME_PERSONALIZATION |
987 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { | 1041 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { |
988 return personalization_.get(); | 1042 return personalization_.get(); |
989 } | 1043 } |
990 #endif | 1044 #endif |
OLD | NEW |