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/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "app/clipboard/clipboard.h" | 9 #include "app/clipboard/clipboard.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 #include "chrome/browser/google/google_url_tracker.h" | 30 #include "chrome/browser/google/google_url_tracker.h" |
31 #include "chrome/browser/icon_manager.h" | 31 #include "chrome/browser/icon_manager.h" |
32 #include "chrome/browser/in_process_webkit/dom_storage_context.h" | 32 #include "chrome/browser/in_process_webkit/dom_storage_context.h" |
33 #include "chrome/browser/intranet_redirect_detector.h" | 33 #include "chrome/browser/intranet_redirect_detector.h" |
34 #include "chrome/browser/io_thread.h" | 34 #include "chrome/browser/io_thread.h" |
35 #include "chrome/browser/metrics/metrics_service.h" | 35 #include "chrome/browser/metrics/metrics_service.h" |
36 #include "chrome/browser/net/predictor_api.h" | 36 #include "chrome/browser/net/predictor_api.h" |
37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
38 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 38 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
39 #include "chrome/browser/notifications/notification_ui_manager.h" | 39 #include "chrome/browser/notifications/notification_ui_manager.h" |
40 #include "chrome/browser/plugin_data_remover.h" | |
40 #include "chrome/browser/plugin_service.h" | 41 #include "chrome/browser/plugin_service.h" |
41 #include "chrome/browser/plugin_updater.h" | 42 #include "chrome/browser/plugin_updater.h" |
42 #include "chrome/browser/prefs/pref_service.h" | 43 #include "chrome/browser/prefs/pref_service.h" |
43 #include "chrome/browser/printing/print_job_manager.h" | 44 #include "chrome/browser/printing/print_job_manager.h" |
44 #include "chrome/browser/printing/print_preview_tab_controller.h" | 45 #include "chrome/browser/printing/print_preview_tab_controller.h" |
45 #include "chrome/browser/profile_manager.h" | 46 #include "chrome/browser/profile_manager.h" |
46 #include "chrome/browser/renderer_host/render_process_host.h" | 47 #include "chrome/browser/renderer_host/render_process_host.h" |
47 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
48 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 49 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
49 #include "chrome/browser/sidebar/sidebar_manager.h" | 50 #include "chrome/browser/sidebar/sidebar_manager.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 main_notification_service_.reset(new NotificationService); | 110 main_notification_service_.reset(new NotificationService); |
110 | 111 |
111 // Must be created after the NotificationService. | 112 // Must be created after the NotificationService. |
112 print_job_manager_.reset(new printing::PrintJobManager); | 113 print_job_manager_.reset(new printing::PrintJobManager); |
113 | 114 |
114 shutdown_event_.reset(new base::WaitableEvent(true, false)); | 115 shutdown_event_.reset(new base::WaitableEvent(true, false)); |
115 } | 116 } |
116 | 117 |
117 BrowserProcessImpl::~BrowserProcessImpl() { | 118 BrowserProcessImpl::~BrowserProcessImpl() { |
118 FilePath profile_path; | 119 FilePath profile_path; |
119 bool clear_local_state_on_exit; | 120 bool clear_local_state_on_exit = false; |
120 | 121 Profile* profile = GetProfile(); |
121 // Store the profile path for clearing local state data on exit. | 122 if (profile) { |
122 clear_local_state_on_exit = ShouldClearLocalState(&profile_path); | 123 // Store the profile path for clearing local state data on exit. |
124 profile_path = profile->GetPath(); | |
125 PrefService* prefs = profile->GetPrefs(); | |
126 clear_local_state_on_exit = prefs->GetBoolean(prefs::kClearSiteDataOnExit); | |
127 if (prefs->GetBoolean(prefs::kClearPluginLSODataOnExit) && | |
128 local_state()->GetBoolean(prefs::kClearPluginLSODataEnabled)) { | |
129 PluginDataRemover remover; | |
130 remover.StartRemoving(base::Time(), new MessageLoop::QuitTask()); | |
131 MessageLoop::current()->Run(); | |
jochen (gone - plz use gerrit)
2010/11/24 19:03:07
i think this is the wrong place to do this. Can't
Bernhard Bauer
2010/11/29 10:45:23
PluginDataRemover needs the PluginService in order
| |
132 } | |
133 } | |
123 | 134 |
124 // Delete the AutomationProviderList before NotificationService, | 135 // Delete the AutomationProviderList before NotificationService, |
125 // since it may try to unregister notifications | 136 // since it may try to unregister notifications |
126 // Both NotificationService and AutomationProvider are singleton instances in | 137 // Both NotificationService and AutomationProvider are singleton instances in |
127 // the BrowserProcess. Since AutomationProvider may have some active | 138 // the BrowserProcess. Since AutomationProvider may have some active |
128 // notification observers, it is essential that it gets destroyed before the | 139 // notification observers, it is essential that it gets destroyed before the |
129 // NotificationService. NotificationService won't be destroyed until after | 140 // NotificationService. NotificationService won't be destroyed until after |
130 // this destructor is run. | 141 // this destructor is run. |
131 automation_provider_list_.reset(); | 142 automation_provider_list_.reset(); |
132 | 143 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 } | 513 } |
503 | 514 |
504 void BrowserProcessImpl::ClearLocalState(const FilePath& profile_path) { | 515 void BrowserProcessImpl::ClearLocalState(const FilePath& profile_path) { |
505 SQLitePersistentCookieStore::ClearLocalState(profile_path.Append( | 516 SQLitePersistentCookieStore::ClearLocalState(profile_path.Append( |
506 chrome::kCookieFilename)); | 517 chrome::kCookieFilename)); |
507 DOMStorageContext::ClearLocalState(profile_path, chrome::kExtensionScheme); | 518 DOMStorageContext::ClearLocalState(profile_path, chrome::kExtensionScheme); |
508 webkit_database::DatabaseTracker::ClearLocalState(profile_path); | 519 webkit_database::DatabaseTracker::ClearLocalState(profile_path); |
509 ChromeAppCacheService::ClearLocalState(profile_path); | 520 ChromeAppCacheService::ClearLocalState(profile_path); |
510 } | 521 } |
511 | 522 |
512 bool BrowserProcessImpl::ShouldClearLocalState(FilePath* profile_path) { | 523 Profile* BrowserProcessImpl::GetProfile() { |
513 FilePath user_data_dir; | |
514 Profile* profile; | |
515 | |
516 // Check for the existence of a profile manager. When quitting early, | 524 // Check for the existence of a profile manager. When quitting early, |
517 // e.g. because another chrome instance is running, or when invoked with | 525 // e.g. because another chrome instance is running, or when invoked with |
518 // options such as --uninstall or --try-chrome-again=0, the profile manager | 526 // options such as --uninstall or --try-chrome-again=0, the profile manager |
519 // does not exist yet. | 527 // does not exist yet. |
520 if (!profile_manager_.get()) | 528 if (!profile_manager_.get()) |
521 return false; | 529 return NULL; |
522 | 530 |
531 FilePath user_data_dir; | |
523 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 532 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
524 profile = profile_manager_->GetDefaultProfile(user_data_dir); | 533 return profile_manager_->GetDefaultProfile(user_data_dir); |
525 if (!profile) | |
526 return false; | |
527 *profile_path = profile->GetPath(); | |
528 return profile->GetPrefs()->GetBoolean(prefs::kClearSiteDataOnExit); | |
529 } | 534 } |
530 | 535 |
531 void BrowserProcessImpl::CreateResourceDispatcherHost() { | 536 void BrowserProcessImpl::CreateResourceDispatcherHost() { |
532 DCHECK(!created_resource_dispatcher_host_ && | 537 DCHECK(!created_resource_dispatcher_host_ && |
533 resource_dispatcher_host_.get() == NULL); | 538 resource_dispatcher_host_.get() == NULL); |
534 created_resource_dispatcher_host_ = true; | 539 created_resource_dispatcher_host_ = true; |
535 | 540 |
536 resource_dispatcher_host_.reset(new ResourceDispatcherHost()); | 541 resource_dispatcher_host_.reset(new ResourceDispatcherHost()); |
537 resource_dispatcher_host_->Initialize(); | 542 resource_dispatcher_host_->Initialize(); |
538 } | 543 } |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
818 } | 823 } |
819 | 824 |
820 void BrowserProcessImpl::OnAutoupdateTimer() { | 825 void BrowserProcessImpl::OnAutoupdateTimer() { |
821 if (CanAutorestartForUpdate()) { | 826 if (CanAutorestartForUpdate()) { |
822 DLOG(WARNING) << "Detected update. Restarting browser."; | 827 DLOG(WARNING) << "Detected update. Restarting browser."; |
823 RestartPersistentInstance(); | 828 RestartPersistentInstance(); |
824 } | 829 } |
825 } | 830 } |
826 | 831 |
827 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 832 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |