Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / extensions / browser / test_management_policy.cc
blob77ec19132f2a09db6fe54d4173dc29a9c4806d38
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
3 // found in the LICENSE file.
5 #include "extensions/browser/test_management_policy.h"
7 #include "base/strings/utf_string_conversions.h"
9 namespace extensions {
11 TestManagementPolicyProvider::TestManagementPolicyProvider()
12 : may_load_(true),
13 may_modify_status_(true),
14 must_remain_enabled_(false),
15 must_remain_disabled_(false),
16 disable_reason_(Extension::DISABLE_NONE) {
17 error_message_ = base::UTF8ToUTF16(expected_error());
20 TestManagementPolicyProvider::TestManagementPolicyProvider(
21 int prohibited_actions) {
22 SetProhibitedActions(prohibited_actions);
23 error_message_ = base::UTF8ToUTF16(expected_error());
26 void TestManagementPolicyProvider::SetProhibitedActions(
27 int prohibited_actions) {
28 may_load_ = (prohibited_actions & PROHIBIT_LOAD) == 0;
29 may_modify_status_ = (prohibited_actions & PROHIBIT_MODIFY_STATUS) == 0;
30 must_remain_enabled_ = (prohibited_actions & MUST_REMAIN_ENABLED) != 0;
31 must_remain_disabled_ = (prohibited_actions & MUST_REMAIN_DISABLED) != 0;
34 void TestManagementPolicyProvider::SetDisableReason(
35 Extension::DisableReason reason) {
36 disable_reason_ = reason;
39 std::string TestManagementPolicyProvider::GetDebugPolicyProviderName() const {
40 return "the test management policy provider";
43 bool TestManagementPolicyProvider::UserMayLoad(const Extension* extension,
44 base::string16* error) const {
45 if (error && !may_load_)
46 *error = error_message_;
47 return may_load_;
50 bool TestManagementPolicyProvider::UserMayModifySettings(
51 const Extension* extension, base::string16* error) const {
52 if (error && !may_modify_status_)
53 *error = error_message_;
54 return may_modify_status_;
57 bool TestManagementPolicyProvider::MustRemainEnabled(const Extension* extension,
58 base::string16* error)
59 const {
60 if (error && must_remain_enabled_)
61 *error = error_message_;
62 return must_remain_enabled_;
65 bool TestManagementPolicyProvider::MustRemainDisabled(
66 const Extension* extension,
67 Extension::DisableReason* reason,
68 base::string16* error) const {
69 if (must_remain_disabled_) {
70 if (error)
71 *error = error_message_;
72 if (reason)
73 *reason = disable_reason_;
75 return must_remain_disabled_;
79 } // namespace extensions