| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 // TODO(phajdan.jr): Check return values of the functions below, carefully. | 103 // TODO(phajdan.jr): Check return values of the functions below, carefully. |
| 104 base::DeleteFile(user_scripts_dir_, true); | 104 base::DeleteFile(user_scripts_dir_, true); |
| 105 base::DeleteFile(extensions_dir_, true); | 105 base::DeleteFile(extensions_dir_, true); |
| 106 | 106 |
| 107 InProcessBrowserTest::TearDown(); | 107 InProcessBrowserTest::TearDown(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void WaitForServicesToStart(int num_expected_extensions, | 110 void WaitForServicesToStart(int num_expected_extensions, |
| 111 bool expect_extensions_enabled) { | 111 bool expect_extensions_enabled) { |
| 112 ExtensionService* service = extensions::ExtensionSystem::Get( | 112 extensions::ExtensionRegistry* registry = |
| 113 browser()->profile())->extension_service(); | 113 extensions::ExtensionRegistry::Get(browser()->profile()); |
| 114 | 114 |
| 115 // Count the number of non-component extensions. | 115 // Count the number of non-component extensions. |
| 116 int found_extensions = 0; | 116 int found_extensions = 0; |
| 117 for (extensions::ExtensionSet::const_iterator it = | 117 for (const scoped_refptr<const extensions::Extension>& extension : |
| 118 service->extensions()->begin(); | 118 registry->enabled_extensions()) { |
| 119 it != service->extensions()->end(); ++it) { | 119 if (extension->location() != extensions::Manifest::COMPONENT) |
| 120 if ((*it)->location() != extensions::Manifest::COMPONENT) | |
| 121 found_extensions++; | 120 found_extensions++; |
| 122 } | 121 } |
| 123 | 122 |
| 124 if (!unauthenticated_load_allowed_) | 123 if (!unauthenticated_load_allowed_) |
| 125 num_expected_extensions = 0; | 124 num_expected_extensions = 0; |
| 126 | 125 |
| 127 ASSERT_EQ(static_cast<uint32>(num_expected_extensions), | 126 ASSERT_EQ(static_cast<uint32>(num_expected_extensions), |
| 128 static_cast<uint32>(found_extensions)); | 127 static_cast<uint32>(found_extensions)); |
| 128 |
| 129 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 130 browser()->profile())->extension_service(); |
| 129 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); | 131 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); |
| 130 | 132 |
| 131 content::WindowedNotificationObserver user_scripts_observer( | 133 content::WindowedNotificationObserver user_scripts_observer( |
| 132 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, | 134 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, |
| 133 content::NotificationService::AllSources()); | 135 content::NotificationService::AllSources()); |
| 134 extensions::SharedUserScriptMaster* master = | 136 extensions::SharedUserScriptMaster* master = |
| 135 extensions::ExtensionSystem::Get(browser()->profile())-> | 137 extensions::ExtensionSystem::Get(browser()->profile())-> |
| 136 shared_user_script_master(); | 138 shared_user_script_master(); |
| 137 if (!master->scripts_ready()) | 139 if (!master->scripts_ready()) |
| 138 user_scripts_observer.Wait(); | 140 user_scripts_observer.Wait(); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 .AppendASCII("extensions") | 295 .AppendASCII("extensions") |
| 294 .AppendASCII("app2"); | 296 .AppendASCII("app2"); |
| 295 load_extensions_.push_back(fourth_extension_path.value()); | 297 load_extensions_.push_back(fourth_extension_path.value()); |
| 296 } | 298 } |
| 297 }; | 299 }; |
| 298 | 300 |
| 299 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { | 301 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { |
| 300 WaitForServicesToStart(4, true); | 302 WaitForServicesToStart(4, true); |
| 301 TestInjection(true, true); | 303 TestInjection(true, true); |
| 302 } | 304 } |
| OLD | NEW |