Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3766)

Unified Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 10236003: Added RefreshPolicies to PolicyService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/automation/automation_provider_observers.cc
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 3ec6343e49e2b55947c225f64be46eec5ae17ff6..26a5d2d33e198ce428673def235419509eaa5291 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -43,7 +43,6 @@
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/password_manager/password_store_change.h"
-#include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
#include "chrome/browser/search_engines/template_url_service.h"
@@ -2947,92 +2946,6 @@ void BrowserOpenedWithNewProfileNotificationObserver::Observe(
}
}
-#if defined(ENABLE_CONFIGURATION_POLICY)
-
-PolicyUpdatesObserver::PolicyUpdatesObserver(
- AutomationProvider* automation,
- IPC::Message* reply_message,
- policy::BrowserPolicyConnector* browser_policy_connector)
- : automation_(automation->AsWeakPtr()),
- reply_message_(reply_message) {
- policy::ConfigurationPolicyProvider* providers[] = {
- browser_policy_connector->GetManagedCloudProvider(),
- browser_policy_connector->GetManagedPlatformProvider(),
- browser_policy_connector->GetRecommendedCloudProvider(),
- browser_policy_connector->GetRecommendedPlatformProvider(),
- };
- for (size_t i = 0; i < arraysize(providers); ++i) {
- if (providers[i]) {
- registrars_.push_back(new policy::ConfigurationPolicyObserverRegistrar);
- registrars_.back()->Init(providers[i], this);
- }
- }
- MaybeReply();
-}
-
-PolicyUpdatesObserver::~PolicyUpdatesObserver() {}
-
-// static
-void PolicyUpdatesObserver::PostCallbackAfterPolicyUpdates(
- const base::Closure& callback) {
- // Some policies (e.g. URLBlacklist) post tasks to other message loops before
- // they start enforcing updated policy values; make sure those tasks have
- // finished after a policy update.
- // Updates of the URLBlacklist are done on IO, after building the blacklist
- // on FILE, which is initiated from IO.
- PostTask(BrowserThread::IO,
- base::Bind(&PostTask, BrowserThread::FILE,
- base::Bind(&PostTask, BrowserThread::IO,
- base::Bind(&PostTask, BrowserThread::UI, callback))));
-}
-
-void PolicyUpdatesObserver::OnUpdatePolicy(
- policy::ConfigurationPolicyProvider* provider) {
- std::vector<policy::ConfigurationPolicyObserverRegistrar*>::iterator it;
- for (it = registrars_.begin(); it != registrars_.end(); ++it) {
- if ((*it)->provider() == provider) {
- delete *it;
- registrars_.erase(it);
- MaybeReply();
- return;
- }
- }
-}
-
-void PolicyUpdatesObserver::OnProviderGoingAway(
- policy::ConfigurationPolicyProvider* provider) {
- STLDeleteElements(&registrars_);
- if (automation_) {
- AutomationJSONReply(automation_, reply_message_.release()).SendError(
- "Policy provider went away.");
- }
- delete this;
-}
-
-void PolicyUpdatesObserver::MaybeReply() {
- if (registrars_.empty()) {
- PostCallbackAfterPolicyUpdates(
- base::Bind(&PolicyUpdatesObserver::Reply, base::Owned(this)));
- }
-}
-
-void PolicyUpdatesObserver::Reply() {
- if (automation_) {
- AutomationJSONReply(
- automation_, reply_message_.release()).SendSuccess(NULL);
- }
- // Reply() is only called from MaybeReply(), which makes the callback own
- // |this|; so |this| will be deleted once this method returns.
-}
-
-// static
-void PolicyUpdatesObserver::PostTask(content::BrowserThread::ID id,
- const base::Closure& callback) {
- content::BrowserThread::PostTask(id, FROM_HERE, callback);
-}
-
-#endif // defined(ENABLE_CONFIGURATION_POLICY)
-
ExtensionPopupObserver::ExtensionPopupObserver(
AutomationProvider* automation,
IPC::Message* reply_message,
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.h ('k') | chrome/browser/automation/testing_automation_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698