| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 created_safe_browsing_service_(false), | 125 created_safe_browsing_service_(false), |
| 126 module_ref_count_(0), | 126 module_ref_count_(0), |
| 127 did_start_(false), | 127 did_start_(false), |
| 128 checked_for_new_frames_(false), | 128 checked_for_new_frames_(false), |
| 129 using_new_frames_(false), | 129 using_new_frames_(false), |
| 130 thumbnail_generator_(new ThumbnailGenerator), | 130 thumbnail_generator_(new ThumbnailGenerator), |
| 131 download_status_updater_(new DownloadStatusUpdater) { | 131 download_status_updater_(new DownloadStatusUpdater) { |
| 132 g_browser_process = this; | 132 g_browser_process = this; |
| 133 clipboard_.reset(new ui::Clipboard); | 133 clipboard_.reset(new ui::Clipboard); |
| 134 | 134 |
| 135 #if !defined(OS_ANDROID) |
| 135 // Must be created after the NotificationService. | 136 // Must be created after the NotificationService. |
| 136 print_job_manager_.reset(new printing::PrintJobManager); | 137 print_job_manager_.reset(new printing::PrintJobManager); |
| 138 #endif |
| 137 | 139 |
| 138 net_log_.reset(new ChromeNetLog); | 140 net_log_.reset(new ChromeNetLog); |
| 139 | 141 |
| 140 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 142 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
| 141 chrome::kExtensionScheme); | 143 chrome::kExtensionScheme); |
| 142 | 144 |
| 143 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; | 145 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; |
| 144 | 146 |
| 145 ExtensionTabIdMap::GetInstance()->Init(); | 147 ExtensionTabIdMap::GetInstance()->Init(); |
| 146 | 148 |
| 147 online_state_observer_.reset(new BrowserOnlineStateObserver); | 149 online_state_observer_.reset(new BrowserOnlineStateObserver); |
| 148 } | 150 } |
| 149 | 151 |
| 150 BrowserProcessImpl::~BrowserProcessImpl() { | 152 BrowserProcessImpl::~BrowserProcessImpl() { |
| 153 #if !defined(OS_ANDROID) |
| 151 // Wait for the pending print jobs to finish. | 154 // Wait for the pending print jobs to finish. |
| 152 print_job_manager_->OnQuit(); | 155 print_job_manager_->OnQuit(); |
| 153 print_job_manager_.reset(); | 156 print_job_manager_.reset(); |
| 157 #endif |
| 154 | 158 |
| 155 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); | 159 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); |
| 156 | 160 |
| 157 g_browser_process = NULL; | 161 g_browser_process = NULL; |
| 158 } | 162 } |
| 159 | 163 |
| 160 void BrowserProcessImpl::StartTearDown() { | 164 void BrowserProcessImpl::StartTearDown() { |
| 161 // Delete the AutomationProviderList before NotificationService, | 165 // Delete the AutomationProviderList before NotificationService, |
| 162 // since it may try to unregister notifications | 166 // since it may try to unregister notifications |
| 163 // Both NotificationService and AutomationProvider are singleton instances in | 167 // Both NotificationService and AutomationProvider are singleton instances in |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 // TODO(abarth): DCHECK(CalledOnValidThread()); | 461 // TODO(abarth): DCHECK(CalledOnValidThread()); |
| 458 // http://code.google.com/p/chromium/issues/detail?id=6828 | 462 // http://code.google.com/p/chromium/issues/detail?id=6828 |
| 459 // print_job_manager_ is initialized in the constructor and destroyed in the | 463 // print_job_manager_ is initialized in the constructor and destroyed in the |
| 460 // destructor, so it should always be valid. | 464 // destructor, so it should always be valid. |
| 461 DCHECK(print_job_manager_.get()); | 465 DCHECK(print_job_manager_.get()); |
| 462 return print_job_manager_.get(); | 466 return print_job_manager_.get(); |
| 463 } | 467 } |
| 464 | 468 |
| 465 printing::PrintPreviewTabController* | 469 printing::PrintPreviewTabController* |
| 466 BrowserProcessImpl::print_preview_tab_controller() { | 470 BrowserProcessImpl::print_preview_tab_controller() { |
| 471 #if defined(OS_ANDROID) |
| 472 NOTIMPLEMENTED(); |
| 473 return NULL; |
| 474 #else |
| 467 DCHECK(CalledOnValidThread()); | 475 DCHECK(CalledOnValidThread()); |
| 468 if (!print_preview_tab_controller_.get()) | 476 if (!print_preview_tab_controller_.get()) |
| 469 CreatePrintPreviewTabController(); | 477 CreatePrintPreviewTabController(); |
| 470 return print_preview_tab_controller_.get(); | 478 return print_preview_tab_controller_.get(); |
| 479 #endif |
| 471 } | 480 } |
| 472 | 481 |
| 473 printing::BackgroundPrintingManager* | 482 printing::BackgroundPrintingManager* |
| 474 BrowserProcessImpl::background_printing_manager() { | 483 BrowserProcessImpl::background_printing_manager() { |
| 484 #if defined(OS_ANDROID) |
| 485 NOTIMPLEMENTED(); |
| 486 return NULL; |
| 487 #else |
| 475 DCHECK(CalledOnValidThread()); | 488 DCHECK(CalledOnValidThread()); |
| 476 if (!background_printing_manager_.get()) | 489 if (!background_printing_manager_.get()) |
| 477 CreateBackgroundPrintingManager(); | 490 CreateBackgroundPrintingManager(); |
| 478 return background_printing_manager_.get(); | 491 return background_printing_manager_.get(); |
| 492 #endif |
| 479 } | 493 } |
| 480 | 494 |
| 481 GoogleURLTracker* BrowserProcessImpl::google_url_tracker() { | 495 GoogleURLTracker* BrowserProcessImpl::google_url_tracker() { |
| 482 DCHECK(CalledOnValidThread()); | 496 DCHECK(CalledOnValidThread()); |
| 483 if (!google_url_tracker_.get()) | 497 if (!google_url_tracker_.get()) |
| 484 CreateGoogleURLTracker(); | 498 CreateGoogleURLTracker(); |
| 485 return google_url_tracker_.get(); | 499 return google_url_tracker_.get(); |
| 486 } | 500 } |
| 487 | 501 |
| 488 IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() { | 502 IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 FilePath local_state_path; | 682 FilePath local_state_path; |
| 669 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 683 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
| 670 local_state_.reset( | 684 local_state_.reset( |
| 671 PrefService::CreatePrefService(local_state_path, NULL, false)); | 685 PrefService::CreatePrefService(local_state_path, NULL, false)); |
| 672 | 686 |
| 673 // Initialize the prefs of the local state. | 687 // Initialize the prefs of the local state. |
| 674 browser::RegisterLocalState(local_state_.get()); | 688 browser::RegisterLocalState(local_state_.get()); |
| 675 | 689 |
| 676 pref_change_registrar_.Init(local_state_.get()); | 690 pref_change_registrar_.Init(local_state_.get()); |
| 677 | 691 |
| 692 #if !defined(OS_ANDROID) |
| 678 print_job_manager_->InitOnUIThread(local_state_.get()); | 693 print_job_manager_->InitOnUIThread(local_state_.get()); |
| 694 #endif |
| 679 | 695 |
| 680 // Initialize the notification for the default browser setting policy. | 696 // Initialize the notification for the default browser setting policy. |
| 681 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, | 697 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, |
| 682 false); | 698 false); |
| 683 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); | 699 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); |
| 684 | 700 |
| 685 // Initialize the preference for the plugin finder policy. | 701 // Initialize the preference for the plugin finder policy. |
| 686 // This preference is only needed on the IO thread so make it available there. | 702 // This preference is only needed on the IO thread so make it available there. |
| 687 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); | 703 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); |
| 688 plugin_finder_disabled_pref_.reset(new BooleanPrefMember); | 704 plugin_finder_disabled_pref_.reset(new BooleanPrefMember); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 new BackgroundModeManager(CommandLine::ForCurrentProcess(), | 791 new BackgroundModeManager(CommandLine::ForCurrentProcess(), |
| 776 &profile_manager()->GetProfileInfoCache())); | 792 &profile_manager()->GetProfileInfoCache())); |
| 777 } | 793 } |
| 778 | 794 |
| 779 void BrowserProcessImpl::CreateStatusTray() { | 795 void BrowserProcessImpl::CreateStatusTray() { |
| 780 DCHECK(status_tray_.get() == NULL); | 796 DCHECK(status_tray_.get() == NULL); |
| 781 status_tray_.reset(StatusTray::Create()); | 797 status_tray_.reset(StatusTray::Create()); |
| 782 } | 798 } |
| 783 | 799 |
| 784 void BrowserProcessImpl::CreatePrintPreviewTabController() { | 800 void BrowserProcessImpl::CreatePrintPreviewTabController() { |
| 801 #if defined(OS_ANDROID) |
| 802 NOTIMPLEMENTED(); |
| 803 #else |
| 785 DCHECK(print_preview_tab_controller_.get() == NULL); | 804 DCHECK(print_preview_tab_controller_.get() == NULL); |
| 786 print_preview_tab_controller_ = new printing::PrintPreviewTabController(); | 805 print_preview_tab_controller_ = new printing::PrintPreviewTabController(); |
| 806 #endif |
| 787 } | 807 } |
| 788 | 808 |
| 789 void BrowserProcessImpl::CreateBackgroundPrintingManager() { | 809 void BrowserProcessImpl::CreateBackgroundPrintingManager() { |
| 790 DCHECK(background_printing_manager_.get() == NULL); | 810 DCHECK(background_printing_manager_.get() == NULL); |
| 791 background_printing_manager_.reset(new printing::BackgroundPrintingManager()); | 811 background_printing_manager_.reset(new printing::BackgroundPrintingManager()); |
| 792 } | 812 } |
| 793 | 813 |
| 794 void BrowserProcessImpl::CreateSafeBrowsingService() { | 814 void BrowserProcessImpl::CreateSafeBrowsingService() { |
| 795 DCHECK(safe_browsing_service_.get() == NULL); | 815 DCHECK(safe_browsing_service_.get() == NULL); |
| 796 // Set this flag to true so that we don't retry indefinitely to | 816 // 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... |
| 877 } | 897 } |
| 878 | 898 |
| 879 void BrowserProcessImpl::OnAutoupdateTimer() { | 899 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 880 if (CanAutorestartForUpdate()) { | 900 if (CanAutorestartForUpdate()) { |
| 881 DLOG(WARNING) << "Detected update. Restarting browser."; | 901 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 882 RestartBackgroundInstance(); | 902 RestartBackgroundInstance(); |
| 883 } | 903 } |
| 884 } | 904 } |
| 885 | 905 |
| 886 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 906 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |