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_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 void WaitForServicesToStart(int num_expected_extensions, | 85 void WaitForServicesToStart(int num_expected_extensions, |
86 bool expect_extensions_enabled) { | 86 bool expect_extensions_enabled) { |
87 ExtensionService* service = browser()->profile()->GetExtensionService(); | 87 ExtensionService* service = browser()->profile()->GetExtensionService(); |
88 | 88 |
89 // Count the number of non-component extensions. | 89 // Count the number of non-component extensions. |
90 int found_extensions = 0; | 90 int found_extensions = 0; |
91 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 91 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
92 it != service->extensions()->end(); ++it) | 92 it != service->extensions()->end(); ++it) |
93 if ((*it)->location() != Extension::COMPONENT) | 93 if ((*it)->location() != extensions::Extension::COMPONENT) |
94 found_extensions++; | 94 found_extensions++; |
95 | 95 |
96 ASSERT_EQ(static_cast<uint32>(num_expected_extensions), | 96 ASSERT_EQ(static_cast<uint32>(num_expected_extensions), |
97 static_cast<uint32>(found_extensions)); | 97 static_cast<uint32>(found_extensions)); |
98 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); | 98 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); |
99 | 99 |
100 ui_test_utils::WindowedNotificationObserver user_scripts_observer( | 100 ui_test_utils::WindowedNotificationObserver user_scripts_observer( |
101 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, | 101 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, |
102 content::NotificationService::AllSources()); | 102 content::NotificationService::AllSources()); |
103 UserScriptMaster* master = browser()->profile()->GetUserScriptMaster(); | 103 UserScriptMaster* master = browser()->profile()->GetUserScriptMaster(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 #else | 165 #else |
166 #define MAYBE_NoFileAccess NoFileAccess | 166 #define MAYBE_NoFileAccess NoFileAccess |
167 #endif | 167 #endif |
168 // Tests that disallowing file access on an extension prevents it from injecting | 168 // Tests that disallowing file access on an extension prevents it from injecting |
169 // script into a page with a file URL. | 169 // script into a page with a file URL. |
170 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { | 170 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { |
171 WaitForServicesToStart(num_expected_extensions_, true); | 171 WaitForServicesToStart(num_expected_extensions_, true); |
172 | 172 |
173 // Keep a separate list of extensions for which to disable file access, since | 173 // Keep a separate list of extensions for which to disable file access, since |
174 // doing so reloads them. | 174 // doing so reloads them. |
175 std::vector<const Extension*> extension_list; | 175 std::vector<const extensions::Extension*> extension_list; |
176 | 176 |
177 ExtensionService* service = browser()->profile()->GetExtensionService(); | 177 ExtensionService* service = browser()->profile()->GetExtensionService(); |
178 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 178 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
179 it != service->extensions()->end(); ++it) { | 179 it != service->extensions()->end(); ++it) { |
180 if ((*it)->location() == Extension::COMPONENT) | 180 if ((*it)->location() == extensions::Extension::COMPONENT) |
181 continue; | 181 continue; |
182 if (service->AllowFileAccess(*it)) | 182 if (service->AllowFileAccess(*it)) |
183 extension_list.push_back(*it); | 183 extension_list.push_back(*it); |
184 } | 184 } |
185 | 185 |
186 for (size_t i = 0; i < extension_list.size(); ++i) { | 186 for (size_t i = 0; i < extension_list.size(); ++i) { |
187 ui_test_utils::WindowedNotificationObserver user_scripts_observer( | 187 ui_test_utils::WindowedNotificationObserver user_scripts_observer( |
188 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, | 188 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, |
189 content::NotificationService::AllSources()); | 189 content::NotificationService::AllSources()); |
190 service->SetAllowFileAccess(extension_list[i], false); | 190 service->SetAllowFileAccess(extension_list[i], false); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 .AppendASCII("extensions") | 259 .AppendASCII("extensions") |
260 .AppendASCII("app2"); | 260 .AppendASCII("app2"); |
261 load_extensions_.push_back(fourth_extension_path.value()); | 261 load_extensions_.push_back(fourth_extension_path.value()); |
262 } | 262 } |
263 }; | 263 }; |
264 | 264 |
265 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { | 265 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { |
266 WaitForServicesToStart(4, true); | 266 WaitForServicesToStart(4, true); |
267 TestInjection(true, true); | 267 TestInjection(true, true); |
268 } | 268 } |
OLD | NEW |