Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 27 matching lines...) Expand all Loading... | |
| 38 #include "chrome/browser/metrics/thread_watcher.h" | 38 #include "chrome/browser/metrics/thread_watcher.h" |
| 39 #include "chrome/browser/net/chrome_net_log.h" | 39 #include "chrome/browser/net/chrome_net_log.h" |
| 40 #include "chrome/browser/net/crl_set_fetcher.h" | 40 #include "chrome/browser/net/crl_set_fetcher.h" |
| 41 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 41 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 42 #include "chrome/browser/notifications/notification_ui_manager.h" | 42 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 43 #include "chrome/browser/policy/browser_policy_connector.h" | 43 #include "chrome/browser/policy/browser_policy_connector.h" |
| 44 #include "chrome/browser/prefs/browser_prefs.h" | 44 #include "chrome/browser/prefs/browser_prefs.h" |
| 45 #include "chrome/browser/prefs/pref_service.h" | 45 #include "chrome/browser/prefs/pref_service.h" |
| 46 #include "chrome/browser/prerender/prerender_tracker.h" | 46 #include "chrome/browser/prerender/prerender_tracker.h" |
| 47 #include "chrome/browser/printing/background_printing_manager.h" | 47 #include "chrome/browser/printing/background_printing_manager.h" |
| 48 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | |
| 49 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" | |
| 48 #include "chrome/browser/printing/print_job_manager.h" | 50 #include "chrome/browser/printing/print_job_manager.h" |
| 49 #include "chrome/browser/printing/print_preview_tab_controller.h" | 51 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 50 #include "chrome/browser/profiles/profile_manager.h" | 52 #include "chrome/browser/profiles/profile_manager.h" |
| 51 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" | 53 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" |
| 52 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 54 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 53 #include "chrome/browser/shell_integration.h" | 55 #include "chrome/browser/shell_integration.h" |
| 54 #include "chrome/browser/sidebar/sidebar_manager.h" | 56 #include "chrome/browser/sidebar/sidebar_manager.h" |
| 55 #include "chrome/browser/status_icons/status_tray.h" | 57 #include "chrome/browser/status_icons/status_tray.h" |
| 56 #include "chrome/browser/tab_closeable_state_watcher.h" | 58 #include "chrome/browser/tab_closeable_state_watcher.h" |
| 57 #include "chrome/browser/tab_contents/thumbnail_generator.h" | 59 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 77 #include "content/browser/download/download_status_updater.h" | 79 #include "content/browser/download/download_status_updater.h" |
| 78 #include "content/browser/download/mhtml_generation_manager.h" | 80 #include "content/browser/download/mhtml_generation_manager.h" |
| 79 #include "content/browser/download/save_file_manager.h" | 81 #include "content/browser/download/save_file_manager.h" |
| 80 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 82 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 81 #include "content/browser/net/browser_online_state_observer.h" | 83 #include "content/browser/net/browser_online_state_observer.h" |
| 82 #include "content/browser/plugin_service.h" | 84 #include "content/browser/plugin_service.h" |
| 83 #include "content/browser/renderer_host/render_process_host.h" | 85 #include "content/browser/renderer_host/render_process_host.h" |
| 84 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 86 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 85 #include "content/public/browser/browser_thread.h" | 87 #include "content/public/browser/browser_thread.h" |
| 86 #include "content/public/browser/notification_details.h" | 88 #include "content/public/browser/notification_details.h" |
| 89 #include "content/public/browser/notification_service.h" | |
| 87 #include "content/public/common/url_fetcher.h" | 90 #include "content/public/common/url_fetcher.h" |
| 88 #include "ipc/ipc_logging.h" | 91 #include "ipc/ipc_logging.h" |
| 89 #include "net/socket/client_socket_pool_manager.h" | 92 #include "net/socket/client_socket_pool_manager.h" |
| 90 #include "net/url_request/url_request_context_getter.h" | 93 #include "net/url_request/url_request_context_getter.h" |
| 91 #include "ui/base/clipboard/clipboard.h" | 94 #include "ui/base/clipboard/clipboard.h" |
| 92 #include "ui/base/l10n/l10n_util.h" | 95 #include "ui/base/l10n/l10n_util.h" |
| 93 #include "webkit/plugins/npapi/plugin_list.h" | 96 #include "webkit/plugins/npapi/plugin_list.h" |
| 94 | 97 |
| 95 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
| 96 #include "views/focus/view_storage.h" | 99 #include "views/focus/view_storage.h" |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 const content::NotificationSource& source, | 686 const content::NotificationSource& source, |
| 684 const content::NotificationDetails& details) { | 687 const content::NotificationDetails& details) { |
| 685 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 688 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 686 std::string* pref = content::Details<std::string>(details).ptr(); | 689 std::string* pref = content::Details<std::string>(details).ptr(); |
| 687 if (*pref == prefs::kDefaultBrowserSettingEnabled) { | 690 if (*pref == prefs::kDefaultBrowserSettingEnabled) { |
| 688 ApplyDefaultBrowserPolicy(); | 691 ApplyDefaultBrowserPolicy(); |
| 689 } else if (*pref == prefs::kDisabledSchemes) { | 692 } else if (*pref == prefs::kDisabledSchemes) { |
| 690 ApplyDisabledSchemesPolicy(); | 693 ApplyDisabledSchemesPolicy(); |
| 691 } else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { | 694 } else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { |
| 692 ApplyAllowCrossOriginAuthPromptPolicy(); | 695 ApplyAllowCrossOriginAuthPromptPolicy(); |
| 696 } else if (*pref == prefs::kCloudPrintProxyEnabled) { | |
| 697 ApplyCloudPrintConnectorPolicy(); | |
| 698 } | |
| 699 } else if (type == chrome::NOTIFICATION_PROFILE_CREATED) { | |
|
Peter Kasting
2011/11/02 22:09:59
Nit: I would either do:
if (type == chrome::NOTIF
| |
| 700 if (local_state()->IsManagedPreference(prefs::kCloudPrintProxyEnabled)) { | |
| 701 Profile* profile = content::Source<Profile>(source).ptr(); | |
| 702 if (profile) | |
|
Peter Kasting
2011/11/02 22:09:59
Can this ever be NULL? If not then don't add a co
| |
| 703 ApplyCloudPrintConnectorPolicyToProfile(profile); | |
| 693 } | 704 } |
| 694 } else { | 705 } else { |
| 695 NOTREACHED(); | 706 NOTREACHED(); |
| 696 } | 707 } |
| 697 } | 708 } |
| 698 | 709 |
| 699 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 710 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 700 void BrowserProcessImpl::StartAutoupdateTimer() { | 711 void BrowserProcessImpl::StartAutoupdateTimer() { |
| 701 autoupdate_timer_.Start(FROM_HERE, | 712 autoupdate_timer_.Start(FROM_HERE, |
| 702 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), | 713 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); | 975 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); |
| 965 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 976 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
| 966 std::max(std::min(max_per_proxy, 99), | 977 std::max(std::min(max_per_proxy, 99), |
| 967 net::ClientSocketPoolManager::max_sockets_per_group())); | 978 net::ClientSocketPoolManager::max_sockets_per_group())); |
| 968 | 979 |
| 969 // This is observed by ChildProcessSecurityPolicy, which lives in content/ | 980 // This is observed by ChildProcessSecurityPolicy, which lives in content/ |
| 970 // though, so it can't register itself. | 981 // though, so it can't register itself. |
| 971 local_state_->RegisterListPref(prefs::kDisabledSchemes); | 982 local_state_->RegisterListPref(prefs::kDisabledSchemes); |
| 972 pref_change_registrar_.Add(prefs::kDisabledSchemes, this); | 983 pref_change_registrar_.Add(prefs::kDisabledSchemes, this); |
| 973 ApplyDisabledSchemesPolicy(); | 984 ApplyDisabledSchemesPolicy(); |
| 985 | |
| 986 local_state_->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, true); | |
| 987 pref_change_registrar_.Add(prefs::kCloudPrintProxyEnabled, this); | |
| 988 notification_registrar_.Add( | |
| 989 this, chrome::NOTIFICATION_PROFILE_CREATED, | |
|
Peter Kasting
2011/11/02 22:09:59
Nit: These args can go on the prior line
| |
| 990 content::NotificationService::AllBrowserContextsAndSources()); | |
| 974 } | 991 } |
| 975 | 992 |
| 976 void BrowserProcessImpl::CreateIconManager() { | 993 void BrowserProcessImpl::CreateIconManager() { |
| 977 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); | 994 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); |
| 978 created_icon_manager_ = true; | 995 created_icon_manager_ = true; |
| 979 icon_manager_.reset(new IconManager); | 996 icon_manager_.reset(new IconManager); |
| 980 } | 997 } |
| 981 | 998 |
| 982 void BrowserProcessImpl::CreateDevToolsManager() { | 999 void BrowserProcessImpl::CreateDevToolsManager() { |
| 983 DCHECK(devtools_manager_.get() == NULL); | 1000 DCHECK(devtools_manager_.get() == NULL); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1066 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL); | 1083 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL); |
| 1067 set_browser_worker->StartSetAsDefault(); | 1084 set_browser_worker->StartSetAsDefault(); |
| 1068 } | 1085 } |
| 1069 } | 1086 } |
| 1070 | 1087 |
| 1071 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { | 1088 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { |
| 1072 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); | 1089 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); |
| 1073 resource_dispatcher_host()->set_allow_cross_origin_auth_prompt(value); | 1090 resource_dispatcher_host()->set_allow_cross_origin_auth_prompt(value); |
| 1074 } | 1091 } |
| 1075 | 1092 |
| 1093 void BrowserProcessImpl::ApplyCloudPrintConnectorPolicy() { | |
| 1094 // Search the profiles for any enabled connectors and shut them down. | |
| 1095 ProfileManager* pm = profile_manager(); | |
|
Peter Kasting
2011/11/02 22:09:59
Nit: Could just roll this into the next line
| |
| 1096 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); | |
| 1097 for (size_t i = 0; i < profiles.size(); ++i) | |
|
Peter Kasting
2011/11/02 22:09:59
Nit: I suggest using an iterator (rest of this fil
| |
| 1098 ApplyCloudPrintConnectorPolicyToProfile(profiles[i]); | |
| 1099 } | |
| 1100 | |
| 1101 void BrowserProcessImpl::ApplyCloudPrintConnectorPolicyToProfile( | |
| 1102 Profile* profile) { | |
| 1103 if (!local_state()->GetBoolean(prefs::kCloudPrintProxyEnabled)) { | |
| 1104 std::string email; | |
| 1105 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail)) { | |
| 1106 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); | |
| 1107 if (!email.empty()) { | |
| 1108 CloudPrintProxyServiceFactory::GetForProfile(profile)-> | |
| 1109 DisableForUser(); | |
| 1110 profile->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string()); | |
| 1111 } | |
| 1112 } | |
| 1113 } | |
| 1114 } | |
| 1115 | |
| 1076 // The BrowserProcess object must outlive the file thread so we use traits | 1116 // The BrowserProcess object must outlive the file thread so we use traits |
| 1077 // which don't do any management. | 1117 // which don't do any management. |
| 1078 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl); | 1118 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl); |
| 1079 | 1119 |
| 1080 #if defined(IPC_MESSAGE_LOG_ENABLED) | 1120 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 1081 | 1121 |
| 1082 void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) { | 1122 void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) { |
| 1083 // First enable myself. | 1123 // First enable myself. |
| 1084 if (enable) | 1124 if (enable) |
| 1085 IPC::Logging::GetInstance()->Enable(); | 1125 IPC::Logging::GetInstance()->Enable(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 } | 1205 } |
| 1166 | 1206 |
| 1167 void BrowserProcessImpl::OnAutoupdateTimer() { | 1207 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 1168 if (CanAutorestartForUpdate()) { | 1208 if (CanAutorestartForUpdate()) { |
| 1169 DLOG(WARNING) << "Detected update. Restarting browser."; | 1209 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 1170 RestartBackgroundInstance(); | 1210 RestartBackgroundInstance(); |
| 1171 } | 1211 } |
| 1172 } | 1212 } |
| 1173 | 1213 |
| 1174 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1214 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |