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

Unified Diff: chrome/browser/extensions/test_management_policy.h

Issue 10382149: Refactor the various ways to control what users can do to extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/test_management_policy.h
===================================================================
--- chrome/browser/extensions/test_management_policy.h (revision 0)
+++ chrome/browser/extensions/test_management_policy.h (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_TEST_MANAGEMENT_POLICY_H_
+#define CHROME_BROWSER_EXTENSIONS_TEST_MANAGEMENT_POLICY_H_
+#pragma once
+
+#include <string>
+
+#include "base/string16.h"
+#include "chrome/browser/extensions/extension_service.h"
+
+namespace extensions {
+// This class provides a simple way to create providers with specific
+// restrictions and a known error message, for use in testing.
+class TestManagementPolicyProvider : public ManagementPolicy::Provider {
+ public:
+ enum AllowedActionFlag {
+ ALLOW_ALL = 0,
+ PROHIBIT_LOAD = 1 << 0,
+ PROHIBIT_MODIFY_STATUS = 1 << 1,
+ MUST_REMAIN_ENABLED = 1 << 2
+ };
+
+ static std::string expected_error() {
+ return "Action prohibited by test provider.";
+ }
+
+ TestManagementPolicyProvider();
+ explicit TestManagementPolicyProvider(int prohibited_actions);
+
+ void SetProhibitedActions(int prohibited_actions);
+
+ virtual std::string GetPolicyProviderName() const OVERRIDE;
+
+ virtual bool UserMayLoad(const Extension* extension,
+ string16* error) const OVERRIDE;
+
+ virtual bool UserMayModifySettings(const Extension* extension,
+ string16* error) const OVERRIDE;
+
+ virtual bool MustRemainEnabled(const Extension* extension,
+ string16* error) const OVERRIDE;
+
+ private:
+ bool may_load_;
+ bool may_modify_status_;
+ bool must_remain_enabled_;
+
+ string16 error_message_;
+};
+} // namespace
+#endif // CHROME_BROWSER_EXTENSIONS_TEST_MANAGEMENT_POLICY_H_
Property changes on: chrome\browser\extensions\test_management_policy.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/extensions/test_extension_system.cc ('k') | chrome/browser/extensions/test_management_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698