| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 return details.ptr(); | 684 return details.ptr(); |
| 685 } | 685 } |
| 686 | 686 |
| 687 const extensions::Extension* LoadUnpackedExtension( | 687 const extensions::Extension* LoadUnpackedExtension( |
| 688 const base::FilePath::StringType& name, bool expect_success) { | 688 const base::FilePath::StringType& name, bool expect_success) { |
| 689 base::FilePath extension_path(ui_test_utils::GetTestFilePath( | 689 base::FilePath extension_path(ui_test_utils::GetTestFilePath( |
| 690 base::FilePath(kTestExtensionsDir), base::FilePath(name))); | 690 base::FilePath(kTestExtensionsDir), base::FilePath(name))); |
| 691 scoped_refptr<extensions::UnpackedInstaller> installer = | 691 scoped_refptr<extensions::UnpackedInstaller> installer = |
| 692 extensions::UnpackedInstaller::Create(extension_service()); | 692 extensions::UnpackedInstaller::Create(extension_service()); |
| 693 content::WindowedNotificationObserver observer( | 693 content::WindowedNotificationObserver observer( |
| 694 expect_success ? chrome::NOTIFICATION_EXTENSION_LOADED | 694 expect_success ? chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED |
| 695 : chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, | 695 : chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, |
| 696 content::NotificationService::AllSources()); | 696 content::NotificationService::AllSources()); |
| 697 installer->Load(extension_path); | 697 installer->Load(extension_path); |
| 698 observer.Wait(); | 698 observer.Wait(); |
| 699 | 699 |
| 700 const extensions::ExtensionSet* extensions = | 700 const extensions::ExtensionSet* extensions = |
| 701 extension_service()->extensions(); | 701 extension_service()->extensions(); |
| 702 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); | 702 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); |
| 703 it != extensions->end(); ++it) { | 703 it != extensions->end(); ++it) { |
| 704 if ((*it)->path() == extension_path) | 704 if ((*it)->path() == extension_path) |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 } | 1638 } |
| 1639 } | 1639 } |
| 1640 | 1640 |
| 1641 // Test policy-installed extensions are reloaded when killed. | 1641 // Test policy-installed extensions are reloaded when killed. |
| 1642 BackgroundContentsService:: | 1642 BackgroundContentsService:: |
| 1643 SetRestartDelayForForceInstalledAppsAndExtensionsForTesting(0); | 1643 SetRestartDelayForForceInstalledAppsAndExtensionsForTesting(0); |
| 1644 content::WindowedNotificationObserver extension_crashed_observer( | 1644 content::WindowedNotificationObserver extension_crashed_observer( |
| 1645 chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 1645 chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| 1646 content::NotificationService::AllSources()); | 1646 content::NotificationService::AllSources()); |
| 1647 content::WindowedNotificationObserver extension_loaded_observer( | 1647 content::WindowedNotificationObserver extension_loaded_observer( |
| 1648 chrome::NOTIFICATION_EXTENSION_LOADED, | 1648 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 1649 content::NotificationService::AllSources()); | 1649 content::NotificationService::AllSources()); |
| 1650 extensions::ExtensionHost* extension_host = | 1650 extensions::ExtensionHost* extension_host = |
| 1651 extensions::ExtensionSystem::Get(browser()->profile())-> | 1651 extensions::ExtensionSystem::Get(browser()->profile())-> |
| 1652 process_manager()->GetBackgroundHostForExtension(kGoodCrxId); | 1652 process_manager()->GetBackgroundHostForExtension(kGoodCrxId); |
| 1653 base::KillProcess(extension_host->render_process_host()->GetHandle(), | 1653 base::KillProcess(extension_host->render_process_host()->GetHandle(), |
| 1654 content::RESULT_CODE_KILLED, false); | 1654 content::RESULT_CODE_KILLED, false); |
| 1655 extension_crashed_observer.Wait(); | 1655 extension_crashed_observer.Wait(); |
| 1656 extension_loaded_observer.Wait(); | 1656 extension_loaded_observer.Wait(); |
| 1657 } | 1657 } |
| 1658 | 1658 |
| (...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2971 PrefService* prefs = browser()->profile()->GetPrefs(); | 2971 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2972 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( | 2972 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2973 prefs, "host.name")); | 2973 prefs, "host.name")); |
| 2974 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( | 2974 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2975 prefs, "other.host.name")); | 2975 prefs, "other.host.name")); |
| 2976 } | 2976 } |
| 2977 | 2977 |
| 2978 #endif // !defined(CHROME_OS) | 2978 #endif // !defined(CHROME_OS) |
| 2979 | 2979 |
| 2980 } // namespace policy | 2980 } // namespace policy |
| OLD | NEW |