OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/background/background_mode_manager.h" | 9 #include "chrome/browser/background/background_mode_manager.h" |
10 #include "chrome/browser/browser_shutdown.h" | 10 #include "chrome/browser/browser_shutdown.h" |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 600 |
601 static_cast<extensions::TestExtensionSystem*>( | 601 static_cast<extensions::TestExtensionSystem*>( |
602 extensions::ExtensionSystem::Get(profile_))->CreateExtensionService( | 602 extensions::ExtensionSystem::Get(profile_))->CreateExtensionService( |
603 CommandLine::ForCurrentProcess(), | 603 CommandLine::ForCurrentProcess(), |
604 base::FilePath(), | 604 base::FilePath(), |
605 false); | 605 false); |
606 ExtensionService* service = | 606 ExtensionService* service = |
607 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 607 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
608 service->Init(); | 608 service->Init(); |
609 | 609 |
610 service->AddComponentExtension(component_extension); | 610 service->AddComponentExtension(component_extension.get()); |
611 service->AddComponentExtension(component_extension_with_options); | 611 service->AddComponentExtension(component_extension_with_options.get()); |
612 service->AddExtension(regular_extension); | 612 service->AddExtension(regular_extension.get()); |
613 service->AddExtension(regular_extension_with_options); | 613 service->AddExtension(regular_extension_with_options.get()); |
614 | 614 |
615 scoped_ptr<StatusIconMenuModel> menu(new StatusIconMenuModel(NULL)); | 615 scoped_ptr<StatusIconMenuModel> menu(new StatusIconMenuModel(NULL)); |
616 scoped_ptr<StatusIconMenuModel> submenu(new StatusIconMenuModel(NULL)); | 616 scoped_ptr<StatusIconMenuModel> submenu(new StatusIconMenuModel(NULL)); |
617 BackgroundModeManager::BackgroundModeData* bmd = | 617 BackgroundModeManager::BackgroundModeData* bmd = |
618 manager_->GetBackgroundModeData(profile_); | 618 manager_->GetBackgroundModeData(profile_); |
619 bmd->BuildProfileMenu(submenu.get(), menu.get()); | 619 bmd->BuildProfileMenu(submenu.get(), menu.get()); |
620 EXPECT_TRUE( | 620 EXPECT_TRUE( |
621 submenu->GetLabelAt(0) == | 621 submenu->GetLabelAt(0) == |
622 base::UTF8ToUTF16("Component Extension")); | 622 base::UTF8ToUTF16("Component Extension")); |
623 EXPECT_FALSE(submenu->IsCommandIdEnabled(submenu->GetCommandIdAt(0))); | 623 EXPECT_FALSE(submenu->IsCommandIdEnabled(submenu->GetCommandIdAt(0))); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 | 678 |
679 static_cast<extensions::TestExtensionSystem*>( | 679 static_cast<extensions::TestExtensionSystem*>( |
680 extensions::ExtensionSystem::Get(profile_))->CreateExtensionService( | 680 extensions::ExtensionSystem::Get(profile_))->CreateExtensionService( |
681 CommandLine::ForCurrentProcess(), | 681 CommandLine::ForCurrentProcess(), |
682 base::FilePath(), | 682 base::FilePath(), |
683 false); | 683 false); |
684 ExtensionService* service1 = | 684 ExtensionService* service1 = |
685 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 685 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
686 service1->Init(); | 686 service1->Init(); |
687 | 687 |
688 service1->AddComponentExtension(component_extension); | 688 service1->AddComponentExtension(component_extension.get()); |
689 service1->AddComponentExtension(component_extension_with_options); | 689 service1->AddComponentExtension(component_extension_with_options.get()); |
690 service1->AddExtension(regular_extension); | 690 service1->AddExtension(regular_extension.get()); |
691 service1->AddExtension(regular_extension_with_options); | 691 service1->AddExtension(regular_extension_with_options.get()); |
692 | 692 |
693 static_cast<extensions::TestExtensionSystem*>( | 693 static_cast<extensions::TestExtensionSystem*>( |
694 extensions::ExtensionSystem::Get(profile2))->CreateExtensionService( | 694 extensions::ExtensionSystem::Get(profile2))->CreateExtensionService( |
695 CommandLine::ForCurrentProcess(), | 695 CommandLine::ForCurrentProcess(), |
696 base::FilePath(), | 696 base::FilePath(), |
697 false); | 697 false); |
698 ExtensionService* service2 = | 698 ExtensionService* service2 = |
699 extensions::ExtensionSystem::Get(profile2)->extension_service(); | 699 extensions::ExtensionSystem::Get(profile2)->extension_service(); |
700 service2->Init(); | 700 service2->Init(); |
701 | 701 |
702 service2->AddComponentExtension(component_extension); | 702 service2->AddComponentExtension(component_extension.get()); |
703 service2->AddExtension(regular_extension); | 703 service2->AddExtension(regular_extension.get()); |
704 service2->AddExtension(regular_extension_with_options); | 704 service2->AddExtension(regular_extension_with_options.get()); |
705 | 705 |
706 manager_->RegisterProfile(profile2); | 706 manager_->RegisterProfile(profile2); |
707 | 707 |
708 manager_->status_icon_ = new TestStatusIcon(); | 708 manager_->status_icon_ = new TestStatusIcon(); |
709 manager_->UpdateStatusTrayIconContextMenu(); | 709 manager_->UpdateStatusTrayIconContextMenu(); |
710 StatusIconMenuModel* context_menu = manager_->context_menu_; | 710 StatusIconMenuModel* context_menu = manager_->context_menu_; |
711 EXPECT_TRUE(context_menu != NULL); | 711 EXPECT_TRUE(context_menu != NULL); |
712 | 712 |
713 // Background Profile Enable Checks | 713 // Background Profile Enable Checks |
714 EXPECT_TRUE(context_menu->GetLabelAt(3) == base::UTF8ToUTF16("p1")); | 714 EXPECT_TRUE(context_menu->GetLabelAt(3) == base::UTF8ToUTF16("p1")); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 ExtensionService* service = | 851 ExtensionService* service = |
852 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 852 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
853 DCHECK(!service->is_ready()); | 853 DCHECK(!service->is_ready()); |
854 service->Init(); | 854 service->Init(); |
855 DCHECK(service->is_ready()); | 855 DCHECK(service->is_ready()); |
856 manager_->status_icon_ = new TestStatusIcon(); | 856 manager_->status_icon_ = new TestStatusIcon(); |
857 manager_->UpdateStatusTrayIconContextMenu(); | 857 manager_->UpdateStatusTrayIconContextMenu(); |
858 | 858 |
859 // Adding a background extension should show the balloon. | 859 // Adding a background extension should show the balloon. |
860 EXPECT_FALSE(manager_->HasShownBalloon()); | 860 EXPECT_FALSE(manager_->HasShownBalloon()); |
861 service->AddExtension(bg_ext); | 861 service->AddExtension(bg_ext.get()); |
862 EXPECT_TRUE(manager_->HasShownBalloon()); | 862 EXPECT_TRUE(manager_->HasShownBalloon()); |
863 | 863 |
864 // Adding an extension without background should not show the balloon. | 864 // Adding an extension without background should not show the balloon. |
865 manager_->SetHasShownBalloon(false); | 865 manager_->SetHasShownBalloon(false); |
866 service->AddExtension(no_bg_ext); | 866 service->AddExtension(no_bg_ext.get()); |
867 EXPECT_FALSE(manager_->HasShownBalloon()); | 867 EXPECT_FALSE(manager_->HasShownBalloon()); |
868 | 868 |
869 // Upgrading an extension that has background should not reshow the balloon. | 869 // Upgrading an extension that has background should not reshow the balloon. |
870 service->AddExtension(upgraded_bg_ext); | 870 service->AddExtension(upgraded_bg_ext.get()); |
871 EXPECT_FALSE(manager_->HasShownBalloon()); | 871 EXPECT_FALSE(manager_->HasShownBalloon()); |
872 | 872 |
873 // Upgrading an extension that didn't have background to one that does should | 873 // Upgrading an extension that didn't have background to one that does should |
874 // show the balloon. | 874 // show the balloon. |
875 service->AddExtension(upgraded_no_bg_ext_has_bg); | 875 service->AddExtension(upgraded_no_bg_ext_has_bg.get()); |
876 EXPECT_TRUE(manager_->HasShownBalloon()); | 876 EXPECT_TRUE(manager_->HasShownBalloon()); |
877 | 877 |
878 // Installing an ephemeral app should not show the balloon. | 878 // Installing an ephemeral app should not show the balloon. |
879 manager_->SetHasShownBalloon(false); | 879 manager_->SetHasShownBalloon(false); |
880 AddEphemeralApp(ephemeral_app.get(), service); | 880 AddEphemeralApp(ephemeral_app.get(), service); |
881 EXPECT_FALSE(manager_->HasShownBalloon()); | 881 EXPECT_FALSE(manager_->HasShownBalloon()); |
882 | 882 |
883 // Promoting the ephemeral app to a regular installed app should now show | 883 // Promoting the ephemeral app to a regular installed app should now show |
884 // the balloon. | 884 // the balloon. |
885 service->PromoteEphemeralApp(ephemeral_app.get(), false /*from sync*/); | 885 service->PromoteEphemeralApp(ephemeral_app.get(), false /*from sync*/); |
886 EXPECT_TRUE(manager_->HasShownBalloon()); | 886 EXPECT_TRUE(manager_->HasShownBalloon()); |
887 } | 887 } |
OLD | NEW |