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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 new BackgroundModeManager(CommandLine::ForCurrentProcess(), | 824 new BackgroundModeManager(CommandLine::ForCurrentProcess(), |
825 &profile_manager()->GetProfileInfoCache())); | 825 &profile_manager()->GetProfileInfoCache())); |
826 } | 826 } |
827 | 827 |
828 void BrowserProcessImpl::CreateStatusTray() { | 828 void BrowserProcessImpl::CreateStatusTray() { |
829 DCHECK(status_tray_.get() == NULL); | 829 DCHECK(status_tray_.get() == NULL); |
830 status_tray_.reset(StatusTray::Create()); | 830 status_tray_.reset(StatusTray::Create()); |
831 } | 831 } |
832 | 832 |
833 void BrowserProcessImpl::CreatePrintPreviewTabController() { | 833 void BrowserProcessImpl::CreatePrintPreviewTabController() { |
834 #if defined(OS_ANDROID) | 834 #if defined(ENABLE_PRINTING) |
835 NOTIMPLEMENTED(); | |
836 #else | |
837 DCHECK(print_preview_tab_controller_.get() == NULL); | 835 DCHECK(print_preview_tab_controller_.get() == NULL); |
838 print_preview_tab_controller_ = new printing::PrintPreviewTabController(); | 836 print_preview_tab_controller_ = new printing::PrintPreviewTabController(); |
| 837 #else |
| 838 NOTIMPLEMENTED(); |
839 #endif | 839 #endif |
840 } | 840 } |
841 | 841 |
842 void BrowserProcessImpl::CreateBackgroundPrintingManager() { | 842 void BrowserProcessImpl::CreateBackgroundPrintingManager() { |
| 843 #if defined(ENABLE_PRINTING) |
843 DCHECK(background_printing_manager_.get() == NULL); | 844 DCHECK(background_printing_manager_.get() == NULL); |
844 background_printing_manager_.reset(new printing::BackgroundPrintingManager()); | 845 background_printing_manager_.reset(new printing::BackgroundPrintingManager()); |
| 846 #else |
| 847 NOTIMPLEMENTED(); |
| 848 #endif |
845 } | 849 } |
846 | 850 |
847 void BrowserProcessImpl::CreateSafeBrowsingService() { | 851 void BrowserProcessImpl::CreateSafeBrowsingService() { |
848 DCHECK(safe_browsing_service_.get() == NULL); | 852 DCHECK(safe_browsing_service_.get() == NULL); |
849 // Set this flag to true so that we don't retry indefinitely to | 853 // Set this flag to true so that we don't retry indefinitely to |
850 // create the service class if there was an error. | 854 // create the service class if there was an error. |
851 created_safe_browsing_service_ = true; | 855 created_safe_browsing_service_ = true; |
852 #if defined(ENABLE_SAFE_BROWSING) | 856 #if defined(ENABLE_SAFE_BROWSING) |
853 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); | 857 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); |
854 safe_browsing_service_->Initialize(); | 858 safe_browsing_service_->Initialize(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 } | 934 } |
931 | 935 |
932 void BrowserProcessImpl::OnAutoupdateTimer() { | 936 void BrowserProcessImpl::OnAutoupdateTimer() { |
933 if (CanAutorestartForUpdate()) { | 937 if (CanAutorestartForUpdate()) { |
934 DLOG(WARNING) << "Detected update. Restarting browser."; | 938 DLOG(WARNING) << "Detected update. Restarting browser."; |
935 RestartBackgroundInstance(); | 939 RestartBackgroundInstance(); |
936 } | 940 } |
937 } | 941 } |
938 | 942 |
939 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 943 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |