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_util.h" | 8 #include "base/file_util.h" |
9 #include "base/lock.h" | 9 #include "base/lock.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 "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/bookmarks/bookmark_bar_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
15 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/download_manager.h" | 17 #include "chrome/browser/download_manager.h" |
18 #include "chrome/browser/history/history.h" | 18 #include "chrome/browser/history/history.h" |
19 #include "chrome/browser/navigation_controller.h" | 19 #include "chrome/browser/navigation_controller.h" |
20 #include "chrome/browser/profile_manager.h" | 20 #include "chrome/browser/profile_manager.h" |
21 #include "chrome/browser/render_process_host.h" | 21 #include "chrome/browser/render_process_host.h" |
22 #include "chrome/browser/spellchecker.h" | 22 #include "chrome/browser/spellchecker.h" |
23 #include "chrome/browser/tab_restore_service.h" | 23 #include "chrome/browser/tab_restore_service.h" |
24 #include "chrome/browser/template_url_fetcher.h" | 24 #include "chrome/browser/template_url_fetcher.h" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 } | 458 } |
459 | 459 |
460 virtual const Profile::ProfileControllerSet& GetNavigationControllers() { | 460 virtual const Profile::ProfileControllerSet& GetNavigationControllers() { |
461 return profile_->GetNavigationControllers(); | 461 return profile_->GetNavigationControllers(); |
462 } | 462 } |
463 | 463 |
464 virtual bool DidLastSessionExitCleanly() { | 464 virtual bool DidLastSessionExitCleanly() { |
465 return profile_->DidLastSessionExitCleanly(); | 465 return profile_->DidLastSessionExitCleanly(); |
466 } | 466 } |
467 | 467 |
468 virtual bool HasBookmarkBarModel() { | 468 virtual BookmarkModel* GetBookmarkModel() { |
469 return profile_->HasBookmarkBarModel(); | 469 return profile_->GetBookmarkModel(); |
470 } | |
471 | |
472 virtual BookmarkBarModel* GetBookmarkBarModel() { | |
473 return profile_->GetBookmarkBarModel(); | |
474 } | 470 } |
475 | 471 |
476 #ifdef CHROME_PERSONALIZATION | 472 #ifdef CHROME_PERSONALIZATION |
477 virtual ProfilePersonalization GetProfilePersonalization() { | 473 virtual ProfilePersonalization GetProfilePersonalization() { |
478 return profile_->GetProfilePersonalization(); | 474 return profile_->GetProfilePersonalization(); |
479 } | 475 } |
480 #endif | 476 #endif |
481 | 477 |
482 virtual bool IsSameProfile(Profile* profile) { | 478 virtual bool IsSameProfile(Profile* profile) { |
483 if (profile == static_cast<Profile*>(this)) | 479 if (profile == static_cast<Profile*>(this)) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 } | 599 } |
604 | 600 |
605 if (request_context_) { | 601 if (request_context_) { |
606 request_context_->CleanupBeforeDestroy(); | 602 request_context_->CleanupBeforeDestroy(); |
607 // Clean up request context on IO thread. | 603 // Clean up request context on IO thread. |
608 io_thread->message_loop()->PostTask(FROM_HERE, | 604 io_thread->message_loop()->PostTask(FROM_HERE, |
609 NewRunnableFunction(&ReleaseURLRequestContext, request_context_)); | 605 NewRunnableFunction(&ReleaseURLRequestContext, request_context_)); |
610 request_context_ = NULL; | 606 request_context_ = NULL; |
611 } | 607 } |
612 | 608 |
613 // HistoryService may call into the BookmarkBarModel, as such we need to | 609 // HistoryService may call into the BookmarkModel, as such we need to |
614 // delete HistoryService before the BookmarkBarModel. The destructor for | 610 // delete HistoryService before the BookmarkModel. The destructor for |
615 // HistoryService will join with HistoryService's backend thread so that | 611 // HistoryService will join with HistoryService's backend thread so that |
616 // by the time the destructor has finished we're sure it will no longer call | 612 // by the time the destructor has finished we're sure it will no longer call |
617 // into the BookmarkBarModel. | 613 // into the BookmarkModel. |
618 history_service_ = NULL; | 614 history_service_ = NULL; |
619 bookmark_bar_model_.reset(); | 615 bookmark_bar_model_.reset(); |
620 | 616 |
621 MarkAsCleanShutdown(); | 617 MarkAsCleanShutdown(); |
622 } | 618 } |
623 | 619 |
624 std::wstring ProfileImpl::GetPath() { | 620 std::wstring ProfileImpl::GetPath() { |
625 return path_; | 621 return path_; |
626 } | 622 } |
627 | 623 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 DCHECK(request_context_->cookie_store()); | 713 DCHECK(request_context_->cookie_store()); |
718 } | 714 } |
719 | 715 |
720 return request_context_; | 716 return request_context_; |
721 } | 717 } |
722 | 718 |
723 HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) { | 719 HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) { |
724 if (!history_service_created_) { | 720 if (!history_service_created_) { |
725 history_service_created_ = true; | 721 history_service_created_ = true; |
726 scoped_refptr<HistoryService> history(new HistoryService(this)); | 722 scoped_refptr<HistoryService> history(new HistoryService(this)); |
727 if (!history->Init(GetPath(), GetBookmarkBarModel())) | 723 if (!history->Init(GetPath(), GetBookmarkModel())) |
728 return NULL; | 724 return NULL; |
729 history_service_.swap(history); | 725 history_service_.swap(history); |
730 | 726 |
731 // Send out the notification that the history service was created. | 727 // Send out the notification that the history service was created. |
732 NotificationService::current()-> | 728 NotificationService::current()-> |
733 Notify(NOTIFY_HISTORY_CREATED, Source<Profile>(this), | 729 Notify(NOTIFY_HISTORY_CREATED, Source<Profile>(this), |
734 Details<HistoryService>(history_service_.get())); | 730 Details<HistoryService>(history_service_.get())); |
735 } | 731 } |
736 return history_service_.get(); | 732 return history_service_.get(); |
737 } | 733 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 return controllers_; | 825 return controllers_; |
830 } | 826 } |
831 | 827 |
832 bool ProfileImpl::DidLastSessionExitCleanly() { | 828 bool ProfileImpl::DidLastSessionExitCleanly() { |
833 // last_session_exited_cleanly_ is set when the preferences are loaded. Force | 829 // last_session_exited_cleanly_ is set when the preferences are loaded. Force |
834 // it to be set by asking for the prefs. | 830 // it to be set by asking for the prefs. |
835 GetPrefs(); | 831 GetPrefs(); |
836 return last_session_exited_cleanly_; | 832 return last_session_exited_cleanly_; |
837 } | 833 } |
838 | 834 |
839 bool ProfileImpl::HasBookmarkBarModel() { | 835 BookmarkModel* ProfileImpl::GetBookmarkModel() { |
840 return bookmark_bar_model_.get() != NULL; | |
841 } | |
842 | |
843 BookmarkBarModel* ProfileImpl::GetBookmarkBarModel() { | |
844 if (!bookmark_bar_model_.get()) { | 836 if (!bookmark_bar_model_.get()) { |
845 bookmark_bar_model_.reset(new BookmarkBarModel(this)); | 837 bookmark_bar_model_.reset(new BookmarkModel(this)); |
846 bookmark_bar_model_->Load(); | 838 bookmark_bar_model_->Load(); |
847 } | 839 } |
848 return bookmark_bar_model_.get(); | 840 return bookmark_bar_model_.get(); |
849 } | 841 } |
850 | 842 |
851 bool ProfileImpl::IsSameProfile(Profile* profile) { | 843 bool ProfileImpl::IsSameProfile(Profile* profile) { |
852 if (profile == static_cast<Profile*>(this)) | 844 if (profile == static_cast<Profile*>(this)) |
853 return true; | 845 return true; |
854 OffTheRecordProfileImpl* otr_profile = off_the_record_profile_.get(); | 846 OffTheRecordProfileImpl* otr_profile = off_the_record_profile_.get(); |
855 return otr_profile && profile == static_cast<Profile*>(otr_profile); | 847 return otr_profile && profile == static_cast<Profile*>(otr_profile); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 create_session_service_timer_.Stop(); | 897 create_session_service_timer_.Stop(); |
906 } | 898 } |
907 | 899 |
908 #ifdef CHROME_PERSONALIZATION | 900 #ifdef CHROME_PERSONALIZATION |
909 ProfilePersonalization ProfileImpl::GetProfilePersonalization() { | 901 ProfilePersonalization ProfileImpl::GetProfilePersonalization() { |
910 if (!personalization_) | 902 if (!personalization_) |
911 personalization_ = Personalization::CreateProfilePersonalization(this); | 903 personalization_ = Personalization::CreateProfilePersonalization(this); |
912 return personalization_; | 904 return personalization_; |
913 } | 905 } |
914 #endif | 906 #endif |
OLD | NEW |