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

Side by Side Diff: chrome/browser/policy/forwarding_policy_provider.cc

Issue 78953002: Fixes and improvements to cloud policy for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/policy/forwarding_policy_provider.h" 5 #include "chrome/browser/policy/forwarding_policy_provider.h"
6 6
7 #include "components/policy/core/common/schema_map.h" 7 #include "components/policy/core/common/schema_map.h"
8 #include "components/policy/core/common/schema_registry.h" 8 #include "components/policy/core/common/schema_registry.h"
9 9
10 namespace policy { 10 namespace policy {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 state_ = READY; 53 state_ = READY;
54 OnUpdatePolicy(delegate_); 54 OnUpdatePolicy(delegate_);
55 return; 55 return;
56 } 56 }
57 57
58 state_ = WAITING_FOR_REFRESH; 58 state_ = WAITING_FOR_REFRESH;
59 RefreshPolicies(); 59 RefreshPolicies();
60 } 60 }
61 61
62 void ForwardingPolicyProvider::OnSchemaRegistryUpdated(bool has_new_schemas) { 62 void ForwardingPolicyProvider::OnSchemaRegistryUpdated(bool has_new_schemas) {
63 if (!has_new_schemas || state_ != READY) 63 if (state_ != READY)
64 return; 64 return;
65 RefreshPolicies(); 65 if (has_new_schemas) {
66 RefreshPolicies();
67 } else {
68 // Remove the policies that were being served for the component that have
69 // been removed. This is important so that update notifications are also
70 // sent in case those component are reinstalled during the current session.
71 OnUpdatePolicy(delegate_);
72 }
66 } 73 }
67 74
68 void ForwardingPolicyProvider::OnUpdatePolicy( 75 void ForwardingPolicyProvider::OnUpdatePolicy(
69 ConfigurationPolicyProvider* provider) { 76 ConfigurationPolicyProvider* provider) {
70 DCHECK_EQ(delegate_, provider); 77 DCHECK_EQ(delegate_, provider);
71 78
72 if (state_ == WAITING_FOR_REFRESH) 79 if (state_ == WAITING_FOR_REFRESH)
73 state_ = READY; 80 state_ = READY;
74 81
75 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); 82 scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
76 if (state_ == READY) { 83 if (state_ == READY) {
77 bundle->CopyFrom(delegate_->policies()); 84 bundle->CopyFrom(delegate_->policies());
78 schema_map()->FilterBundle(bundle.get()); 85 schema_map()->FilterBundle(bundle.get());
79 } else { 86 } else {
80 // Always forward the Chrome policy, even if the components are not ready 87 // Always forward the Chrome policy, even if the components are not ready
81 // yet. 88 // yet.
82 const PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, ""); 89 const PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, "");
83 bundle->Get(chrome_ns).CopyFrom(delegate_->policies().Get(chrome_ns)); 90 bundle->Get(chrome_ns).CopyFrom(delegate_->policies().Get(chrome_ns));
84 } 91 }
85 92
86 UpdatePolicy(bundle.Pass()); 93 UpdatePolicy(bundle.Pass());
87 } 94 }
88 95
89 } // namespace policy 96 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698