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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 return NULL; | 678 return NULL; |
| 676 } | 679 } |
| 677 | 680 |
| 678 bool BrowserProcessImpl::plugin_finder_disabled() const { | 681 bool BrowserProcessImpl::plugin_finder_disabled() const { |
| 679 return *plugin_finder_disabled_pref_; | 682 return *plugin_finder_disabled_pref_; |
| 680 } | 683 } |
| 681 | 684 |
| 682 void BrowserProcessImpl::Observe(int type, | 685 void BrowserProcessImpl::Observe(int type, |
| 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 switch (type) { |
| 686 std::string* pref = content::Details<std::string>(details).ptr(); | 689 case chrome::NOTIFICATION_PREF_CHANGED: { |
| 687 if (*pref == prefs::kDefaultBrowserSettingEnabled) { | 690 std::string* pref = content::Details<std::string>(details).ptr(); |
| 688 ApplyDefaultBrowserPolicy(); | 691 if (*pref == prefs::kDefaultBrowserSettingEnabled) { |
| 689 } else if (*pref == prefs::kDisabledSchemes) { | 692 ApplyDefaultBrowserPolicy(); |
| 690 ApplyDisabledSchemesPolicy(); | 693 } else if (*pref == prefs::kDisabledSchemes) { |
| 691 } else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { | 694 ApplyDisabledSchemesPolicy(); |
| 692 ApplyAllowCrossOriginAuthPromptPolicy(); | 695 } else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { |
| 696 ApplyAllowCrossOriginAuthPromptPolicy(); | |
| 697 } else if (*pref == prefs::kCloudPrintProxyEnabled) { | |
| 698 ApplyCloudPrintConnectorPolicy(); | |
| 699 } | |
| 700 break; | |
| 693 } | 701 } |
| 694 } else { | 702 case chrome::NOTIFICATION_PROFILE_CREATED: |
| 695 NOTREACHED(); | 703 if (local_state()->IsManagedPreference(prefs::kCloudPrintProxyEnabled)) { |
| 704 Profile* profile = content::Source<Profile>(source).ptr(); | |
| 705 ApplyCloudPrintConnectorPolicyToProfile(profile); | |
| 706 } | |
| 707 break; | |
| 708 default: | |
| 709 NOTREACHED(); | |
| 696 } | 710 } |
| 697 } | 711 } |
| 698 | 712 |
| 699 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 713 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 700 void BrowserProcessImpl::StartAutoupdateTimer() { | 714 void BrowserProcessImpl::StartAutoupdateTimer() { |
| 701 autoupdate_timer_.Start(FROM_HERE, | 715 autoupdate_timer_.Start(FROM_HERE, |
| 702 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), | 716 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), |
| 703 this, | 717 this, |
| 704 &BrowserProcessImpl::OnAutoupdateTimer); | 718 &BrowserProcessImpl::OnAutoupdateTimer); |
| 705 } | 719 } |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); | 978 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); |
| 965 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 979 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
| 966 std::max(std::min(max_per_proxy, 99), | 980 std::max(std::min(max_per_proxy, 99), |
| 967 net::ClientSocketPoolManager::max_sockets_per_group())); | 981 net::ClientSocketPoolManager::max_sockets_per_group())); |
| 968 | 982 |
| 969 // This is observed by ChildProcessSecurityPolicy, which lives in content/ | 983 // This is observed by ChildProcessSecurityPolicy, which lives in content/ |
| 970 // though, so it can't register itself. | 984 // though, so it can't register itself. |
| 971 local_state_->RegisterListPref(prefs::kDisabledSchemes); | 985 local_state_->RegisterListPref(prefs::kDisabledSchemes); |
| 972 pref_change_registrar_.Add(prefs::kDisabledSchemes, this); | 986 pref_change_registrar_.Add(prefs::kDisabledSchemes, this); |
| 973 ApplyDisabledSchemesPolicy(); | 987 ApplyDisabledSchemesPolicy(); |
| 988 | |
| 989 local_state_->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, true); | |
| 990 pref_change_registrar_.Add(prefs::kCloudPrintProxyEnabled, this); | |
| 991 notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED, | |
| 992 content::NotificationService::AllBrowserContextsAndSources()); | |
| 974 } | 993 } |
| 975 | 994 |
| 976 void BrowserProcessImpl::CreateIconManager() { | 995 void BrowserProcessImpl::CreateIconManager() { |
| 977 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); | 996 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); |
| 978 created_icon_manager_ = true; | 997 created_icon_manager_ = true; |
| 979 icon_manager_.reset(new IconManager); | 998 icon_manager_.reset(new IconManager); |
| 980 } | 999 } |
| 981 | 1000 |
| 982 void BrowserProcessImpl::CreateDevToolsManager() { | 1001 void BrowserProcessImpl::CreateDevToolsManager() { |
| 983 DCHECK(devtools_manager_.get() == NULL); | 1002 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); | 1085 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL); |
| 1067 set_browser_worker->StartSetAsDefault(); | 1086 set_browser_worker->StartSetAsDefault(); |
| 1068 } | 1087 } |
| 1069 } | 1088 } |
| 1070 | 1089 |
| 1071 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { | 1090 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { |
| 1072 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); | 1091 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); |
| 1073 resource_dispatcher_host()->set_allow_cross_origin_auth_prompt(value); | 1092 resource_dispatcher_host()->set_allow_cross_origin_auth_prompt(value); |
| 1074 } | 1093 } |
| 1075 | 1094 |
| 1095 void BrowserProcessImpl::ApplyCloudPrintConnectorPolicy() { | |
| 1096 // Search the profiles for any enabled connectors and shut them down. | |
|
Mattias Nissler (ping if slow)
2011/11/04 00:19:15
So the cloud print connector is per-profile (I was
| |
| 1097 std::vector<Profile*> profiles(profile_manager()->GetLoadedProfiles()); | |
| 1098 for (std::vector<Profile*>::iterator i = profiles.begin(); | |
| 1099 i != profiles.end(); ++i) | |
| 1100 ApplyCloudPrintConnectorPolicyToProfile(*i); | |
| 1101 } | |
| 1102 | |
| 1103 void BrowserProcessImpl::ApplyCloudPrintConnectorPolicyToProfile( | |
| 1104 Profile* profile) { | |
| 1105 if (!local_state()->GetBoolean(prefs::kCloudPrintProxyEnabled)) { | |
| 1106 std::string email; | |
| 1107 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail)) { | |
| 1108 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); | |
| 1109 if (!email.empty()) { | |
| 1110 CloudPrintProxyServiceFactory::GetForProfile(profile)-> | |
| 1111 DisableForUser(); | |
| 1112 profile->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string()); | |
| 1113 } | |
| 1114 } | |
| 1115 } | |
| 1116 } | |
| 1117 | |
| 1076 // The BrowserProcess object must outlive the file thread so we use traits | 1118 // The BrowserProcess object must outlive the file thread so we use traits |
| 1077 // which don't do any management. | 1119 // which don't do any management. |
| 1078 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl); | 1120 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl); |
| 1079 | 1121 |
| 1080 #if defined(IPC_MESSAGE_LOG_ENABLED) | 1122 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 1081 | 1123 |
| 1082 void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) { | 1124 void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) { |
| 1083 // First enable myself. | 1125 // First enable myself. |
| 1084 if (enable) | 1126 if (enable) |
| 1085 IPC::Logging::GetInstance()->Enable(); | 1127 IPC::Logging::GetInstance()->Enable(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 } | 1207 } |
| 1166 | 1208 |
| 1167 void BrowserProcessImpl::OnAutoupdateTimer() { | 1209 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 1168 if (CanAutorestartForUpdate()) { | 1210 if (CanAutorestartForUpdate()) { |
| 1169 DLOG(WARNING) << "Detected update. Restarting browser."; | 1211 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 1170 RestartBackgroundInstance(); | 1212 RestartBackgroundInstance(); |
| 1171 } | 1213 } |
| 1172 } | 1214 } |
| 1173 | 1215 |
| 1174 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1216 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |