Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 11689004: Move PromoResourceService from Profile to BrowserProcessImpl/local_state(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "chrome/browser/printing/print_job_manager.h" 56 #include "chrome/browser/printing/print_job_manager.h"
57 #include "chrome/browser/printing/print_preview_dialog_controller.h" 57 #include "chrome/browser/printing/print_preview_dialog_controller.h"
58 #include "chrome/browser/profiles/profile_manager.h" 58 #include "chrome/browser/profiles/profile_manager.h"
59 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 59 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
60 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 60 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
61 #include "chrome/browser/shell_integration.h" 61 #include "chrome/browser/shell_integration.h"
62 #include "chrome/browser/status_icons/status_tray.h" 62 #include "chrome/browser/status_icons/status_tray.h"
63 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h" 63 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h"
64 #include "chrome/browser/ui/bookmarks/bookmark_prompt_controller.h" 64 #include "chrome/browser/ui/bookmarks/bookmark_prompt_controller.h"
65 #include "chrome/browser/ui/browser_list.h" 65 #include "chrome/browser/ui/browser_list.h"
66 #include "chrome/browser/web_resource/promo_resource_service.h"
66 #include "chrome/common/chrome_constants.h" 67 #include "chrome/common/chrome_constants.h"
67 #include "chrome/common/chrome_notification_types.h" 68 #include "chrome/common/chrome_notification_types.h"
68 #include "chrome/common/chrome_paths.h" 69 #include "chrome/common/chrome_paths.h"
69 #include "chrome/common/chrome_switches.h" 70 #include "chrome/common/chrome_switches.h"
70 #include "chrome/common/extensions/extension_l10n_util.h" 71 #include "chrome/common/extensions/extension_l10n_util.h"
71 #include "chrome/common/extensions/extension_resource.h" 72 #include "chrome/common/extensions/extension_resource.h"
72 #include "chrome/common/pref_names.h" 73 #include "chrome/common/pref_names.h"
73 #include "chrome/common/switch_utils.h" 74 #include "chrome/common/switch_utils.h"
74 #include "chrome/common/url_constants.h" 75 #include "chrome/common/url_constants.h"
75 #include "chrome/installer/util/google_update_constants.h" 76 #include "chrome/installer/util/google_update_constants.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 #endif 195 #endif
195 196
196 // We need to shutdown the SdchDictionaryFetcher as it regularly holds 197 // We need to shutdown the SdchDictionaryFetcher as it regularly holds
197 // a pointer to a URLFetcher, and that URLFetcher (upon destruction) will do 198 // a pointer to a URLFetcher, and that URLFetcher (upon destruction) will do
198 // a PostDelayedTask onto the IO thread. This shutdown call will both discard 199 // a PostDelayedTask onto the IO thread. This shutdown call will both discard
199 // any pending URLFetchers, and avoid creating any more. 200 // any pending URLFetchers, and avoid creating any more.
200 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 201 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
201 base::Bind(&SdchDictionaryFetcher::Shutdown)); 202 base::Bind(&SdchDictionaryFetcher::Shutdown));
202 203
203 // We need to destroy the MetricsService, VariationsService, 204 // We need to destroy the MetricsService, VariationsService,
204 // IntranetRedirectDetector, and SafeBrowsing ClientSideDetectionService 205 // IntranetRedirectDetector, PromoResourceService, and SafeBrowsing
205 // (owned by the SafeBrowsingService) before the io_thread_ gets destroyed, 206 // ClientSideDetectionService (owned by the SafeBrowsingService) before the
206 // since their destructors can call the URLFetcher destructor, which does a 207 // io_thread_ gets destroyed, since their destructors can call the URLFetcher
207 // PostDelayedTask operation on the IO thread. (The IO thread will handle that 208 // destructor, which does a PostDelayedTask operation on the IO thread. (The
208 // URLFetcher operation before going away.) 209 // IO thread will handle that URLFetcher operation before going away.)
209 metrics_service_.reset(); 210 metrics_service_.reset();
210 variations_service_.reset(); 211 variations_service_.reset();
211 intranet_redirect_detector_.reset(); 212 intranet_redirect_detector_.reset();
212 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 213 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
213 if (safe_browsing_service_.get()) { 214 if (safe_browsing_service_.get())
214 safe_browsing_service()->ShutDown(); 215 safe_browsing_service()->ShutDown();
215 }
216 #endif 216 #endif
217 217
218 // Need to clear the desktop notification balloons before the io_thread_ and 218 // Need to clear the desktop notification balloons before the io_thread_ and
219 // before the profiles, since if there are any still showing we will access 219 // before the profiles, since if there are any still showing we will access
220 // those things during teardown. 220 // those things during teardown.
221 notification_ui_manager_.reset(); 221 notification_ui_manager_.reset();
222 222
223 // Need to clear profiles (download managers) before the io_thread_. 223 // Need to clear profiles (download managers) before the io_thread_.
224 profile_manager_.reset(); 224 profile_manager_.reset();
225 225
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // then proceed with normal shutdown. 344 // then proceed with normal shutdown.
345 #if defined(USE_X11) 345 #if defined(USE_X11)
346 // Can't run a local loop on linux. Instead create a waitable event. 346 // Can't run a local loop on linux. Instead create a waitable event.
347 scoped_ptr<base::WaitableEvent> done_writing( 347 scoped_ptr<base::WaitableEvent> done_writing(
348 new base::WaitableEvent(false, false)); 348 new base::WaitableEvent(false, false));
349 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 349 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
350 base::Bind(Signal, done_writing.get())); 350 base::Bind(Signal, done_writing.get()));
351 // If all file writes haven't cleared in the timeout, leak the WaitableEvent 351 // If all file writes haven't cleared in the timeout, leak the WaitableEvent
352 // so that there's no race to reference it in Signal(). 352 // so that there's no race to reference it in Signal().
353 if (!done_writing->TimedWait( 353 if (!done_writing->TimedWait(
354 base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds))) 354 base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds))) {
355 ignore_result(done_writing.release()); 355 ignore_result(done_writing.release());
356 }
356 357
357 #elif defined(OS_WIN) 358 #elif defined(OS_WIN)
358 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 359 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
359 base::Bind(PostQuit, MessageLoop::current())); 360 base::Bind(PostQuit, MessageLoop::current()));
360 int quits_received = 0; 361 int quits_received = 0;
361 do { 362 do {
362 MessageLoop::current()->Run(); 363 MessageLoop::current()->Run();
363 ++quits_received; 364 ++quits_received;
364 } while (!g_end_session_file_thread_has_completed); 365 } while (!g_end_session_file_thread_has_completed);
365 // If we did get extra quits, then we should re-post them to the message loop. 366 // If we did get extra quits, then we should re-post them to the message loop.
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 return component_updater_.get(); 677 return component_updater_.get();
677 #endif 678 #endif
678 } 679 }
679 680
680 CRLSetFetcher* BrowserProcessImpl::crl_set_fetcher() { 681 CRLSetFetcher* BrowserProcessImpl::crl_set_fetcher() {
681 #if defined(OS_CHROMEOS) 682 #if defined(OS_CHROMEOS)
682 // There's no component updater on ChromeOS so there can't be a CRLSetFetcher 683 // There's no component updater on ChromeOS so there can't be a CRLSetFetcher
683 // either. 684 // either.
684 return NULL; 685 return NULL;
685 #else 686 #else
686 if (!crl_set_fetcher_.get()) { 687 if (!crl_set_fetcher_.get())
687 crl_set_fetcher_ = new CRLSetFetcher(); 688 crl_set_fetcher_ = new CRLSetFetcher();
688 }
689 return crl_set_fetcher_.get(); 689 return crl_set_fetcher_.get();
690 #endif 690 #endif
691 } 691 }
692 692
693 void BrowserProcessImpl::ResourceDispatcherHostCreated() { 693 void BrowserProcessImpl::ResourceDispatcherHostCreated() {
694 resource_dispatcher_host_delegate_.reset( 694 resource_dispatcher_host_delegate_.reset(
695 new ChromeResourceDispatcherHostDelegate(prerender_tracker())); 695 new ChromeResourceDispatcherHostDelegate(prerender_tracker()));
696 ResourceDispatcherHost::Get()->SetDelegate( 696 ResourceDispatcherHost::Get()->SetDelegate(
697 resource_dispatcher_host_delegate_.get()); 697 resource_dispatcher_host_delegate_.get());
698 698
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 void BrowserProcessImpl::PreMainMessageLoopRun() { 790 void BrowserProcessImpl::PreMainMessageLoopRun() {
791 #if defined(ENABLE_PLUGINS) 791 #if defined(ENABLE_PLUGINS)
792 PluginService* plugin_service = PluginService::GetInstance(); 792 PluginService* plugin_service = PluginService::GetInstance();
793 plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance()); 793 plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance());
794 plugin_service->StartWatchingPlugins(); 794 plugin_service->StartWatchingPlugins();
795 795
796 #if defined(OS_POSIX) 796 #if defined(OS_POSIX)
797 // Also find plugins in a user-specific plugins dir, 797 // Also find plugins in a user-specific plugins dir,
798 // e.g. ~/.config/chromium/Plugins. 798 // e.g. ~/.config/chromium/Plugins.
799 FilePath user_data_dir; 799 FilePath user_data_dir;
800 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { 800 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
801 plugin_service->AddExtraPluginDir(user_data_dir.Append("Plugins")); 801 plugin_service->AddExtraPluginDir(user_data_dir.Append("Plugins"));
802 }
803 #endif 802 #endif
804 803
805 #endif // defined(ENABLE_PLUGINS) 804 #endif // defined(ENABLE_PLUGINS)
806 805
807 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) 806 if (local_state()->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled))
808 ApplyDefaultBrowserPolicy(); 807 ApplyDefaultBrowserPolicy();
809 808
810 // Triggers initialization of the singleton instance on UI thread. 809 // Triggers initialization of the singleton instance on UI thread.
811 PluginFinder::GetInstance()->Init(); 810 PluginFinder::GetInstance()->Init();
812 811
813 #if defined(ENABLE_PLUGIN_INSTALLATION) 812 #if defined(ENABLE_PLUGIN_INSTALLATION)
814 if (!plugins_resource_service_) { 813 DCHECK(!plugins_resource_service_.get());
815 plugins_resource_service_ = new PluginsResourceService(local_state()); 814 plugins_resource_service_ = new PluginsResourceService(local_state());
816 plugins_resource_service_->StartAfterDelay(); 815 plugins_resource_service_->StartAfterDelay();
816 #endif
817
818 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
819 if (!command_line.HasSwitch(switches::kDisableWebResources)) {
820 DCHECK(!promo_resource_service_.get());
821 promo_resource_service_ = new PromoResourceService;
822 promo_resource_service_->StartAfterDelay();
817 } 823 }
818 #endif
819 824
820 #if !defined(OS_ANDROID) 825 #if !defined(OS_ANDROID)
821 if (browser_defaults::bookmarks_enabled && 826 if (browser_defaults::bookmarks_enabled &&
822 BookmarkPromptController::IsEnabled()) 827 BookmarkPromptController::IsEnabled()) {
823 bookmark_prompt_controller_.reset(new BookmarkPromptController()); 828 bookmark_prompt_controller_.reset(new BookmarkPromptController());
829 }
824 #endif 830 #endif
825 } 831 }
826 832
827 void BrowserProcessImpl::CreateIconManager() { 833 void BrowserProcessImpl::CreateIconManager() {
828 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); 834 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL);
829 created_icon_manager_ = true; 835 created_icon_manager_ = true;
830 icon_manager_.reset(new IconManager); 836 icon_manager_.reset(new IconManager);
831 } 837 }
832 838
833 void BrowserProcessImpl::CreateIntranetRedirectDetector() { 839 void BrowserProcessImpl::CreateIntranetRedirectDetector() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // create the service class if there was an error. 888 // create the service class if there was an error.
883 created_safe_browsing_service_ = true; 889 created_safe_browsing_service_ = true;
884 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 890 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
885 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); 891 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService();
886 safe_browsing_service_->Initialize(); 892 safe_browsing_service_->Initialize();
887 #endif 893 #endif
888 } 894 }
889 895
890 void BrowserProcessImpl::ApplyDisabledSchemesPolicy() { 896 void BrowserProcessImpl::ApplyDisabledSchemesPolicy() {
891 std::set<std::string> schemes; 897 std::set<std::string> schemes;
892 const ListValue* scheme_list = local_state_->GetList(prefs::kDisabledSchemes); 898 const ListValue* scheme_list =
899 local_state()->GetList(prefs::kDisabledSchemes);
893 for (ListValue::const_iterator iter = scheme_list->begin(); 900 for (ListValue::const_iterator iter = scheme_list->begin();
894 iter != scheme_list->end(); ++iter) { 901 iter != scheme_list->end(); ++iter) {
895 std::string scheme; 902 std::string scheme;
896 if ((*iter)->GetAsString(&scheme)) 903 if ((*iter)->GetAsString(&scheme))
897 schemes.insert(scheme); 904 schemes.insert(scheme);
898 } 905 }
899 ChildProcessSecurityPolicy::GetInstance()->RegisterDisabledSchemes(schemes); 906 ChildProcessSecurityPolicy::GetInstance()->RegisterDisabledSchemes(schemes);
900 } 907 }
901 908
902 void BrowserProcessImpl::ApplyDefaultBrowserPolicy() { 909 void BrowserProcessImpl::ApplyDefaultBrowserPolicy() {
903 if (local_state_->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) { 910 if (local_state()->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) {
904 scoped_refptr<ShellIntegration::DefaultWebClientWorker> 911 scoped_refptr<ShellIntegration::DefaultWebClientWorker>
905 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL); 912 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL);
906 set_browser_worker->StartSetAsDefault(); 913 set_browser_worker->StartSetAsDefault();
907 } 914 }
908 } 915 }
909 916
910 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { 917 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() {
911 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); 918 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt);
912 ResourceDispatcherHost::Get()->SetAllowCrossOriginAuthPrompt(value); 919 ResourceDispatcherHost::Get()->SetAllowCrossOriginAuthPrompt(value);
913 } 920 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 } 969 }
963 970
964 void BrowserProcessImpl::OnAutoupdateTimer() { 971 void BrowserProcessImpl::OnAutoupdateTimer() {
965 if (CanAutorestartForUpdate()) { 972 if (CanAutorestartForUpdate()) {
966 DLOG(WARNING) << "Detected update. Restarting browser."; 973 DLOG(WARNING) << "Detected update. Restarting browser.";
967 RestartBackgroundInstance(); 974 RestartBackgroundInstance();
968 } 975 }
969 } 976 }
970 977
971 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 978 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698