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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_content_client.h" | 68 #include "chrome/common/chrome_content_client.h" |
68 #include "chrome/common/chrome_notification_types.h" | 69 #include "chrome/common/chrome_notification_types.h" |
69 #include "chrome/common/chrome_paths.h" | 70 #include "chrome/common/chrome_paths.h" |
70 #include "chrome/common/chrome_switches.h" | 71 #include "chrome/common/chrome_switches.h" |
71 #include "chrome/common/extensions/extension_l10n_util.h" | 72 #include "chrome/common/extensions/extension_l10n_util.h" |
72 #include "chrome/common/extensions/extension_resource.h" | 73 #include "chrome/common/extensions/extension_resource.h" |
73 #include "chrome/common/pref_names.h" | 74 #include "chrome/common/pref_names.h" |
74 #include "chrome/common/switch_utils.h" | 75 #include "chrome/common/switch_utils.h" |
75 #include "chrome/common/url_constants.h" | 76 #include "chrome/common/url_constants.h" |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 local_state_->RegisterBooleanPref(prefs::kRestartSwitchMode, false); | 784 local_state_->RegisterBooleanPref(prefs::kRestartSwitchMode, false); |
784 #endif | 785 #endif |
785 } | 786 } |
786 | 787 |
787 void BrowserProcessImpl::PreCreateThreads() { | 788 void BrowserProcessImpl::PreCreateThreads() { |
788 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(), | 789 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(), |
789 extension_event_router_forwarder_.get())); | 790 extension_event_router_forwarder_.get())); |
790 } | 791 } |
791 | 792 |
792 void BrowserProcessImpl::PreMainMessageLoopRun() { | 793 void BrowserProcessImpl::PreMainMessageLoopRun() { |
794 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
795 | |
793 #if defined(ENABLE_PLUGINS) | 796 #if defined(ENABLE_PLUGINS) |
794 PluginService* plugin_service = PluginService::GetInstance(); | 797 PluginService* plugin_service = PluginService::GetInstance(); |
795 plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance()); | 798 plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance()); |
796 plugin_service->StartWatchingPlugins(); | 799 plugin_service->StartWatchingPlugins(); |
797 | 800 |
798 // Register the internal Flash if available. | 801 // Register the internal Flash if available. |
799 FilePath path; | 802 FilePath path; |
800 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 803 if (!command_line.HasSwitch(switches::kDisableInternalFlash) && |
801 switches::kDisableInternalFlash) && | |
802 PathService::Get(chrome::FILE_FLASH_PLUGIN_EXISTING, &path)) { | 804 PathService::Get(chrome::FILE_FLASH_PLUGIN_EXISTING, &path)) { |
803 plugin_service->AddExtraPluginPath(path); | 805 plugin_service->AddExtraPluginPath(path); |
804 } | 806 } |
805 | 807 |
806 // Register bundled Pepper Flash if available. | 808 // Register bundled Pepper Flash if available. |
807 content::PepperPluginInfo plugin; | 809 content::PepperPluginInfo plugin; |
808 bool add_at_beginning = false; | 810 bool add_at_beginning = false; |
809 chrome::ChromeContentClient* content_client = | 811 chrome::ChromeContentClient* content_client = |
810 static_cast<chrome::ChromeContentClient*>(content::GetContentClient()); | 812 static_cast<chrome::ChromeContentClient*>(content::GetContentClient()); |
811 if (content_client->GetBundledFieldTrialPepperFlash(&plugin, | 813 if (content_client->GetBundledFieldTrialPepperFlash(&plugin, |
812 &add_at_beginning)) { | 814 &add_at_beginning)) { |
813 plugin_service->RegisterInternalPlugin(plugin.ToWebPluginInfo(), | 815 plugin_service->RegisterInternalPlugin(plugin.ToWebPluginInfo(), |
814 add_at_beginning); | 816 add_at_beginning); |
815 } | 817 } |
816 | 818 |
817 #if defined(OS_POSIX) | 819 #if defined(OS_POSIX) |
818 // Also find plugins in a user-specific plugins dir, | 820 // Also find plugins in a user-specific plugins dir, |
819 // e.g. ~/.config/chromium/Plugins. | 821 // e.g. ~/.config/chromium/Plugins. |
820 FilePath user_data_dir; | 822 FilePath user_data_dir; |
821 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 823 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
822 plugin_service->AddExtraPluginDir(user_data_dir.Append("Plugins")); | 824 plugin_service->AddExtraPluginDir(user_data_dir.Append("Plugins")); |
823 } | 825 } |
824 #endif | 826 #endif |
825 | 827 |
826 #endif // defined(ENABLE_PLUGINS) | 828 #endif // defined(ENABLE_PLUGINS) |
827 | 829 |
828 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) | 830 if (local_state()->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) |
829 ApplyDefaultBrowserPolicy(); | 831 ApplyDefaultBrowserPolicy(); |
830 | 832 |
831 // Triggers initialization of the singleton instance on UI thread. | 833 // Triggers initialization of the singleton instance on UI thread. |
832 PluginFinder::GetInstance()->Init(); | 834 PluginFinder::GetInstance()->Init(); |
833 | 835 |
834 #if defined(ENABLE_PLUGIN_INSTALLATION) | 836 #if defined(ENABLE_PLUGIN_INSTALLATION) |
835 if (!plugins_resource_service_) { | 837 if (!plugins_resource_service_) { |
836 plugins_resource_service_ = new PluginsResourceService(local_state()); | 838 plugins_resource_service_ = new PluginsResourceService(local_state()); |
837 plugins_resource_service_->StartAfterDelay(); | 839 plugins_resource_service_->StartAfterDelay(); |
838 } | 840 } |
839 #endif | 841 #endif |
840 | 842 |
843 if (!command_line.HasSwitch(switches::kDisableWebResources) && | |
844 !promo_resource_service_) { | |
Bernhard Bauer
2012/12/31 11:51:52
When can it happen that |promo_resource_service_|
Dan Beam
2013/01/02 04:36:35
I am not sure, I was just following the plugins se
Bernhard Bauer
2013/01/02 10:57:44
It's probably unnecessary there as well. Feel free
jam
2013/01/02 15:59:00
I don't see where pluginservice is null checked? i
Dan Beam
2013/01/02 18:10:32
sorry, I meant L837:
if (!plugins_resource_serv
jam
2013/01/02 18:14:55
that seems to be the only place that creates Plugi
| |
845 promo_resource_service_ = new PromoResourceService(local_state()); | |
846 promo_resource_service_->StartAfterDelay(); | |
847 } | |
848 | |
841 #if !defined(OS_ANDROID) | 849 #if !defined(OS_ANDROID) |
842 if (browser_defaults::bookmarks_enabled && | 850 if (browser_defaults::bookmarks_enabled && |
843 BookmarkPromptController::IsEnabled()) | 851 BookmarkPromptController::IsEnabled()) |
844 bookmark_prompt_controller_.reset(new BookmarkPromptController()); | 852 bookmark_prompt_controller_.reset(new BookmarkPromptController()); |
845 #endif | 853 #endif |
846 } | 854 } |
847 | 855 |
848 void BrowserProcessImpl::CreateIconManager() { | 856 void BrowserProcessImpl::CreateIconManager() { |
849 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); | 857 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); |
850 created_icon_manager_ = true; | 858 created_icon_manager_ = true; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 // create the service class if there was an error. | 911 // create the service class if there was an error. |
904 created_safe_browsing_service_ = true; | 912 created_safe_browsing_service_ = true; |
905 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 913 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
906 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); | 914 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); |
907 safe_browsing_service_->Initialize(); | 915 safe_browsing_service_->Initialize(); |
908 #endif | 916 #endif |
909 } | 917 } |
910 | 918 |
911 void BrowserProcessImpl::ApplyDisabledSchemesPolicy() { | 919 void BrowserProcessImpl::ApplyDisabledSchemesPolicy() { |
912 std::set<std::string> schemes; | 920 std::set<std::string> schemes; |
913 const ListValue* scheme_list = local_state_->GetList(prefs::kDisabledSchemes); | 921 const ListValue* scheme_list = |
922 local_state()->GetList(prefs::kDisabledSchemes); | |
914 for (ListValue::const_iterator iter = scheme_list->begin(); | 923 for (ListValue::const_iterator iter = scheme_list->begin(); |
915 iter != scheme_list->end(); ++iter) { | 924 iter != scheme_list->end(); ++iter) { |
916 std::string scheme; | 925 std::string scheme; |
917 if ((*iter)->GetAsString(&scheme)) | 926 if ((*iter)->GetAsString(&scheme)) |
918 schemes.insert(scheme); | 927 schemes.insert(scheme); |
919 } | 928 } |
920 ChildProcessSecurityPolicy::GetInstance()->RegisterDisabledSchemes(schemes); | 929 ChildProcessSecurityPolicy::GetInstance()->RegisterDisabledSchemes(schemes); |
921 } | 930 } |
922 | 931 |
923 void BrowserProcessImpl::ApplyDefaultBrowserPolicy() { | 932 void BrowserProcessImpl::ApplyDefaultBrowserPolicy() { |
924 if (local_state_->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) { | 933 if (local_state()->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) { |
925 scoped_refptr<ShellIntegration::DefaultWebClientWorker> | 934 scoped_refptr<ShellIntegration::DefaultWebClientWorker> |
926 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL); | 935 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL); |
927 set_browser_worker->StartSetAsDefault(); | 936 set_browser_worker->StartSetAsDefault(); |
928 } | 937 } |
929 } | 938 } |
930 | 939 |
931 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { | 940 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { |
932 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); | 941 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); |
933 ResourceDispatcherHost::Get()->SetAllowCrossOriginAuthPrompt(value); | 942 ResourceDispatcherHost::Get()->SetAllowCrossOriginAuthPrompt(value); |
934 } | 943 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
983 } | 992 } |
984 | 993 |
985 void BrowserProcessImpl::OnAutoupdateTimer() { | 994 void BrowserProcessImpl::OnAutoupdateTimer() { |
986 if (CanAutorestartForUpdate()) { | 995 if (CanAutorestartForUpdate()) { |
987 DLOG(WARNING) << "Detected update. Restarting browser."; | 996 DLOG(WARNING) << "Detected update. Restarting browser."; |
988 RestartBackgroundInstance(); | 997 RestartBackgroundInstance(); |
989 } | 998 } |
990 } | 999 } |
991 | 1000 |
992 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1001 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |