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..b7b9572ee7741b3e4a54aeb8dc36f54ece7b1b7b 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" |
@@ -682,17 +685,28 @@ bool BrowserProcessImpl::plugin_finder_disabled() const { |
void BrowserProcessImpl::Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
- if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
- std::string* pref = content::Details<std::string>(details).ptr(); |
- if (*pref == prefs::kDefaultBrowserSettingEnabled) { |
- ApplyDefaultBrowserPolicy(); |
- } else if (*pref == prefs::kDisabledSchemes) { |
- ApplyDisabledSchemesPolicy(); |
- } else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { |
- ApplyAllowCrossOriginAuthPromptPolicy(); |
+ switch (type) { |
+ case chrome::NOTIFICATION_PREF_CHANGED: { |
+ std::string* pref = content::Details<std::string>(details).ptr(); |
+ if (*pref == prefs::kDefaultBrowserSettingEnabled) { |
+ ApplyDefaultBrowserPolicy(); |
+ } else if (*pref == prefs::kDisabledSchemes) { |
+ ApplyDisabledSchemesPolicy(); |
+ } else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { |
+ ApplyAllowCrossOriginAuthPromptPolicy(); |
+ } else if (*pref == prefs::kCloudPrintProxyEnabled) { |
+ ApplyCloudPrintConnectorPolicy(); |
+ } |
+ break; |
} |
- } else { |
- NOTREACHED(); |
+ case chrome::NOTIFICATION_PROFILE_CREATED: |
+ if (local_state()->IsManagedPreference(prefs::kCloudPrintProxyEnabled)) { |
+ Profile* profile = content::Source<Profile>(source).ptr(); |
+ ApplyCloudPrintConnectorPolicyToProfile(profile); |
+ } |
+ break; |
+ default: |
+ NOTREACHED(); |
} |
} |
@@ -971,6 +985,11 @@ 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, |
+ content::NotificationService::AllBrowserContextsAndSources()); |
} |
void BrowserProcessImpl::CreateIconManager() { |
@@ -1073,6 +1092,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. |
Mattias Nissler (ping if slow)
2011/11/04 00:19:15
So the cloud print connector is per-profile (I was
|
+ std::vector<Profile*> profiles(profile_manager()->GetLoadedProfiles()); |
+ for (std::vector<Profile*>::iterator i = profiles.begin(); |
+ i != profiles.end(); ++i) |
+ ApplyCloudPrintConnectorPolicyToProfile(*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); |