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

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

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 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
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // TODO(phajdan.jr): Check return values of the functions below, carefully. 85 // TODO(phajdan.jr): Check return values of the functions below, carefully.
86 file_util::Delete(user_scripts_dir_, true); 86 file_util::Delete(user_scripts_dir_, true);
87 file_util::Delete(extensions_dir_, true); 87 file_util::Delete(extensions_dir_, true);
88 88
89 InProcessBrowserTest::TearDown(); 89 InProcessBrowserTest::TearDown();
90 } 90 }
91 91
92 void WaitForServicesToStart(int num_expected_extensions, 92 void WaitForServicesToStart(int num_expected_extensions,
93 bool expect_extensions_enabled) { 93 bool expect_extensions_enabled) {
94 ExtensionService* service = browser()->profile()->GetExtensionService(); 94 ExtensionService* service = extensions::ExtensionSystem::Get(
95 browser()->profile())->extension_service();
95 96
96 // Count the number of non-component extensions. 97 // Count the number of non-component extensions.
97 int found_extensions = 0; 98 int found_extensions = 0;
98 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 99 for (ExtensionSet::const_iterator it = service->extensions()->begin();
99 it != service->extensions()->end(); ++it) 100 it != service->extensions()->end(); ++it)
100 if ((*it)->location() != extensions::Extension::COMPONENT) 101 if ((*it)->location() != extensions::Extension::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));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 #endif 180 #endif
180 // Tests that disallowing file access on an extension prevents it from injecting 181 // Tests that disallowing file access on an extension prevents it from injecting
181 // script into a page with a file URL. 182 // script into a page with a file URL.
182 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { 183 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) {
183 WaitForServicesToStart(num_expected_extensions_, true); 184 WaitForServicesToStart(num_expected_extensions_, true);
184 185
185 // Keep a separate list of extensions for which to disable file access, since 186 // Keep a separate list of extensions for which to disable file access, since
186 // doing so reloads them. 187 // doing so reloads them.
187 std::vector<const extensions::Extension*> extension_list; 188 std::vector<const extensions::Extension*> extension_list;
188 189
189 ExtensionService* service = browser()->profile()->GetExtensionService(); 190 ExtensionService* service = extensions::ExtensionSystem::Get(
191 browser()->profile())->extension_service();
190 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 192 for (ExtensionSet::const_iterator it = service->extensions()->begin();
191 it != service->extensions()->end(); ++it) { 193 it != service->extensions()->end(); ++it) {
192 if ((*it)->location() == extensions::Extension::COMPONENT) 194 if ((*it)->location() == extensions::Extension::COMPONENT)
193 continue; 195 continue;
194 if (service->AllowFileAccess(*it)) 196 if (service->AllowFileAccess(*it))
195 extension_list.push_back(*it); 197 extension_list.push_back(*it);
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(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698