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

Unified Diff: chrome/browser/extensions/extension_context_menu_browsertest.cc

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/extension_context_menu_browsertest.cc
===================================================================
--- chrome/browser/extensions/extension_context_menu_browsertest.cc (revision 140193)
+++ chrome/browser/extensions/extension_context_menu_browsertest.cc (working copy)
@@ -5,9 +5,12 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/extensions/extension_context_menu_model.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/lazy_background_page_test_util.h"
+#include "chrome/browser/extensions/test_management_policy.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/ui/browser.h"
@@ -512,6 +515,41 @@
TestEnabledContextMenu(false);
}
+// Tests that applicable menu items are disabled when a ManagementPolicy
+// prohibits them.
+IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, PolicyDisablesItems) {
+ ASSERT_TRUE(LoadContextMenuExtension("simple"));
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ ASSERT_TRUE(service != NULL);
+ ASSERT_FALSE(service->extensions()->is_empty());
+
+ // We need an extension to pass to the menu constructor, but we don't care
+ // which one.
+ ExtensionSet::const_iterator i = service->extensions()->begin();
+ const extensions::Extension* extension = *i;
+ ASSERT_TRUE(extension != NULL);
+
+ scoped_refptr<ExtensionContextMenuModel> menu(
+ new ExtensionContextMenuModel(extension, browser()));
+
+ ExtensionSystem::Get(
+ browser()->profile())->management_policy()->UnregisterAllProviders();
+
+ // Actions should be enabled.
+ ASSERT_TRUE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::DISABLE));
+ ASSERT_TRUE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::UNINSTALL));
+
+ extensions::TestManagementPolicyProvider policy_provider(
+ extensions::TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS);
+ ExtensionSystem::Get(
+ browser()->profile())->management_policy()->RegisterProvider(
+ &policy_provider);
+
+ // Now the actions are disabled.
+ ASSERT_FALSE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::DISABLE));
+ ASSERT_FALSE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::UNINSTALL));
+}
+
class ExtensionContextMenuBrowserLazyTest :
public ExtensionContextMenuBrowserTest {
void SetUpCommandLine(CommandLine* command_line) {
« no previous file with comments | « chrome/browser/extensions/crx_installer.cc ('k') | chrome/browser/extensions/extension_context_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698