Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: chrome/browser/profile.cc

Issue 371063: Integrate BlacklistManager with Profile. (Closed)
Patch Set: trybot fixes Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/profile.h ('k') | chrome/browser/renderer_host/resource_dispatcher_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "app/theme_provider.h" 7 #include "app/theme_provider.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/extensions/extensions_service.h" 25 #include "chrome/browser/extensions/extensions_service.h"
26 #include "chrome/browser/extensions/user_script_master.h" 26 #include "chrome/browser/extensions/user_script_master.h"
27 #include "chrome/browser/favicon_service.h" 27 #include "chrome/browser/favicon_service.h"
28 #include "chrome/browser/strict_transport_security_persister.h" 28 #include "chrome/browser/strict_transport_security_persister.h"
29 #include "chrome/browser/history/history.h" 29 #include "chrome/browser/history/history.h"
30 #include "chrome/browser/in_process_webkit/webkit_context.h" 30 #include "chrome/browser/in_process_webkit/webkit_context.h"
31 #include "chrome/browser/net/chrome_url_request_context.h" 31 #include "chrome/browser/net/chrome_url_request_context.h"
32 #include "chrome/browser/net/ssl_config_service_manager.h" 32 #include "chrome/browser/net/ssl_config_service_manager.h"
33 #include "chrome/browser/notifications/desktop_notification_service.h" 33 #include "chrome/browser/notifications/desktop_notification_service.h"
34 #include "chrome/browser/password_manager/password_store_default.h" 34 #include "chrome/browser/password_manager/password_store_default.h"
35 #include "chrome/browser/privacy_blacklist/blacklist_io.h" 35 #include "chrome/browser/privacy_blacklist/blacklist_manager.h"
36 #include "chrome/browser/profile_manager.h" 36 #include "chrome/browser/profile_manager.h"
37 #include "chrome/browser/renderer_host/render_process_host.h" 37 #include "chrome/browser/renderer_host/render_process_host.h"
38 #include "chrome/browser/search_versus_navigate_classifier.h" 38 #include "chrome/browser/search_versus_navigate_classifier.h"
39 #include "chrome/browser/search_engines/template_url_fetcher.h" 39 #include "chrome/browser/search_engines/template_url_fetcher.h"
40 #include "chrome/browser/search_engines/template_url_model.h" 40 #include "chrome/browser/search_engines/template_url_model.h"
41 #include "chrome/browser/sessions/session_service.h" 41 #include "chrome/browser/sessions/session_service.h"
42 #include "chrome/browser/sessions/tab_restore_service.h" 42 #include "chrome/browser/sessions/tab_restore_service.h"
43 #include "chrome/browser/ssl/ssl_host_state.h" 43 #include "chrome/browser/ssl/ssl_host_state.h"
44 #include "chrome/browser/sync/profile_sync_service.h" 44 #include "chrome/browser/sync/profile_sync_service.h"
45 #include "chrome/browser/thumbnail_store.h" 45 #include "chrome/browser/thumbnail_store.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this); 397 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this);
398 } 398 }
399 399
400 return extensions_request_context_; 400 return extensions_request_context_;
401 } 401 }
402 402
403 virtual net::SSLConfigService* GetSSLConfigService() { 403 virtual net::SSLConfigService* GetSSLConfigService() {
404 return GetOriginalProfile()->GetSSLConfigService(); 404 return GetOriginalProfile()->GetSSLConfigService();
405 } 405 }
406 406
407 virtual Blacklist* GetBlacklist() { 407 virtual BlacklistManager* GetBlacklistManager() {
408 return GetOriginalProfile()->GetBlacklist(); 408 return GetOriginalProfile()->GetBlacklistManager();
409 } 409 }
410 410
411 virtual SessionService* GetSessionService() { 411 virtual SessionService* GetSessionService() {
412 // Don't save any sessions when off the record. 412 // Don't save any sessions when off the record.
413 return NULL; 413 return NULL;
414 } 414 }
415 415
416 virtual void ShutdownSessionService() { 416 virtual void ShutdownSessionService() {
417 // We don't allow a session service, nothing to do. 417 // We don't allow a session service, nothing to do.
418 } 418 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); 563 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
564 }; 564 };
565 565
566 ProfileImpl::ProfileImpl(const FilePath& path) 566 ProfileImpl::ProfileImpl(const FilePath& path)
567 : path_(path), 567 : path_(path),
568 visited_link_event_listener_(new VisitedLinkEventListener()), 568 visited_link_event_listener_(new VisitedLinkEventListener()),
569 extension_devtools_manager_(NULL), 569 extension_devtools_manager_(NULL),
570 request_context_(NULL), 570 request_context_(NULL),
571 media_request_context_(NULL), 571 media_request_context_(NULL),
572 extensions_request_context_(NULL), 572 extensions_request_context_(NULL),
573 blacklist_(NULL), 573 blacklist_manager_(NULL),
574 blacklist_manager_created_(false),
574 history_service_created_(false), 575 history_service_created_(false),
575 favicon_service_created_(false), 576 favicon_service_created_(false),
576 created_web_data_service_(false), 577 created_web_data_service_(false),
577 created_password_store_(false), 578 created_password_store_(false),
578 created_download_manager_(false), 579 created_download_manager_(false),
579 created_theme_provider_(false), 580 created_theme_provider_(false),
580 start_time_(Time::Now()), 581 start_time_(Time::Now()),
581 spellcheck_host_(NULL), 582 spellcheck_host_(NULL),
582 spellcheck_host_ready_(false), 583 spellcheck_host_ready_(false),
583 shutdown_session_service_(false) { 584 shutdown_session_service_(false) {
584 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << 585 DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
585 "profile files to the root directory!"; 586 "profile files to the root directory!";
586 create_session_service_timer_.Start( 587 create_session_service_timer_.Start(
587 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, 588 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
588 &ProfileImpl::EnsureSessionServiceCreated); 589 &ProfileImpl::EnsureSessionServiceCreated);
589 590
590 if (CommandLine::ForCurrentProcess()->HasSwitch( 591 if (CommandLine::ForCurrentProcess()->HasSwitch(
591 switches::kEnableExtensionTimelineApi)) { 592 switches::kEnableExtensionTimelineApi)) {
592 extension_devtools_manager_ = new ExtensionDevToolsManager(this); 593 extension_devtools_manager_ = new ExtensionDevToolsManager(this);
593 } 594 }
594 595
595 extension_process_manager_.reset(new ExtensionProcessManager(this)); 596 extension_process_manager_.reset(new ExtensionProcessManager(this));
596 extension_message_service_ = new ExtensionMessageService(this); 597 extension_message_service_ = new ExtensionMessageService(this);
597 598
598 PrefService* prefs = GetPrefs(); 599 PrefService* prefs = GetPrefs();
599 prefs->AddPrefObserver(prefs::kSpellCheckDictionary, this); 600 prefs->AddPrefObserver(prefs::kSpellCheckDictionary, this);
600 prefs->AddPrefObserver(prefs::kEnableSpellCheck, this); 601 prefs->AddPrefObserver(prefs::kEnableSpellCheck, this);
601 prefs->AddPrefObserver(prefs::kEnableAutoSpellCorrect, this); 602 prefs->AddPrefObserver(prefs::kEnableAutoSpellCorrect, this);
602 603
603 if (CommandLine::ForCurrentProcess()->
604 HasSwitch(switches::kPrivacyBlacklist)) {
605 std::wstring option = CommandLine::ForCurrentProcess()->GetSwitchValue(
606 switches::kPrivacyBlacklist);
607 #if defined(OS_POSIX)
608 FilePath path(WideToUTF8(option));
609 #else
610 FilePath path(option);
611 #endif
612 blacklist_.reset(new Blacklist);
613 // TODO(phajdan.jr): Handle errors when reading blacklist.
614 BlacklistIO::ReadBinary(blacklist_.get(), path);
615 }
616
617 #if defined(OS_MACOSX) 604 #if defined(OS_MACOSX)
618 // If the profile directory doesn't already have a cache directory and it 605 // If the profile directory doesn't already have a cache directory and it
619 // is under ~/Library/Application Support, use a suitable cache directory 606 // is under ~/Library/Application Support, use a suitable cache directory
620 // under ~/Library/Caches. For example, a profile directory of 607 // under ~/Library/Caches. For example, a profile directory of
621 // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't 608 // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't
622 // have a "Cache" or "MediaCache" subdirectory would use the cache directory 609 // have a "Cache" or "MediaCache" subdirectory would use the cache directory
623 // ~/Library/Caches/Google/Chrome/MyProfileName. 610 // ~/Library/Caches/Google/Chrome/MyProfileName.
624 // 611 //
625 // TODO(akalin): Come up with unit tests for this. 612 // TODO(akalin): Come up with unit tests for this.
626 // TODO(akalin): Use for Linux, too? 613 // TODO(akalin): Use for Linux, too?
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 if (spellcheck_host_.get()) 738 if (spellcheck_host_.get())
752 spellcheck_host_->UnsetObserver(); 739 spellcheck_host_->UnsetObserver();
753 740
754 if (default_request_context_ == request_context_) 741 if (default_request_context_ == request_context_)
755 default_request_context_ = NULL; 742 default_request_context_ = NULL;
756 743
757 CleanupRequestContext(request_context_); 744 CleanupRequestContext(request_context_);
758 CleanupRequestContext(media_request_context_); 745 CleanupRequestContext(media_request_context_);
759 CleanupRequestContext(extensions_request_context_); 746 CleanupRequestContext(extensions_request_context_);
760 747
761 // When the request contexts are gone, the blacklist wont be needed anymore.
762 blacklist_.reset();
763
764 // HistoryService may call into the BookmarkModel, as such we need to 748 // HistoryService may call into the BookmarkModel, as such we need to
765 // delete HistoryService before the BookmarkModel. The destructor for 749 // delete HistoryService before the BookmarkModel. The destructor for
766 // HistoryService will join with HistoryService's backend thread so that 750 // HistoryService will join with HistoryService's backend thread so that
767 // by the time the destructor has finished we're sure it will no longer call 751 // by the time the destructor has finished we're sure it will no longer call
768 // into the BookmarkModel. 752 // into the BookmarkModel.
769 history_service_ = NULL; 753 history_service_ = NULL;
770 bookmark_bar_model_.reset(); 754 bookmark_bar_model_.reset();
771 755
772 // FaviconService depends on HistoryServce so make sure we delete 756 // FaviconService depends on HistoryServce so make sure we delete
773 // HistoryService first. 757 // HistoryService first.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 this, cookie_path); 949 this, cookie_path);
966 } 950 }
967 951
968 return extensions_request_context_; 952 return extensions_request_context_;
969 } 953 }
970 954
971 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { 955 net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
972 return ssl_config_service_manager_->Get(); 956 return ssl_config_service_manager_->Get();
973 } 957 }
974 958
975 Blacklist* ProfileImpl::GetBlacklist() { 959 BlacklistManager* ProfileImpl::GetBlacklistManager() {
976 return blacklist_.get(); 960 if (!CommandLine::ForCurrentProcess()->HasSwitch(
961 switches::kEnablePrivacyBlacklists)) {
962 return NULL;
963 }
964 if (!blacklist_manager_created_) {
965 blacklist_manager_created_ = true;
966 blacklist_manager_ = new BlacklistManager(this, GetExtensionsService());
967 blacklist_manager_->Initialize();
968 }
969 return blacklist_manager_.get();
977 } 970 }
978 971
979 HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) { 972 HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) {
980 if (!history_service_created_) { 973 if (!history_service_created_) {
981 history_service_created_ = true; 974 history_service_created_ = true;
982 scoped_refptr<HistoryService> history(new HistoryService(this)); 975 scoped_refptr<HistoryService> history(new HistoryService(this));
983 if (!history->Init(GetPath(), GetBookmarkModel())) 976 if (!history->Init(GetPath(), GetBookmarkModel()))
984 return NULL; 977 return NULL;
985 history_service_.swap(history); 978 history_service_.swap(history);
986 979
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 } 1321 }
1329 if (!sync_service_.get()) 1322 if (!sync_service_.get())
1330 InitSyncService(); 1323 InitSyncService();
1331 return sync_service_.get(); 1324 return sync_service_.get();
1332 } 1325 }
1333 1326
1334 void ProfileImpl::InitSyncService() { 1327 void ProfileImpl::InitSyncService() {
1335 sync_service_.reset(new ProfileSyncService(this)); 1328 sync_service_.reset(new ProfileSyncService(this));
1336 sync_service_->Initialize(); 1329 sync_service_->Initialize();
1337 } 1330 }
OLDNEW
« no previous file with comments | « chrome/browser/profile.h ('k') | chrome/browser/renderer_host/resource_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698