OLD | NEW |
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 "extensions/browser/management_policy.h" | 5 #include "extensions/browser/management_policy.h" |
6 | 6 |
7 namespace extensions { | 7 namespace extensions { |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 return false; | 40 return false; |
41 } | 41 } |
42 | 42 |
43 bool ManagementPolicy::Provider::MustRemainDisabled( | 43 bool ManagementPolicy::Provider::MustRemainDisabled( |
44 const Extension* extension, | 44 const Extension* extension, |
45 Extension::DisableReason* reason, | 45 Extension::DisableReason* reason, |
46 base::string16* error) const { | 46 base::string16* error) const { |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
| 50 bool ManagementPolicy::Provider::MustRemainInstalled( |
| 51 const Extension* extension, |
| 52 base::string16* error) const { |
| 53 return false; |
| 54 } |
| 55 |
50 void ManagementPolicy::RegisterProvider(Provider* provider) { | 56 void ManagementPolicy::RegisterProvider(Provider* provider) { |
51 providers_.insert(provider); | 57 providers_.insert(provider); |
52 } | 58 } |
53 | 59 |
54 void ManagementPolicy::UnregisterProvider(Provider* provider) { | 60 void ManagementPolicy::UnregisterProvider(Provider* provider) { |
55 providers_.erase(provider); | 61 providers_.erase(provider); |
56 } | 62 } |
57 | 63 |
58 bool ManagementPolicy::UserMayLoad(const Extension* extension, | 64 bool ManagementPolicy::UserMayLoad(const Extension* extension, |
59 base::string16* error) const { | 65 base::string16* error) const { |
60 return ApplyToProviderList(&Provider::UserMayLoad, "Installation", | 66 return ApplyToProviderList( |
61 true, extension, error); | 67 &Provider::UserMayLoad, "Installation", true, extension, error); |
62 } | 68 } |
63 | 69 |
64 bool ManagementPolicy::UserMayModifySettings(const Extension* extension, | 70 bool ManagementPolicy::UserMayModifySettings(const Extension* extension, |
65 base::string16* error) const { | 71 base::string16* error) const { |
66 return ApplyToProviderList(&Provider::UserMayModifySettings, "Modification", | 72 return ApplyToProviderList( |
67 true, extension, error); | 73 &Provider::UserMayModifySettings, "Modification", true, extension, error); |
68 } | 74 } |
69 | 75 |
70 bool ManagementPolicy::MustRemainEnabled(const Extension* extension, | 76 bool ManagementPolicy::MustRemainEnabled(const Extension* extension, |
71 base::string16* error) const { | 77 base::string16* error) const { |
72 return ApplyToProviderList(&Provider::MustRemainEnabled, "Disabling", | 78 return ApplyToProviderList( |
73 false, extension, error); | 79 &Provider::MustRemainEnabled, "Disabling", false, extension, error); |
74 } | 80 } |
75 | 81 |
76 bool ManagementPolicy::MustRemainDisabled(const Extension* extension, | 82 bool ManagementPolicy::MustRemainDisabled(const Extension* extension, |
77 Extension::DisableReason* reason, | 83 Extension::DisableReason* reason, |
78 base::string16* error) const { | 84 base::string16* error) const { |
79 for (ProviderList::const_iterator it = providers_.begin(); | 85 for (ProviderList::const_iterator it = providers_.begin(); |
80 it != providers_.end(); ++it) | 86 it != providers_.end(); ++it) |
81 if ((*it)->MustRemainDisabled(extension, reason, error)) | 87 if ((*it)->MustRemainDisabled(extension, reason, error)) |
82 return true; | 88 return true; |
83 | 89 |
84 return false; | 90 return false; |
85 } | 91 } |
86 | 92 |
| 93 bool ManagementPolicy::MustRemainInstalled(const Extension* extension, |
| 94 base::string16* error) const { |
| 95 return ApplyToProviderList( |
| 96 &Provider::MustRemainInstalled, "Removing", false, extension, error); |
| 97 } |
| 98 |
87 void ManagementPolicy::UnregisterAllProviders() { | 99 void ManagementPolicy::UnregisterAllProviders() { |
88 providers_.clear(); | 100 providers_.clear(); |
89 } | 101 } |
90 | 102 |
91 int ManagementPolicy::GetNumProviders() const { | 103 int ManagementPolicy::GetNumProviders() const { |
92 return providers_.size(); | 104 return providers_.size(); |
93 } | 105 } |
94 | 106 |
95 bool ManagementPolicy::ApplyToProviderList(ProviderFunction function, | 107 bool ManagementPolicy::ApplyToProviderList(ProviderFunction function, |
96 const char* debug_operation_name, | 108 const char* debug_operation_name, |
(...skipping 11 matching lines...) Expand all Loading... |
108 DVLOG(1) << debug_operation_name << " of extension " << name | 120 DVLOG(1) << debug_operation_name << " of extension " << name |
109 << " (" << id << ")" | 121 << " (" << id << ")" |
110 << " prohibited by " << provider->GetDebugPolicyProviderName(); | 122 << " prohibited by " << provider->GetDebugPolicyProviderName(); |
111 return !normal_result; | 123 return !normal_result; |
112 } | 124 } |
113 } | 125 } |
114 return normal_result; | 126 return normal_result; |
115 } | 127 } |
116 | 128 |
117 } // namespace extensions | 129 } // namespace extensions |
OLD | NEW |