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

Side by Side Diff: chrome/browser/extensions/test_management_policy.cc

Issue 54903011: Add management policy function allowing extensions to be disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/test_management_policy.h" 5 #include "chrome/browser/extensions/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 TestManagementPolicyProvider::TestManagementPolicyProvider() 11 TestManagementPolicyProvider::TestManagementPolicyProvider()
11 : may_load_(true), 12 : may_load_(true),
12 may_modify_status_(true), 13 may_modify_status_(true),
13 must_remain_enabled_(false) { 14 must_remain_enabled_(false),
15 must_remain_disabled_(false),
16 disable_reason_(Extension::DISABLE_NONE) {
14 error_message_ = UTF8ToUTF16(expected_error()); 17 error_message_ = UTF8ToUTF16(expected_error());
15 } 18 }
16 19
17 TestManagementPolicyProvider::TestManagementPolicyProvider( 20 TestManagementPolicyProvider::TestManagementPolicyProvider(
18 int prohibited_actions) { 21 int prohibited_actions) {
19 SetProhibitedActions(prohibited_actions); 22 SetProhibitedActions(prohibited_actions);
20 error_message_ = UTF8ToUTF16(expected_error()); 23 error_message_ = UTF8ToUTF16(expected_error());
21 } 24 }
22 25
23 void TestManagementPolicyProvider::SetProhibitedActions( 26 void TestManagementPolicyProvider::SetProhibitedActions(
24 int prohibited_actions) { 27 int prohibited_actions) {
25 may_load_ = (prohibited_actions & PROHIBIT_LOAD) == 0; 28 may_load_ = (prohibited_actions & PROHIBIT_LOAD) == 0;
26 may_modify_status_ = (prohibited_actions & PROHIBIT_MODIFY_STATUS) == 0; 29 may_modify_status_ = (prohibited_actions & PROHIBIT_MODIFY_STATUS) == 0;
27 must_remain_enabled_ = (prohibited_actions & MUST_REMAIN_ENABLED) != 0; 30 must_remain_enabled_ = (prohibited_actions & MUST_REMAIN_ENABLED) != 0;
31 must_remain_disabled_ = (prohibited_actions & MUST_REMAIN_DISABLED) != 0;
32 }
33
34 void TestManagementPolicyProvider::SetDisableReason(
35 Extension::DisableReason reason) {
36 disable_reason_ = reason;
28 } 37 }
29 38
30 std::string TestManagementPolicyProvider::GetDebugPolicyProviderName() const { 39 std::string TestManagementPolicyProvider::GetDebugPolicyProviderName() const {
31 return "the test management policy provider"; 40 return "the test management policy provider";
32 } 41 }
33 42
34 bool TestManagementPolicyProvider::UserMayLoad(const Extension* extension, 43 bool TestManagementPolicyProvider::UserMayLoad(const Extension* extension,
35 string16* error) const { 44 string16* error) const {
36 if (error && !may_load_) 45 if (error && !may_load_)
37 *error = error_message_; 46 *error = error_message_;
38 return may_load_; 47 return may_load_;
39 } 48 }
40 49
41 bool TestManagementPolicyProvider::UserMayModifySettings( 50 bool TestManagementPolicyProvider::UserMayModifySettings(
42 const Extension* extension, string16* error) const { 51 const Extension* extension, string16* error) const {
43 if (error && !may_modify_status_) 52 if (error && !may_modify_status_)
44 *error = error_message_; 53 *error = error_message_;
45 return may_modify_status_; 54 return may_modify_status_;
46 } 55 }
47 56
48 bool TestManagementPolicyProvider::MustRemainEnabled(const Extension* extension, 57 bool TestManagementPolicyProvider::MustRemainEnabled(const Extension* extension,
49 string16* error) const { 58 string16* error) const {
50 if (error && must_remain_enabled_) 59 if (error && must_remain_enabled_)
51 *error = error_message_; 60 *error = error_message_;
52 return must_remain_enabled_; 61 return must_remain_enabled_;
53 } 62 }
54 } // namespace 63
64 bool TestManagementPolicyProvider::MustRemainDisabled(
65 const Extension* extension,
66 Extension::DisableReason* reason,
67 string16* error) const {
68 if (error && must_remain_disabled_)
69 *error = error_message_;
70 if (reason && must_remain_disabled_)
71 *reason = disable_reason_;
miket_OOO 2013/11/04 23:18:10 Tiniest readability comment that you can ignore:
asargent_no_longer_on_chrome 2013/11/05 00:20:44 Done.
72 return must_remain_disabled_;
73 }
74
75
76 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698