Index: chrome/browser/browser_process_impl.cc |
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc |
index 55cdd5b33901b5209c1aa9614e8e6d5df25ad4aa..66a164c4574152d4593f17804a3d6dc6bf936e28 100644 |
--- a/chrome/browser/browser_process_impl.cc |
+++ b/chrome/browser/browser_process_impl.cc |
@@ -45,6 +45,8 @@ |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/prerender/prerender_tracker.h" |
#include "chrome/browser/printing/background_printing_manager.h" |
+#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
+#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h" |
#include "chrome/browser/printing/print_job_manager.h" |
#include "chrome/browser/printing/print_preview_tab_controller.h" |
#include "chrome/browser/profiles/profile_manager.h" |
@@ -84,6 +86,7 @@ |
#include "content/browser/renderer_host/resource_dispatcher_host.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_details.h" |
+#include "content/public/browser/notification_service.h" |
#include "content/public/common/url_fetcher.h" |
#include "ipc/ipc_logging.h" |
#include "net/socket/client_socket_pool_manager.h" |
@@ -690,6 +693,14 @@ void BrowserProcessImpl::Observe(int type, |
ApplyDisabledSchemesPolicy(); |
} else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { |
ApplyAllowCrossOriginAuthPromptPolicy(); |
+ } else if (*pref == prefs::kCloudPrintProxyEnabled) { |
+ ApplyCloudPrintConnectorPolicy(); |
+ } |
+ } else if (type == chrome::NOTIFICATION_PROFILE_CREATED) { |
Peter Kasting
2011/11/02 22:09:59
Nit: I would either do:
if (type == chrome::NOTIF
|
+ if (local_state()->IsManagedPreference(prefs::kCloudPrintProxyEnabled)) { |
+ Profile* profile = content::Source<Profile>(source).ptr(); |
+ if (profile) |
Peter Kasting
2011/11/02 22:09:59
Can this ever be NULL? If not then don't add a co
|
+ ApplyCloudPrintConnectorPolicyToProfile(profile); |
} |
} else { |
NOTREACHED(); |
@@ -971,6 +982,12 @@ void BrowserProcessImpl::CreateLocalState() { |
local_state_->RegisterListPref(prefs::kDisabledSchemes); |
pref_change_registrar_.Add(prefs::kDisabledSchemes, this); |
ApplyDisabledSchemesPolicy(); |
+ |
+ local_state_->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, true); |
+ pref_change_registrar_.Add(prefs::kCloudPrintProxyEnabled, this); |
+ notification_registrar_.Add( |
+ this, chrome::NOTIFICATION_PROFILE_CREATED, |
Peter Kasting
2011/11/02 22:09:59
Nit: These args can go on the prior line
|
+ content::NotificationService::AllBrowserContextsAndSources()); |
} |
void BrowserProcessImpl::CreateIconManager() { |
@@ -1073,6 +1090,29 @@ void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { |
resource_dispatcher_host()->set_allow_cross_origin_auth_prompt(value); |
} |
+void BrowserProcessImpl::ApplyCloudPrintConnectorPolicy() { |
+ // Search the profiles for any enabled connectors and shut them down. |
+ ProfileManager* pm = profile_manager(); |
Peter Kasting
2011/11/02 22:09:59
Nit: Could just roll this into the next line
|
+ std::vector<Profile*> profiles(pm->GetLoadedProfiles()); |
+ 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
|
+ ApplyCloudPrintConnectorPolicyToProfile(profiles[i]); |
+} |
+ |
+void BrowserProcessImpl::ApplyCloudPrintConnectorPolicyToProfile( |
+ Profile* profile) { |
+ if (!local_state()->GetBoolean(prefs::kCloudPrintProxyEnabled)) { |
+ std::string email; |
+ if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail)) { |
+ email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); |
+ if (!email.empty()) { |
+ CloudPrintProxyServiceFactory::GetForProfile(profile)-> |
+ DisableForUser(); |
+ profile->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string()); |
+ } |
+ } |
+ } |
+} |
+ |
// The BrowserProcess object must outlive the file thread so we use traits |
// which don't do any management. |
DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl); |