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 <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 created_safe_browsing_service_(false), | 137 created_safe_browsing_service_(false), |
138 module_ref_count_(0), | 138 module_ref_count_(0), |
139 did_start_(false), | 139 did_start_(false), |
140 checked_for_new_frames_(false), | 140 checked_for_new_frames_(false), |
141 using_new_frames_(false), | 141 using_new_frames_(false), |
142 thumbnail_generator_(new ThumbnailGenerator), | 142 thumbnail_generator_(new ThumbnailGenerator), |
143 download_status_updater_(new DownloadStatusUpdater) { | 143 download_status_updater_(new DownloadStatusUpdater) { |
144 g_browser_process = this; | 144 g_browser_process = this; |
145 clipboard_.reset(new ui::Clipboard); | 145 clipboard_.reset(new ui::Clipboard); |
146 | 146 |
147 #if !defined(OS_ANDROID) | 147 #if defined(ENABLE_PRINTING) |
148 // Must be created after the NotificationService. | 148 // Must be created after the NotificationService. |
149 print_job_manager_.reset(new printing::PrintJobManager); | 149 print_job_manager_.reset(new printing::PrintJobManager); |
150 #endif | 150 #endif |
151 | 151 |
152 net_log_.reset(new ChromeNetLog); | 152 net_log_.reset(new ChromeNetLog); |
153 | 153 |
154 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 154 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
155 chrome::kExtensionScheme); | 155 chrome::kExtensionScheme); |
156 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 156 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
157 chrome::kExtensionResourceScheme); | 157 chrome::kExtensionResourceScheme); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 return module_ref_count_; | 274 return module_ref_count_; |
275 } | 275 } |
276 | 276 |
277 unsigned int BrowserProcessImpl::ReleaseModule() { | 277 unsigned int BrowserProcessImpl::ReleaseModule() { |
278 DCHECK(CalledOnValidThread()); | 278 DCHECK(CalledOnValidThread()); |
279 DCHECK_NE(0u, module_ref_count_); | 279 DCHECK_NE(0u, module_ref_count_); |
280 module_ref_count_--; | 280 module_ref_count_--; |
281 if (0 == module_ref_count_) { | 281 if (0 == module_ref_count_) { |
282 release_last_reference_callstack_ = base::debug::StackTrace(); | 282 release_last_reference_callstack_ = base::debug::StackTrace(); |
283 | 283 |
284 #if !defined(OS_ANDROID) | 284 #if defined(ENABLE_PRINTING) |
285 // Wait for the pending print jobs to finish. Don't do this later, since | 285 // Wait for the pending print jobs to finish. Don't do this later, since |
286 // this might cause a nested message loop to run, and we don't want pending | 286 // this might cause a nested message loop to run, and we don't want pending |
287 // tasks to run once teardown has started. | 287 // tasks to run once teardown has started. |
288 print_job_manager_->OnQuit(); | 288 print_job_manager_->OnQuit(); |
289 print_job_manager_.reset(); | 289 print_job_manager_.reset(); |
290 #endif | 290 #endif |
291 | 291 |
292 CHECK(MessageLoop::current()->is_running()); | 292 CHECK(MessageLoop::current()->is_running()); |
293 | 293 |
294 #if defined(OS_MACOSX) | 294 #if defined(OS_MACOSX) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 // TODO(abarth): DCHECK(CalledOnValidThread()); | 492 // TODO(abarth): DCHECK(CalledOnValidThread()); |
493 // http://code.google.com/p/chromium/issues/detail?id=6828 | 493 // http://code.google.com/p/chromium/issues/detail?id=6828 |
494 // print_job_manager_ is initialized in the constructor and destroyed in the | 494 // print_job_manager_ is initialized in the constructor and destroyed in the |
495 // destructor, so it should always be valid. | 495 // destructor, so it should always be valid. |
496 DCHECK(print_job_manager_.get()); | 496 DCHECK(print_job_manager_.get()); |
497 return print_job_manager_.get(); | 497 return print_job_manager_.get(); |
498 } | 498 } |
499 | 499 |
500 printing::PrintPreviewTabController* | 500 printing::PrintPreviewTabController* |
501 BrowserProcessImpl::print_preview_tab_controller() { | 501 BrowserProcessImpl::print_preview_tab_controller() { |
502 #if defined(OS_ANDROID) | 502 #if defined(ENABLE_PRINTING) |
503 NOTIMPLEMENTED(); | |
504 return NULL; | |
505 #else | |
506 DCHECK(CalledOnValidThread()); | 503 DCHECK(CalledOnValidThread()); |
507 if (!print_preview_tab_controller_.get()) | 504 if (!print_preview_tab_controller_.get()) |
508 CreatePrintPreviewTabController(); | 505 CreatePrintPreviewTabController(); |
509 return print_preview_tab_controller_.get(); | 506 return print_preview_tab_controller_.get(); |
| 507 #else |
| 508 NOTIMPLEMENTED(); |
| 509 return NULL; |
510 #endif | 510 #endif |
511 } | 511 } |
512 | 512 |
513 printing::BackgroundPrintingManager* | 513 printing::BackgroundPrintingManager* |
514 BrowserProcessImpl::background_printing_manager() { | 514 BrowserProcessImpl::background_printing_manager() { |
515 #if defined(OS_ANDROID) | 515 #if defined(ENABLE_PRINTING) |
516 NOTIMPLEMENTED(); | |
517 return NULL; | |
518 #else | |
519 DCHECK(CalledOnValidThread()); | 516 DCHECK(CalledOnValidThread()); |
520 if (!background_printing_manager_.get()) | 517 if (!background_printing_manager_.get()) |
521 CreateBackgroundPrintingManager(); | 518 CreateBackgroundPrintingManager(); |
522 return background_printing_manager_.get(); | 519 return background_printing_manager_.get(); |
| 520 #else |
| 521 NOTIMPLEMENTED(); |
| 522 return NULL; |
523 #endif | 523 #endif |
524 } | 524 } |
525 | 525 |
526 IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() { | 526 IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() { |
527 DCHECK(CalledOnValidThread()); | 527 DCHECK(CalledOnValidThread()); |
528 if (!intranet_redirect_detector_.get()) | 528 if (!intranet_redirect_detector_.get()) |
529 CreateIntranetRedirectDetector(); | 529 CreateIntranetRedirectDetector(); |
530 return intranet_redirect_detector_.get(); | 530 return intranet_redirect_detector_.get(); |
531 } | 531 } |
532 | 532 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 706 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
707 local_state_.reset( | 707 local_state_.reset( |
708 PrefService::CreatePrefService(local_state_path, policy_service(), NULL, | 708 PrefService::CreatePrefService(local_state_path, policy_service(), NULL, |
709 false)); | 709 false)); |
710 | 710 |
711 // Initialize the prefs of the local state. | 711 // Initialize the prefs of the local state. |
712 browser::RegisterLocalState(local_state_.get()); | 712 browser::RegisterLocalState(local_state_.get()); |
713 | 713 |
714 pref_change_registrar_.Init(local_state_.get()); | 714 pref_change_registrar_.Init(local_state_.get()); |
715 | 715 |
716 #if !defined(OS_ANDROID) | 716 #if defined(ENABLE_PRINTING) |
717 print_job_manager_->InitOnUIThread(local_state_.get()); | 717 print_job_manager_->InitOnUIThread(local_state_.get()); |
718 #endif | 718 #endif |
719 | 719 |
720 // Initialize the notification for the default browser setting policy. | 720 // Initialize the notification for the default browser setting policy. |
721 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, | 721 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, |
722 false); | 722 false); |
723 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); | 723 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); |
724 | 724 |
725 // Initialize the preference for the plugin finder policy. | 725 // Initialize the preference for the plugin finder policy. |
726 // This preference is only needed on the IO thread so make it available there. | 726 // This preference is only needed on the IO thread so make it available there. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 new BackgroundModeManager(CommandLine::ForCurrentProcess(), | 822 new BackgroundModeManager(CommandLine::ForCurrentProcess(), |
823 &profile_manager()->GetProfileInfoCache())); | 823 &profile_manager()->GetProfileInfoCache())); |
824 } | 824 } |
825 | 825 |
826 void BrowserProcessImpl::CreateStatusTray() { | 826 void BrowserProcessImpl::CreateStatusTray() { |
827 DCHECK(status_tray_.get() == NULL); | 827 DCHECK(status_tray_.get() == NULL); |
828 status_tray_.reset(StatusTray::Create()); | 828 status_tray_.reset(StatusTray::Create()); |
829 } | 829 } |
830 | 830 |
831 void BrowserProcessImpl::CreatePrintPreviewTabController() { | 831 void BrowserProcessImpl::CreatePrintPreviewTabController() { |
832 #if defined(OS_ANDROID) | 832 #if defined(ENABLE_PRINTING) |
833 NOTIMPLEMENTED(); | |
834 #else | |
835 DCHECK(print_preview_tab_controller_.get() == NULL); | 833 DCHECK(print_preview_tab_controller_.get() == NULL); |
836 print_preview_tab_controller_ = new printing::PrintPreviewTabController(); | 834 print_preview_tab_controller_ = new printing::PrintPreviewTabController(); |
| 835 #else |
| 836 NOTIMPLEMENTED(); |
837 #endif | 837 #endif |
838 } | 838 } |
839 | 839 |
840 void BrowserProcessImpl::CreateBackgroundPrintingManager() { | 840 void BrowserProcessImpl::CreateBackgroundPrintingManager() { |
| 841 #if defined(ENABLE_PRINTING) |
841 DCHECK(background_printing_manager_.get() == NULL); | 842 DCHECK(background_printing_manager_.get() == NULL); |
842 background_printing_manager_.reset(new printing::BackgroundPrintingManager()); | 843 background_printing_manager_.reset(new printing::BackgroundPrintingManager()); |
| 844 #else |
| 845 NOTIMPLEMENTED(); |
| 846 #endif |
843 } | 847 } |
844 | 848 |
845 void BrowserProcessImpl::CreateSafeBrowsingService() { | 849 void BrowserProcessImpl::CreateSafeBrowsingService() { |
846 DCHECK(safe_browsing_service_.get() == NULL); | 850 DCHECK(safe_browsing_service_.get() == NULL); |
847 // Set this flag to true so that we don't retry indefinitely to | 851 // Set this flag to true so that we don't retry indefinitely to |
848 // create the service class if there was an error. | 852 // create the service class if there was an error. |
849 created_safe_browsing_service_ = true; | 853 created_safe_browsing_service_ = true; |
850 #if defined(ENABLE_SAFE_BROWSING) | 854 #if defined(ENABLE_SAFE_BROWSING) |
851 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); | 855 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); |
852 safe_browsing_service_->Initialize(); | 856 safe_browsing_service_->Initialize(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 } | 932 } |
929 | 933 |
930 void BrowserProcessImpl::OnAutoupdateTimer() { | 934 void BrowserProcessImpl::OnAutoupdateTimer() { |
931 if (CanAutorestartForUpdate()) { | 935 if (CanAutorestartForUpdate()) { |
932 DLOG(WARNING) << "Detected update. Restarting browser."; | 936 DLOG(WARNING) << "Detected update. Restarting browser."; |
933 RestartBackgroundInstance(); | 937 RestartBackgroundInstance(); |
934 } | 938 } |
935 } | 939 } |
936 | 940 |
937 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 941 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |