Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/browser/extensions/extension_startup_browsertest.cc

Issue 8789018: Revert 113047 - Make ExtensionService use ExtensionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:mergeinfo
OLDNEW
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 <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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 InProcessBrowserTest::TearDown(); 77 InProcessBrowserTest::TearDown();
78 } 78 }
79 79
80 void WaitForServicesToStart(int num_expected_extensions, 80 void WaitForServicesToStart(int num_expected_extensions,
81 bool expect_extensions_enabled) { 81 bool expect_extensions_enabled) {
82 ExtensionService* service = browser()->profile()->GetExtensionService(); 82 ExtensionService* service = browser()->profile()->GetExtensionService();
83 83
84 // Count the number of non-component extensions. 84 // Count the number of non-component extensions.
85 int found_extensions = 0; 85 int found_extensions = 0;
86 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 86 for (size_t i = 0; i < service->extensions()->size(); i++)
87 it != service->extensions()->end(); ++it) 87 if (service->extensions()->at(i)->location() != Extension::COMPONENT)
88 if ((*it)->location() != Extension::COMPONENT)
89 found_extensions++; 88 found_extensions++;
90 89
91 ASSERT_EQ(static_cast<uint32>(num_expected_extensions), 90 ASSERT_EQ(static_cast<uint32>(num_expected_extensions),
92 static_cast<uint32>(found_extensions)); 91 static_cast<uint32>(found_extensions));
93 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); 92 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled());
94 93
95 ui_test_utils::WindowedNotificationObserver user_scripts_observer( 94 ui_test_utils::WindowedNotificationObserver user_scripts_observer(
96 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, 95 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
97 content::NotificationService::AllSources()); 96 content::NotificationService::AllSources());
98 UserScriptMaster* master = browser()->profile()->GetUserScriptMaster(); 97 UserScriptMaster* master = browser()->profile()->GetUserScriptMaster();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 #if defined(OS_MACOSX) 156 #if defined(OS_MACOSX)
158 #define MAYBE_NoFileAccess DISABLED_NoFileAccess 157 #define MAYBE_NoFileAccess DISABLED_NoFileAccess
159 #else 158 #else
160 #define MAYBE_NoFileAccess NoFileAccess 159 #define MAYBE_NoFileAccess NoFileAccess
161 #endif 160 #endif
162 // Tests that disallowing file access on an extension prevents it from injecting 161 // Tests that disallowing file access on an extension prevents it from injecting
163 // script into a page with a file URL. 162 // script into a page with a file URL.
164 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { 163 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) {
165 WaitForServicesToStart(num_expected_extensions_, true); 164 WaitForServicesToStart(num_expected_extensions_, true);
166 165
167 // Keep a separate list of extensions for which to disable file access, since
168 // doing so reloads them.
169 std::vector<const Extension*> extension_list;
170
171 ExtensionService* service = browser()->profile()->GetExtensionService(); 166 ExtensionService* service = browser()->profile()->GetExtensionService();
172 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 167 for (size_t i = 0; i < service->extensions()->size(); ++i) {
173 it != service->extensions()->end(); ++it) { 168 if (service->extensions()->at(i)->location() == Extension::COMPONENT)
174 if ((*it)->location() == Extension::COMPONENT)
175 continue; 169 continue;
176 if (service->AllowFileAccess(*it)) 170 if (service->AllowFileAccess(service->extensions()->at(i))) {
177 extension_list.push_back(*it); 171 ui_test_utils::WindowedNotificationObserver user_scripts_observer(
178 } 172 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
179 173 content::NotificationService::AllSources());
180 for (size_t i = 0; i < extension_list.size(); ++i) { 174 service->SetAllowFileAccess(service->extensions()->at(i), false);
181 ui_test_utils::WindowedNotificationObserver user_scripts_observer( 175 user_scripts_observer.Wait();
182 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, 176 }
183 content::NotificationService::AllSources());
184 service->SetAllowFileAccess(extension_list[i], false);
185 user_scripts_observer.Wait();
186 } 177 }
187 178
188 TestInjection(false, false); 179 TestInjection(false, false);
189 } 180 }
190 181
191 // ExtensionsLoadTest 182 // ExtensionsLoadTest
192 // Ensures that we can startup the browser with --load-extension and see them 183 // Ensures that we can startup the browser with --load-extension and see them
193 // run. 184 // run.
194 185
195 class ExtensionsLoadTest : public ExtensionStartupTestBase { 186 class ExtensionsLoadTest : public ExtensionStartupTestBase {
(...skipping 14 matching lines...) Expand all
210 #if defined(OS_LINUX) && defined(ARCH_CPU_64_BITS) 201 #if defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)
211 #define Maybe_Test FLAKY_Test 202 #define Maybe_Test FLAKY_Test
212 #else 203 #else
213 #define Maybe_Test Test 204 #define Maybe_Test Test
214 #endif 205 #endif
215 206
216 IN_PROC_BROWSER_TEST_F(ExtensionsLoadTest, Maybe_Test) { 207 IN_PROC_BROWSER_TEST_F(ExtensionsLoadTest, Maybe_Test) {
217 WaitForServicesToStart(1, true); 208 WaitForServicesToStart(1, true);
218 TestInjection(true, true); 209 TestInjection(true, true);
219 } 210 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/extensions/extension_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698