| 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/test_management_policy.h" | 5 #include "extensions/browser/test_management_policy.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 | 10 |
| 11 TestManagementPolicyProvider::TestManagementPolicyProvider() | 11 TestManagementPolicyProvider::TestManagementPolicyProvider() |
| 12 : may_load_(true), | 12 : may_load_(true), |
| 13 may_modify_status_(true), | 13 may_modify_status_(true), |
| 14 must_remain_enabled_(false), | 14 must_remain_enabled_(false), |
| 15 must_remain_disabled_(false), | 15 must_remain_disabled_(false), |
| 16 must_remain_installed_(false), |
| 16 disable_reason_(Extension::DISABLE_NONE) { | 17 disable_reason_(Extension::DISABLE_NONE) { |
| 17 error_message_ = base::UTF8ToUTF16(expected_error()); | 18 error_message_ = base::UTF8ToUTF16(expected_error()); |
| 18 } | 19 } |
| 19 | 20 |
| 20 TestManagementPolicyProvider::TestManagementPolicyProvider( | 21 TestManagementPolicyProvider::TestManagementPolicyProvider( |
| 21 int prohibited_actions) { | 22 int prohibited_actions) { |
| 22 SetProhibitedActions(prohibited_actions); | 23 SetProhibitedActions(prohibited_actions); |
| 23 error_message_ = base::UTF8ToUTF16(expected_error()); | 24 error_message_ = base::UTF8ToUTF16(expected_error()); |
| 24 } | 25 } |
| 25 | 26 |
| 26 void TestManagementPolicyProvider::SetProhibitedActions( | 27 void TestManagementPolicyProvider::SetProhibitedActions( |
| 27 int prohibited_actions) { | 28 int prohibited_actions) { |
| 28 may_load_ = (prohibited_actions & PROHIBIT_LOAD) == 0; | 29 may_load_ = (prohibited_actions & PROHIBIT_LOAD) == 0; |
| 29 may_modify_status_ = (prohibited_actions & PROHIBIT_MODIFY_STATUS) == 0; | 30 may_modify_status_ = (prohibited_actions & PROHIBIT_MODIFY_STATUS) == 0; |
| 30 must_remain_enabled_ = (prohibited_actions & MUST_REMAIN_ENABLED) != 0; | 31 must_remain_enabled_ = (prohibited_actions & MUST_REMAIN_ENABLED) != 0; |
| 31 must_remain_disabled_ = (prohibited_actions & MUST_REMAIN_DISABLED) != 0; | 32 must_remain_disabled_ = (prohibited_actions & MUST_REMAIN_DISABLED) != 0; |
| 33 must_remain_installed_ = (prohibited_actions & MUST_REMAIN_INSTALLED) != 0; |
| 32 } | 34 } |
| 33 | 35 |
| 34 void TestManagementPolicyProvider::SetDisableReason( | 36 void TestManagementPolicyProvider::SetDisableReason( |
| 35 Extension::DisableReason reason) { | 37 Extension::DisableReason reason) { |
| 36 disable_reason_ = reason; | 38 disable_reason_ = reason; |
| 37 } | 39 } |
| 38 | 40 |
| 39 std::string TestManagementPolicyProvider::GetDebugPolicyProviderName() const { | 41 std::string TestManagementPolicyProvider::GetDebugPolicyProviderName() const { |
| 40 return "the test management policy provider"; | 42 return "the test management policy provider"; |
| 41 } | 43 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 68 base::string16* error) const { | 70 base::string16* error) const { |
| 69 if (must_remain_disabled_) { | 71 if (must_remain_disabled_) { |
| 70 if (error) | 72 if (error) |
| 71 *error = error_message_; | 73 *error = error_message_; |
| 72 if (reason) | 74 if (reason) |
| 73 *reason = disable_reason_; | 75 *reason = disable_reason_; |
| 74 } | 76 } |
| 75 return must_remain_disabled_; | 77 return must_remain_disabled_; |
| 76 } | 78 } |
| 77 | 79 |
| 80 bool TestManagementPolicyProvider::MustRemainInstalled( |
| 81 const Extension* extension, |
| 82 base::string16* error) const { |
| 83 if (error && must_remain_installed_) |
| 84 *error = error_message_; |
| 85 return must_remain_installed_; |
| 86 } |
| 78 | 87 |
| 79 } // namespace extensions | 88 } // namespace extensions |
| OLD | NEW |