OLD | NEW |
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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
7 #include "chrome/browser/extensions/extension_browsertest.h" | 7 #include "chrome/browser/extensions/extension_browsertest.h" |
8 #include "chrome/browser/extensions/extension_context_menu_model.h" | 8 #include "chrome/browser/extensions/extension_context_menu_model.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 526 |
527 // We need an extension to pass to the menu constructor, but we don't care | 527 // We need an extension to pass to the menu constructor, but we don't care |
528 // which one. | 528 // which one. |
529 ExtensionSet::const_iterator i = service->extensions()->begin(); | 529 ExtensionSet::const_iterator i = service->extensions()->begin(); |
530 const extensions::Extension* extension = *i; | 530 const extensions::Extension* extension = *i; |
531 ASSERT_TRUE(extension != NULL); | 531 ASSERT_TRUE(extension != NULL); |
532 | 532 |
533 scoped_refptr<ExtensionContextMenuModel> menu( | 533 scoped_refptr<ExtensionContextMenuModel> menu( |
534 new ExtensionContextMenuModel(extension, browser(), NULL)); | 534 new ExtensionContextMenuModel(extension, browser(), NULL)); |
535 | 535 |
536 ExtensionSystem::Get( | 536 extensions::ExtensionSystem::Get( |
537 browser()->profile())->management_policy()->UnregisterAllProviders(); | 537 browser()->profile())->management_policy()->UnregisterAllProviders(); |
538 | 538 |
539 // Actions should be enabled. | 539 // Actions should be enabled. |
540 ASSERT_TRUE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::DISABLE)); | 540 ASSERT_TRUE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::DISABLE)); |
541 ASSERT_TRUE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::UNINSTALL)); | 541 ASSERT_TRUE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::UNINSTALL)); |
542 | 542 |
543 extensions::TestManagementPolicyProvider policy_provider( | 543 extensions::TestManagementPolicyProvider policy_provider( |
544 extensions::TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS); | 544 extensions::TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS); |
545 ExtensionSystem::Get( | 545 extensions::ExtensionSystem::Get( |
546 browser()->profile())->management_policy()->RegisterProvider( | 546 browser()->profile())->management_policy()->RegisterProvider( |
547 &policy_provider); | 547 &policy_provider); |
548 | 548 |
549 // Now the actions are disabled. | 549 // Now the actions are disabled. |
550 ASSERT_FALSE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::DISABLE)); | 550 ASSERT_FALSE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::DISABLE)); |
551 ASSERT_FALSE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::UNINSTALL)); | 551 ASSERT_FALSE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::UNINSTALL)); |
552 } | 552 } |
553 | 553 |
554 class ExtensionContextMenuBrowserLazyTest : | 554 class ExtensionContextMenuBrowserLazyTest : |
555 public ExtensionContextMenuBrowserTest { | 555 public ExtensionContextMenuBrowserTest { |
(...skipping 30 matching lines...) Expand all Loading... |
586 EXPECT_FALSE(menu->IsCommandIdChecked(command_id)); | 586 EXPECT_FALSE(menu->IsCommandIdChecked(command_id)); |
587 | 587 |
588 // Executing the checkbox also fires the onClicked event. | 588 // Executing the checkbox also fires the onClicked event. |
589 ExtensionTestMessageListener listener("onClicked fired for checkbox1", false); | 589 ExtensionTestMessageListener listener("onClicked fired for checkbox1", false); |
590 menu->ExecuteCommand(command_id); | 590 menu->ExecuteCommand(command_id); |
591 checkbox_checked.WaitUntilClosed(); | 591 checkbox_checked.WaitUntilClosed(); |
592 | 592 |
593 EXPECT_TRUE(menu->IsCommandIdChecked(command_id)); | 593 EXPECT_TRUE(menu->IsCommandIdChecked(command_id)); |
594 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 594 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
595 } | 595 } |
OLD | NEW |