| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 created_safe_browsing_service_(false), | 127 created_safe_browsing_service_(false), |
| 128 module_ref_count_(0), | 128 module_ref_count_(0), |
| 129 did_start_(false), | 129 did_start_(false), |
| 130 checked_for_new_frames_(false), | 130 checked_for_new_frames_(false), |
| 131 using_new_frames_(false), | 131 using_new_frames_(false), |
| 132 thumbnail_generator_(new ThumbnailGenerator), | 132 thumbnail_generator_(new ThumbnailGenerator), |
| 133 download_status_updater_(new DownloadStatusUpdater) { | 133 download_status_updater_(new DownloadStatusUpdater) { |
| 134 g_browser_process = this; | 134 g_browser_process = this; |
| 135 clipboard_.reset(new ui::Clipboard); | 135 clipboard_.reset(new ui::Clipboard); |
| 136 | 136 |
| 137 #if !defined(OS_ANDROID) |
| 137 // Must be created after the NotificationService. | 138 // Must be created after the NotificationService. |
| 138 print_job_manager_.reset(new printing::PrintJobManager); | 139 print_job_manager_.reset(new printing::PrintJobManager); |
| 140 #endif |
| 139 | 141 |
| 140 net_log_.reset(new ChromeNetLog); | 142 net_log_.reset(new ChromeNetLog); |
| 141 | 143 |
| 142 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 144 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
| 143 chrome::kExtensionScheme); | 145 chrome::kExtensionScheme); |
| 144 | 146 |
| 145 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; | 147 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; |
| 146 | 148 |
| 147 ExtensionTabIdMap::GetInstance()->Init(); | 149 ExtensionTabIdMap::GetInstance()->Init(); |
| 148 | 150 |
| 149 online_state_observer_.reset(new BrowserOnlineStateObserver); | 151 online_state_observer_.reset(new BrowserOnlineStateObserver); |
| 150 } | 152 } |
| 151 | 153 |
| 152 BrowserProcessImpl::~BrowserProcessImpl() { | 154 BrowserProcessImpl::~BrowserProcessImpl() { |
| 155 #if !defined(OS_ANDROID) |
| 153 // Wait for the pending print jobs to finish. | 156 // Wait for the pending print jobs to finish. |
| 154 print_job_manager_->OnQuit(); | 157 print_job_manager_->OnQuit(); |
| 155 print_job_manager_.reset(); | 158 print_job_manager_.reset(); |
| 159 #endif |
| 156 | 160 |
| 157 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); | 161 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); |
| 158 | 162 |
| 159 g_browser_process = NULL; | 163 g_browser_process = NULL; |
| 160 } | 164 } |
| 161 | 165 |
| 162 void BrowserProcessImpl::StartTearDown() { | 166 void BrowserProcessImpl::StartTearDown() { |
| 163 // Delete the AutomationProviderList before NotificationService, | 167 // Delete the AutomationProviderList before NotificationService, |
| 164 // since it may try to unregister notifications | 168 // since it may try to unregister notifications |
| 165 // Both NotificationService and AutomationProvider are singleton instances in | 169 // Both NotificationService and AutomationProvider are singleton instances in |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 // TODO(abarth): DCHECK(CalledOnValidThread()); | 463 // TODO(abarth): DCHECK(CalledOnValidThread()); |
| 460 // http://code.google.com/p/chromium/issues/detail?id=6828 | 464 // http://code.google.com/p/chromium/issues/detail?id=6828 |
| 461 // print_job_manager_ is initialized in the constructor and destroyed in the | 465 // print_job_manager_ is initialized in the constructor and destroyed in the |
| 462 // destructor, so it should always be valid. | 466 // destructor, so it should always be valid. |
| 463 DCHECK(print_job_manager_.get()); | 467 DCHECK(print_job_manager_.get()); |
| 464 return print_job_manager_.get(); | 468 return print_job_manager_.get(); |
| 465 } | 469 } |
| 466 | 470 |
| 467 printing::PrintPreviewTabController* | 471 printing::PrintPreviewTabController* |
| 468 BrowserProcessImpl::print_preview_tab_controller() { | 472 BrowserProcessImpl::print_preview_tab_controller() { |
| 473 #if defined(OS_ANDROID) |
| 474 NOTIMPLEMENTED(); |
| 475 return NULL; |
| 476 #else |
| 469 DCHECK(CalledOnValidThread()); | 477 DCHECK(CalledOnValidThread()); |
| 470 if (!print_preview_tab_controller_.get()) | 478 if (!print_preview_tab_controller_.get()) |
| 471 CreatePrintPreviewTabController(); | 479 CreatePrintPreviewTabController(); |
| 472 return print_preview_tab_controller_.get(); | 480 return print_preview_tab_controller_.get(); |
| 481 #endif |
| 473 } | 482 } |
| 474 | 483 |
| 475 printing::BackgroundPrintingManager* | 484 printing::BackgroundPrintingManager* |
| 476 BrowserProcessImpl::background_printing_manager() { | 485 BrowserProcessImpl::background_printing_manager() { |
| 486 #if defined(OS_ANDROID) |
| 487 NOTIMPLEMENTED(); |
| 488 return NULL; |
| 489 #else |
| 477 DCHECK(CalledOnValidThread()); | 490 DCHECK(CalledOnValidThread()); |
| 478 if (!background_printing_manager_.get()) | 491 if (!background_printing_manager_.get()) |
| 479 CreateBackgroundPrintingManager(); | 492 CreateBackgroundPrintingManager(); |
| 480 return background_printing_manager_.get(); | 493 return background_printing_manager_.get(); |
| 494 #endif |
| 481 } | 495 } |
| 482 | 496 |
| 483 GoogleURLTracker* BrowserProcessImpl::google_url_tracker() { | 497 GoogleURLTracker* BrowserProcessImpl::google_url_tracker() { |
| 484 DCHECK(CalledOnValidThread()); | 498 DCHECK(CalledOnValidThread()); |
| 485 if (!google_url_tracker_.get()) | 499 if (!google_url_tracker_.get()) |
| 486 CreateGoogleURLTracker(); | 500 CreateGoogleURLTracker(); |
| 487 return google_url_tracker_.get(); | 501 return google_url_tracker_.get(); |
| 488 } | 502 } |
| 489 | 503 |
| 490 IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() { | 504 IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 FilePath local_state_path; | 693 FilePath local_state_path; |
| 680 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 694 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
| 681 local_state_.reset( | 695 local_state_.reset( |
| 682 PrefService::CreatePrefService(local_state_path, NULL, false)); | 696 PrefService::CreatePrefService(local_state_path, NULL, false)); |
| 683 | 697 |
| 684 // Initialize the prefs of the local state. | 698 // Initialize the prefs of the local state. |
| 685 browser::RegisterLocalState(local_state_.get()); | 699 browser::RegisterLocalState(local_state_.get()); |
| 686 | 700 |
| 687 pref_change_registrar_.Init(local_state_.get()); | 701 pref_change_registrar_.Init(local_state_.get()); |
| 688 | 702 |
| 703 #if !defined(OS_ANDROID) |
| 689 print_job_manager_->InitOnUIThread(local_state_.get()); | 704 print_job_manager_->InitOnUIThread(local_state_.get()); |
| 705 #endif |
| 690 | 706 |
| 691 // Initialize the notification for the default browser setting policy. | 707 // Initialize the notification for the default browser setting policy. |
| 692 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, | 708 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, |
| 693 false); | 709 false); |
| 694 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); | 710 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); |
| 695 | 711 |
| 696 // Initialize the preference for the plugin finder policy. | 712 // Initialize the preference for the plugin finder policy. |
| 697 // This preference is only needed on the IO thread so make it available there. | 713 // This preference is only needed on the IO thread so make it available there. |
| 698 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); | 714 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); |
| 699 plugin_finder_disabled_pref_.reset(new BooleanPrefMember); | 715 plugin_finder_disabled_pref_.reset(new BooleanPrefMember); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 new BackgroundModeManager(CommandLine::ForCurrentProcess(), | 802 new BackgroundModeManager(CommandLine::ForCurrentProcess(), |
| 787 &profile_manager()->GetProfileInfoCache())); | 803 &profile_manager()->GetProfileInfoCache())); |
| 788 } | 804 } |
| 789 | 805 |
| 790 void BrowserProcessImpl::CreateStatusTray() { | 806 void BrowserProcessImpl::CreateStatusTray() { |
| 791 DCHECK(status_tray_.get() == NULL); | 807 DCHECK(status_tray_.get() == NULL); |
| 792 status_tray_.reset(StatusTray::Create()); | 808 status_tray_.reset(StatusTray::Create()); |
| 793 } | 809 } |
| 794 | 810 |
| 795 void BrowserProcessImpl::CreatePrintPreviewTabController() { | 811 void BrowserProcessImpl::CreatePrintPreviewTabController() { |
| 812 #if defined(OS_ANDROID) |
| 813 NOTIMPLEMENTED(); |
| 814 #else |
| 796 DCHECK(print_preview_tab_controller_.get() == NULL); | 815 DCHECK(print_preview_tab_controller_.get() == NULL); |
| 797 print_preview_tab_controller_ = new printing::PrintPreviewTabController(); | 816 print_preview_tab_controller_ = new printing::PrintPreviewTabController(); |
| 817 #endif |
| 798 } | 818 } |
| 799 | 819 |
| 800 void BrowserProcessImpl::CreateBackgroundPrintingManager() { | 820 void BrowserProcessImpl::CreateBackgroundPrintingManager() { |
| 801 DCHECK(background_printing_manager_.get() == NULL); | 821 DCHECK(background_printing_manager_.get() == NULL); |
| 802 background_printing_manager_.reset(new printing::BackgroundPrintingManager()); | 822 background_printing_manager_.reset(new printing::BackgroundPrintingManager()); |
| 803 } | 823 } |
| 804 | 824 |
| 805 void BrowserProcessImpl::CreateSafeBrowsingService() { | 825 void BrowserProcessImpl::CreateSafeBrowsingService() { |
| 806 DCHECK(safe_browsing_service_.get() == NULL); | 826 DCHECK(safe_browsing_service_.get() == NULL); |
| 807 // Set this flag to true so that we don't retry indefinitely to | 827 // Set this flag to true so that we don't retry indefinitely to |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 } | 908 } |
| 889 | 909 |
| 890 void BrowserProcessImpl::OnAutoupdateTimer() { | 910 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 891 if (CanAutorestartForUpdate()) { | 911 if (CanAutorestartForUpdate()) { |
| 892 DLOG(WARNING) << "Detected update. Restarting browser."; | 912 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 893 RestartBackgroundInstance(); | 913 RestartBackgroundInstance(); |
| 894 } | 914 } |
| 895 } | 915 } |
| 896 | 916 |
| 897 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 917 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |