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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 InProcessBrowserTest::TearDown(); | 88 InProcessBrowserTest::TearDown(); |
89 } | 89 } |
90 | 90 |
91 void WaitForServicesToStart(int num_expected_extensions, | 91 void WaitForServicesToStart(int num_expected_extensions, |
92 bool expect_extensions_enabled) { | 92 bool expect_extensions_enabled) { |
93 ExtensionService* service = extensions::ExtensionSystem::Get( | 93 ExtensionService* service = extensions::ExtensionSystem::Get( |
94 browser()->profile())->extension_service(); | 94 browser()->profile())->extension_service(); |
95 | 95 |
96 // Count the number of non-component extensions. | 96 // Count the number of non-component extensions. |
97 int found_extensions = 0; | 97 int found_extensions = 0; |
98 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 98 for (extensions::ExtensionSet::const_iterator it = |
| 99 service->extensions()->begin(); |
99 it != service->extensions()->end(); ++it) | 100 it != service->extensions()->end(); ++it) |
100 if ((*it)->location() != extensions::Manifest::COMPONENT) | 101 if ((*it)->location() != extensions::Manifest::COMPONENT) |
101 found_extensions++; | 102 found_extensions++; |
102 | 103 |
103 ASSERT_EQ(static_cast<uint32>(num_expected_extensions), | 104 ASSERT_EQ(static_cast<uint32>(num_expected_extensions), |
104 static_cast<uint32>(found_extensions)); | 105 static_cast<uint32>(found_extensions)); |
105 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); | 106 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); |
106 | 107 |
107 content::WindowedNotificationObserver user_scripts_observer( | 108 content::WindowedNotificationObserver user_scripts_observer( |
108 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, | 109 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // script into a page with a file URL. | 181 // script into a page with a file URL. |
181 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { | 182 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { |
182 WaitForServicesToStart(num_expected_extensions_, true); | 183 WaitForServicesToStart(num_expected_extensions_, true); |
183 | 184 |
184 // Keep a separate list of extensions for which to disable file access, since | 185 // Keep a separate list of extensions for which to disable file access, since |
185 // doing so reloads them. | 186 // doing so reloads them. |
186 std::vector<const extensions::Extension*> extension_list; | 187 std::vector<const extensions::Extension*> extension_list; |
187 | 188 |
188 ExtensionService* service = extensions::ExtensionSystem::Get( | 189 ExtensionService* service = extensions::ExtensionSystem::Get( |
189 browser()->profile())->extension_service(); | 190 browser()->profile())->extension_service(); |
190 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 191 for (extensions::ExtensionSet::const_iterator it = |
| 192 service->extensions()->begin(); |
191 it != service->extensions()->end(); ++it) { | 193 it != service->extensions()->end(); ++it) { |
192 if ((*it)->location() == extensions::Manifest::COMPONENT) | 194 if ((*it)->location() == extensions::Manifest::COMPONENT) |
193 continue; | 195 continue; |
194 if (extension_util::AllowFileAccess(it->get(), service)) | 196 if (extension_util::AllowFileAccess(it->get(), service)) |
195 extension_list.push_back(it->get()); | 197 extension_list.push_back(it->get()); |
196 } | 198 } |
197 | 199 |
198 for (size_t i = 0; i < extension_list.size(); ++i) { | 200 for (size_t i = 0; i < extension_list.size(); ++i) { |
199 content::WindowedNotificationObserver user_scripts_observer( | 201 content::WindowedNotificationObserver user_scripts_observer( |
200 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, | 202 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 .AppendASCII("extensions") | 273 .AppendASCII("extensions") |
272 .AppendASCII("app2"); | 274 .AppendASCII("app2"); |
273 load_extensions_.push_back(fourth_extension_path.value()); | 275 load_extensions_.push_back(fourth_extension_path.value()); |
274 } | 276 } |
275 }; | 277 }; |
276 | 278 |
277 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { | 279 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { |
278 WaitForServicesToStart(4, true); | 280 WaitForServicesToStart(4, true); |
279 TestInjection(true, true); | 281 TestInjection(true, true); |
280 } | 282 } |
OLD | NEW |