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/profile.h" | 5 #include "chrome/browser/profile.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "app/theme_provider.h" | 8 #include "app/theme_provider.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/env_var.h" | 10 #include "base/env_var.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 GtkThemeProvider::DefaultUsesSystemTheme()); | 207 GtkThemeProvider::DefaultUsesSystemTheme()); |
208 #endif | 208 #endif |
209 prefs->RegisterFilePathPref(prefs::kCurrentThemePackFilename, FilePath()); | 209 prefs->RegisterFilePathPref(prefs::kCurrentThemePackFilename, FilePath()); |
210 prefs->RegisterStringPref(prefs::kCurrentThemeID, | 210 prefs->RegisterStringPref(prefs::kCurrentThemeID, |
211 UTF8ToWide(BrowserThemeProvider::kDefaultThemeID)); | 211 UTF8ToWide(BrowserThemeProvider::kDefaultThemeID)); |
212 prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages); | 212 prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages); |
213 prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors); | 213 prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors); |
214 prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints); | 214 prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints); |
215 prefs->RegisterDictionaryPref(prefs::kCurrentThemeDisplayProperties); | 215 prefs->RegisterDictionaryPref(prefs::kCurrentThemeDisplayProperties); |
216 prefs->RegisterBooleanPref(prefs::kDisableExtensions, false); | 216 prefs->RegisterBooleanPref(prefs::kDisableExtensions, false); |
| 217 prefs->RegisterStringPref(prefs::kSelectFileLastDirectory, L""); |
217 } | 218 } |
218 | 219 |
219 // static | 220 // static |
220 Profile* Profile::CreateProfile(const FilePath& path) { | 221 Profile* Profile::CreateProfile(const FilePath& path) { |
221 return new ProfileImpl(path); | 222 return new ProfileImpl(path); |
222 } | 223 } |
223 | 224 |
224 // static | 225 // static |
225 URLRequestContextGetter* Profile::GetDefaultRequestContext() { | 226 URLRequestContextGetter* Profile::GetDefaultRequestContext() { |
226 return default_request_context_; | 227 return default_request_context_; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 | 576 |
576 virtual void InitWebResources() { | 577 virtual void InitWebResources() { |
577 NOTREACHED(); | 578 NOTREACHED(); |
578 } | 579 } |
579 | 580 |
580 virtual NTPResourceCache* GetNTPResourceCache() { | 581 virtual NTPResourceCache* GetNTPResourceCache() { |
581 // Just return the real profile resource cache. | 582 // Just return the real profile resource cache. |
582 return profile_->GetNTPResourceCache(); | 583 return profile_->GetNTPResourceCache(); |
583 } | 584 } |
584 | 585 |
| 586 virtual FilePath last_selected_directory() { |
| 587 const FilePath& directory = last_selected_directory_; |
| 588 if (directory.empty()) { |
| 589 return profile_->last_selected_directory(); |
| 590 } |
| 591 return directory; |
| 592 } |
| 593 |
| 594 virtual void set_last_selected_directory(const FilePath& path) { |
| 595 last_selected_directory_ = path; |
| 596 } |
| 597 |
585 virtual void ExitedOffTheRecordMode() { | 598 virtual void ExitedOffTheRecordMode() { |
586 // Drop our download manager so we forget about all the downloads made | 599 // Drop our download manager so we forget about all the downloads made |
587 // in off-the-record mode. | 600 // in off-the-record mode. |
588 download_manager_ = NULL; | 601 download_manager_ = NULL; |
589 } | 602 } |
590 | 603 |
591 virtual void Observe(NotificationType type, | 604 virtual void Observe(NotificationType type, |
592 const NotificationSource& source, | 605 const NotificationSource& source, |
593 const NotificationDetails& details) { | 606 const NotificationDetails& details) { |
594 DCHECK_EQ(NotificationType::BROWSER_CLOSED, type.value); | 607 DCHECK_EQ(NotificationType::BROWSER_CLOSED, type.value); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 scoped_refptr<net::TransportSecurityState> | 653 scoped_refptr<net::TransportSecurityState> |
641 transport_security_state_; | 654 transport_security_state_; |
642 | 655 |
643 // Time we were started. | 656 // Time we were started. |
644 Time start_time_; | 657 Time start_time_; |
645 | 658 |
646 // The main database tracker for this profile. | 659 // The main database tracker for this profile. |
647 // Should be used only on the file thread. | 660 // Should be used only on the file thread. |
648 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; | 661 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; |
649 | 662 |
| 663 FilePath last_selected_directory_; |
| 664 |
650 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); | 665 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); |
651 }; | 666 }; |
652 | 667 |
653 ProfileImpl::ProfileImpl(const FilePath& path) | 668 ProfileImpl::ProfileImpl(const FilePath& path) |
654 : path_(path), | 669 : path_(path), |
655 visited_link_event_listener_(new VisitedLinkEventListener()), | 670 visited_link_event_listener_(new VisitedLinkEventListener()), |
656 extension_devtools_manager_(NULL), | 671 extension_devtools_manager_(NULL), |
657 request_context_(NULL), | 672 request_context_(NULL), |
658 media_request_context_(NULL), | 673 media_request_context_(NULL), |
659 extensions_request_context_(NULL), | 674 extensions_request_context_(NULL), |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 web_resource_service_ = new WebResourceService(this); | 831 web_resource_service_ = new WebResourceService(this); |
817 web_resource_service_->StartAfterDelay(); | 832 web_resource_service_->StartAfterDelay(); |
818 } | 833 } |
819 | 834 |
820 NTPResourceCache* ProfileImpl::GetNTPResourceCache() { | 835 NTPResourceCache* ProfileImpl::GetNTPResourceCache() { |
821 if (!ntp_resource_cache_.get()) | 836 if (!ntp_resource_cache_.get()) |
822 ntp_resource_cache_.reset(new NTPResourceCache(this)); | 837 ntp_resource_cache_.reset(new NTPResourceCache(this)); |
823 return ntp_resource_cache_.get(); | 838 return ntp_resource_cache_.get(); |
824 } | 839 } |
825 | 840 |
| 841 FilePath ProfileImpl::last_selected_directory() { |
| 842 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
| 843 } |
| 844 |
| 845 void ProfileImpl::set_last_selected_directory(const FilePath& path) { |
| 846 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
| 847 } |
| 848 |
826 ProfileImpl::~ProfileImpl() { | 849 ProfileImpl::~ProfileImpl() { |
827 NotificationService::current()->Notify( | 850 NotificationService::current()->Notify( |
828 NotificationType::PROFILE_DESTROYED, | 851 NotificationType::PROFILE_DESTROYED, |
829 Source<Profile>(this), | 852 Source<Profile>(this), |
830 NotificationService::NoDetails()); | 853 NotificationService::NoDetails()); |
831 | 854 |
832 tab_restore_service_ = NULL; | 855 tab_restore_service_ = NULL; |
833 | 856 |
834 StopCreateSessionServiceTimer(); | 857 StopCreateSessionServiceTimer(); |
835 // TemplateURLModel schedules a task on the WebDataService from its | 858 // TemplateURLModel schedules a task on the WebDataService from its |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 CommandLine::ForCurrentProcess())); | 1556 CommandLine::ForCurrentProcess())); |
1534 sync_service_.reset( | 1557 sync_service_.reset( |
1535 profile_sync_factory_->CreateProfileSyncService()); | 1558 profile_sync_factory_->CreateProfileSyncService()); |
1536 sync_service_->Initialize(); | 1559 sync_service_->Initialize(); |
1537 } | 1560 } |
1538 | 1561 |
1539 void ProfileImpl::InitCloudPrintProxyService() { | 1562 void ProfileImpl::InitCloudPrintProxyService() { |
1540 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this)); | 1563 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this)); |
1541 cloud_print_proxy_service_->Initialize(); | 1564 cloud_print_proxy_service_->Initialize(); |
1542 } | 1565 } |
OLD | NEW |