| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/task.h" | 13 #include "base/task.h" |
| 13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 14 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 15 #include "base/synchronization/waitable_event.h" | |
| 16 #include "chrome/browser/automation/automation_provider_list.h" | 16 #include "chrome/browser/automation/automation_provider_list.h" |
| 17 #include "chrome/browser/browser_child_process_host.h" | 17 #include "chrome/browser/browser_child_process_host.h" |
| 18 #include "chrome/browser/browser_list.h" | 18 #include "chrome/browser/browser_list.h" |
| 19 #include "chrome/browser/browser_main.h" | 19 #include "chrome/browser/browser_main.h" |
| 20 #include "chrome/browser/browser_process_sub_thread.h" | 20 #include "chrome/browser/browser_process_sub_thread.h" |
| 21 #include "chrome/browser/browser_thread.h" | 21 #include "chrome/browser/browser_thread.h" |
| 22 #include "chrome/browser/browser_trial.h" | 22 #include "chrome/browser/browser_trial.h" |
| 23 #include "chrome/browser/debugger/browser_list_tabcontents_provider.h" | 23 #include "chrome/browser/debugger/browser_list_tabcontents_provider.h" |
| 24 #include "chrome/browser/debugger/devtools_http_protocol_handler.h" | 24 #include "chrome/browser/debugger/devtools_http_protocol_handler.h" |
| 25 #include "chrome/browser/debugger/devtools_manager.h" | 25 #include "chrome/browser/debugger/devtools_manager.h" |
| 26 #include "chrome/browser/debugger/devtools_protocol_handler.h" | 26 #include "chrome/browser/debugger/devtools_protocol_handler.h" |
| 27 #include "chrome/browser/download/download_file_manager.h" | 27 #include "chrome/browser/download/download_file_manager.h" |
| 28 #include "chrome/browser/download/save_file_manager.h" | 28 #include "chrome/browser/download/save_file_manager.h" |
| 29 #include "chrome/browser/first_run/first_run.h" | 29 #include "chrome/browser/first_run/first_run.h" |
| 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/intranet_redirect_detector.h" | 32 #include "chrome/browser/intranet_redirect_detector.h" |
| 33 #include "chrome/browser/io_thread.h" | 33 #include "chrome/browser/io_thread.h" |
| 34 #include "chrome/browser/metrics/metrics_service.h" | 34 #include "chrome/browser/metrics/metrics_service.h" |
| 35 #include "chrome/browser/net/chrome_net_log.h" | 35 #include "chrome/browser/net/chrome_net_log.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/notifications/notification_ui_manager.h" | 38 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 39 #include "chrome/browser/plugin_data_remover.h" | 39 #include "chrome/browser/plugin_data_remover.h" |
| 40 #include "chrome/browser/plugin_service.h" | 40 #include "chrome/browser/plugin_service.h" |
| 41 #include "chrome/browser/plugin_updater.h" | 41 #include "chrome/browser/plugin_updater.h" |
| 42 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" | 42 #include "chrome/browser/policy/browser_policy_connector.h" |
| 43 #include "chrome/browser/prefs/pref_service.h" | 43 #include "chrome/browser/prefs/pref_service.h" |
| 44 #include "chrome/browser/printing/print_job_manager.h" | 44 #include "chrome/browser/printing/print_job_manager.h" |
| 45 #include "chrome/browser/printing/print_preview_tab_controller.h" | 45 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 46 #include "chrome/browser/profiles/profile_manager.h" | 46 #include "chrome/browser/profiles/profile_manager.h" |
| 47 #include "chrome/browser/renderer_host/render_process_host.h" | 47 #include "chrome/browser/renderer_host/render_process_host.h" |
| 48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 49 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 49 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 50 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 50 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 51 #include "chrome/browser/shell_integration.h" | 51 #include "chrome/browser/shell_integration.h" |
| 52 #include "chrome/browser/sidebar/sidebar_manager.h" | 52 #include "chrome/browser/sidebar/sidebar_manager.h" |
| 53 #include "chrome/browser/tab_closeable_state_watcher.h" | 53 #include "chrome/browser/tab_closeable_state_watcher.h" |
| 54 #include "chrome/common/chrome_constants.h" | 54 #include "chrome/common/chrome_constants.h" |
| 55 #include "chrome/common/chrome_paths.h" | 55 #include "chrome/common/chrome_paths.h" |
| 56 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
| 57 #include "chrome/common/extensions/extension_l10n_util.h" |
| 57 #include "chrome/common/extensions/extension_resource.h" | 58 #include "chrome/common/extensions/extension_resource.h" |
| 58 #include "chrome/common/extensions/extension_l10n_util.h" | |
| 59 #include "chrome/common/json_pref_store.h" | 59 #include "chrome/common/json_pref_store.h" |
| 60 #include "chrome/common/notification_service.h" | 60 #include "chrome/common/notification_service.h" |
| 61 #include "chrome/common/pref_names.h" | 61 #include "chrome/common/pref_names.h" |
| 62 #include "chrome/common/switch_utils.h" |
| 62 #include "chrome/common/url_constants.h" | 63 #include "chrome/common/url_constants.h" |
| 63 #include "chrome/common/switch_utils.h" | |
| 64 #include "chrome/installer/util/google_update_constants.h" | 64 #include "chrome/installer/util/google_update_constants.h" |
| 65 #include "ipc/ipc_logging.h" | 65 #include "ipc/ipc_logging.h" |
| 66 #include "ui/base/clipboard/clipboard.h" | 66 #include "ui/base/clipboard/clipboard.h" |
| 67 #include "ui/base/l10n/l10n_util.h" | 67 #include "ui/base/l10n/l10n_util.h" |
| 68 #include "webkit/database/database_tracker.h" | 68 #include "webkit/database/database_tracker.h" |
| 69 | 69 |
| 70 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
| 71 #include "views/focus/view_storage.h" | 71 #include "views/focus/view_storage.h" |
| 72 #endif | 72 #endif |
| 73 | 73 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 created_io_thread_(false), | 95 created_io_thread_(false), |
| 96 created_file_thread_(false), | 96 created_file_thread_(false), |
| 97 created_db_thread_(false), | 97 created_db_thread_(false), |
| 98 created_process_launcher_thread_(false), | 98 created_process_launcher_thread_(false), |
| 99 created_cache_thread_(false), | 99 created_cache_thread_(false), |
| 100 created_profile_manager_(false), | 100 created_profile_manager_(false), |
| 101 created_local_state_(false), | 101 created_local_state_(false), |
| 102 created_icon_manager_(false), | 102 created_icon_manager_(false), |
| 103 created_devtools_manager_(false), | 103 created_devtools_manager_(false), |
| 104 created_sidebar_manager_(false), | 104 created_sidebar_manager_(false), |
| 105 created_configuration_policy_provider_keeper_(false), | 105 created_browser_policy_connector_(false), |
| 106 created_notification_ui_manager_(false), | 106 created_notification_ui_manager_(false), |
| 107 created_safe_browsing_detection_service_(false), | 107 created_safe_browsing_detection_service_(false), |
| 108 module_ref_count_(0), | 108 module_ref_count_(0), |
| 109 did_start_(false), | 109 did_start_(false), |
| 110 checked_for_new_frames_(false), | 110 checked_for_new_frames_(false), |
| 111 using_new_frames_(false), | 111 using_new_frames_(false), |
| 112 have_inspector_files_(true) { | 112 have_inspector_files_(true) { |
| 113 g_browser_process = this; | 113 g_browser_process = this; |
| 114 clipboard_.reset(new ui::Clipboard); | 114 clipboard_.reset(new ui::Clipboard); |
| 115 main_notification_service_.reset(new NotificationService); | 115 main_notification_service_.reset(new NotificationService); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 if (resource_dispatcher_host_.get()) { | 180 if (resource_dispatcher_host_.get()) { |
| 181 // Need to tell Safe Browsing Service that the IO thread is going away | 181 // Need to tell Safe Browsing Service that the IO thread is going away |
| 182 // since it cached a pointer to it. | 182 // since it cached a pointer to it. |
| 183 if (resource_dispatcher_host()->safe_browsing_service()) | 183 if (resource_dispatcher_host()->safe_browsing_service()) |
| 184 resource_dispatcher_host()->safe_browsing_service()->ShutDown(); | 184 resource_dispatcher_host()->safe_browsing_service()->ShutDown(); |
| 185 | 185 |
| 186 // Cancel pending requests and prevent new requests. | 186 // Cancel pending requests and prevent new requests. |
| 187 resource_dispatcher_host()->Shutdown(); | 187 resource_dispatcher_host()->Shutdown(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 // The policy providers managed by |configuration_policy_provider_keeper_| | 190 // The policy providers managed by |browser_policy_connector_| need to shut |
| 191 // need to shut down while the file thread is still alive. | 191 // down while the IO and FILE threads are still alive. |
| 192 configuration_policy_provider_keeper_.reset(); | 192 browser_policy_connector_.reset(); |
| 193 | 193 |
| 194 #if defined(USE_X11) | 194 #if defined(USE_X11) |
| 195 // The IO thread must outlive the BACKGROUND_X11 thread. | 195 // The IO thread must outlive the BACKGROUND_X11 thread. |
| 196 background_x11_thread_.reset(); | 196 background_x11_thread_.reset(); |
| 197 #endif | 197 #endif |
| 198 | 198 |
| 199 // Wait for removing plugin data to finish before shutting down the IO thread. | 199 // Wait for removing plugin data to finish before shutting down the IO thread. |
| 200 WaitForPluginDataRemoverToFinish(); | 200 WaitForPluginDataRemoverToFinish(); |
| 201 | 201 |
| 202 // Need to stop io_thread_ before resource_dispatcher_host_, since | 202 // Need to stop io_thread_ before resource_dispatcher_host_, since |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 return clipboard_.get(); | 423 return clipboard_.get(); |
| 424 } | 424 } |
| 425 | 425 |
| 426 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { | 426 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { |
| 427 DCHECK(CalledOnValidThread()); | 427 DCHECK(CalledOnValidThread()); |
| 428 if (!created_notification_ui_manager_) | 428 if (!created_notification_ui_manager_) |
| 429 CreateNotificationUIManager(); | 429 CreateNotificationUIManager(); |
| 430 return notification_ui_manager_.get(); | 430 return notification_ui_manager_.get(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 policy::ConfigurationPolicyProviderKeeper* | 433 policy::BrowserPolicyConnector* BrowserProcessImpl::browser_policy_connector() { |
| 434 BrowserProcessImpl::configuration_policy_provider_keeper() { | |
| 435 DCHECK(CalledOnValidThread()); | 434 DCHECK(CalledOnValidThread()); |
| 436 if (!created_configuration_policy_provider_keeper_) { | 435 if (!created_browser_policy_connector_) { |
| 437 DCHECK(configuration_policy_provider_keeper_.get() == NULL); | 436 DCHECK(browser_policy_connector_.get() == NULL); |
| 438 created_configuration_policy_provider_keeper_ = true; | 437 created_browser_policy_connector_ = true; |
| 439 configuration_policy_provider_keeper_.reset( | 438 browser_policy_connector_.reset(new policy::BrowserPolicyConnector()); |
| 440 new policy::ConfigurationPolicyProviderKeeper()); | |
| 441 } | 439 } |
| 442 return configuration_policy_provider_keeper_.get(); | 440 return browser_policy_connector_.get(); |
| 443 } | 441 } |
| 444 | 442 |
| 445 IconManager* BrowserProcessImpl::icon_manager() { | 443 IconManager* BrowserProcessImpl::icon_manager() { |
| 446 DCHECK(CalledOnValidThread()); | 444 DCHECK(CalledOnValidThread()); |
| 447 if (!created_icon_manager_) | 445 if (!created_icon_manager_) |
| 448 CreateIconManager(); | 446 CreateIconManager(); |
| 449 return icon_manager_.get(); | 447 return icon_manager_.get(); |
| 450 } | 448 } |
| 451 | 449 |
| 452 ThumbnailGenerator* BrowserProcessImpl::GetThumbnailGenerator() { | 450 ThumbnailGenerator* BrowserProcessImpl::GetThumbnailGenerator() { |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 } | 941 } |
| 944 | 942 |
| 945 void BrowserProcessImpl::OnAutoupdateTimer() { | 943 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 946 if (CanAutorestartForUpdate()) { | 944 if (CanAutorestartForUpdate()) { |
| 947 DLOG(WARNING) << "Detected update. Restarting browser."; | 945 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 948 RestartPersistentInstance(); | 946 RestartPersistentInstance(); |
| 949 } | 947 } |
| 950 } | 948 } |
| 951 | 949 |
| 952 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 950 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |