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

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

Issue 102103005: Move c/c/e/extension_set to top-level extensions/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed unused includes, added includes where missing Created 7 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_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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_system.h" 14 #include "chrome/browser/extensions/extension_system.h"
15 #include "chrome/browser/extensions/extension_util.h" 15 #include "chrome/browser/extensions/extension_util.h"
16 #include "chrome/browser/extensions/user_script_master.h" 16 #include "chrome/browser/extensions/user_script_master.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
24 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
25 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
26 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
28 #include "content/public/test/browser_test_utils.h" 28 #include "content/public/test/browser_test_utils.h"
29 #include "extensions/common/extension.h"
30 #include "extensions/common/extension_set.h"
29 #include "extensions/common/feature_switch.h" 31 #include "extensions/common/feature_switch.h"
30 #include "net/base/net_util.h" 32 #include "net/base/net_util.h"
31 33
32 using extensions::FeatureSwitch; 34 using extensions::FeatureSwitch;
33 35
34 // This file contains high-level startup tests for the extensions system. We've 36 // This file contains high-level startup tests for the extensions system. We've
35 // had many silly bugs where command line flags did not get propagated correctly 37 // had many silly bugs where command line flags did not get propagated correctly
36 // into the services, so we didn't start correctly. 38 // into the services, so we didn't start correctly.
37 39
38 class ExtensionStartupTestBase : public InProcessBrowserTest { 40 class ExtensionStartupTestBase : public InProcessBrowserTest {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 InProcessBrowserTest::TearDown(); 90 InProcessBrowserTest::TearDown();
89 } 91 }
90 92
91 void WaitForServicesToStart(int num_expected_extensions, 93 void WaitForServicesToStart(int num_expected_extensions,
92 bool expect_extensions_enabled) { 94 bool expect_extensions_enabled) {
93 ExtensionService* service = extensions::ExtensionSystem::Get( 95 ExtensionService* service = extensions::ExtensionSystem::Get(
94 browser()->profile())->extension_service(); 96 browser()->profile())->extension_service();
95 97
96 // Count the number of non-component extensions. 98 // Count the number of non-component extensions.
97 int found_extensions = 0; 99 int found_extensions = 0;
98 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 100 for (extensions::ExtensionSet::const_iterator it =
101 service->extensions()->begin();
99 it != service->extensions()->end(); ++it) 102 it != service->extensions()->end(); ++it)
100 if ((*it)->location() != extensions::Manifest::COMPONENT) 103 if ((*it)->location() != extensions::Manifest::COMPONENT)
101 found_extensions++; 104 found_extensions++;
102 105
103 ASSERT_EQ(static_cast<uint32>(num_expected_extensions), 106 ASSERT_EQ(static_cast<uint32>(num_expected_extensions),
104 static_cast<uint32>(found_extensions)); 107 static_cast<uint32>(found_extensions));
105 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); 108 ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled());
106 109
107 content::WindowedNotificationObserver user_scripts_observer( 110 content::WindowedNotificationObserver user_scripts_observer(
108 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, 111 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // script into a page with a file URL. 183 // script into a page with a file URL.
181 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { 184 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) {
182 WaitForServicesToStart(num_expected_extensions_, true); 185 WaitForServicesToStart(num_expected_extensions_, true);
183 186
184 // Keep a separate list of extensions for which to disable file access, since 187 // Keep a separate list of extensions for which to disable file access, since
185 // doing so reloads them. 188 // doing so reloads them.
186 std::vector<const extensions::Extension*> extension_list; 189 std::vector<const extensions::Extension*> extension_list;
187 190
188 ExtensionService* service = extensions::ExtensionSystem::Get( 191 ExtensionService* service = extensions::ExtensionSystem::Get(
189 browser()->profile())->extension_service(); 192 browser()->profile())->extension_service();
190 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 193 for (extensions::ExtensionSet::const_iterator it =
194 service->extensions()->begin();
191 it != service->extensions()->end(); ++it) { 195 it != service->extensions()->end(); ++it) {
192 if ((*it)->location() == extensions::Manifest::COMPONENT) 196 if ((*it)->location() == extensions::Manifest::COMPONENT)
193 continue; 197 continue;
194 if (extension_util::AllowFileAccess(it->get(), service)) 198 if (extension_util::AllowFileAccess(it->get(), service))
195 extension_list.push_back(it->get()); 199 extension_list.push_back(it->get());
196 } 200 }
197 201
198 for (size_t i = 0; i < extension_list.size(); ++i) { 202 for (size_t i = 0; i < extension_list.size(); ++i) {
199 content::WindowedNotificationObserver user_scripts_observer( 203 content::WindowedNotificationObserver user_scripts_observer(
200 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, 204 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 .AppendASCII("extensions") 275 .AppendASCII("extensions")
272 .AppendASCII("app2"); 276 .AppendASCII("app2");
273 load_extensions_.push_back(fourth_extension_path.value()); 277 load_extensions_.push_back(fourth_extension_path.value());
274 } 278 }
275 }; 279 };
276 280
277 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { 281 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) {
278 WaitForServicesToStart(4, true); 282 WaitForServicesToStart(4, true);
279 TestInjection(true, true); 283 TestInjection(true, true);
280 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698