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

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

Issue 5730004: Rename ExtensionsService to ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 10 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
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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"
11 #include "chrome/browser/extensions/extensions_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/user_script_master.h" 12 #include "chrome/browser/extensions/user_script_master.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/tab_contents/tab_contents.h" 14 #include "chrome/browser/tab_contents/tab_contents.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/notification_details.h" 18 #include "chrome/common/notification_details.h"
19 #include "chrome/common/notification_observer.h" 19 #include "chrome/common/notification_observer.h"
20 #include "chrome/common/notification_registrar.h" 20 #include "chrome/common/notification_registrar.h"
21 #include "chrome/common/notification_service.h" 21 #include "chrome/common/notification_service.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 virtual void TearDown() { 78 virtual void TearDown() {
79 EXPECT_TRUE(file_util::Delete(preferences_file_, false)); 79 EXPECT_TRUE(file_util::Delete(preferences_file_, false));
80 80
81 // TODO(phajdan.jr): Check return values of the functions below, carefully. 81 // TODO(phajdan.jr): Check return values of the functions below, carefully.
82 file_util::Delete(user_scripts_dir_, true); 82 file_util::Delete(user_scripts_dir_, true);
83 file_util::Delete(extensions_dir_, true); 83 file_util::Delete(extensions_dir_, true);
84 } 84 }
85 85
86 void WaitForServicesToStart(int num_expected_extensions, 86 void WaitForServicesToStart(int num_expected_extensions,
87 bool expect_extensions_enabled) { 87 bool expect_extensions_enabled) {
88 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 88 ExtensionService* service = browser()->profile()->GetExtensionService();
89 89
90 // Count the number of non-component extensions. 90 // Count the number of non-component extensions.
91 int found_extensions = 0; 91 int found_extensions = 0;
92 for (size_t i = 0; i < service->extensions()->size(); i++) 92 for (size_t i = 0; i < service->extensions()->size(); i++)
93 if (service->extensions()->at(i)->location() != Extension::COMPONENT) 93 if (service->extensions()->at(i)->location() != 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());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 #if defined(OS_MACOSX) 161 #if defined(OS_MACOSX)
162 #define MAYBE_NoFileAccess DISABLED_NoFileAccess 162 #define MAYBE_NoFileAccess DISABLED_NoFileAccess
163 #else 163 #else
164 #define MAYBE_NoFileAccess NoFileAccess 164 #define MAYBE_NoFileAccess NoFileAccess
165 #endif 165 #endif
166 // Tests that disallowing file access on an extension prevents it from injecting 166 // Tests that disallowing file access on an extension prevents it from injecting
167 // script into a page with a file URL. 167 // script into a page with a file URL.
168 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { 168 IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) {
169 WaitForServicesToStart(num_expected_extensions_, true); 169 WaitForServicesToStart(num_expected_extensions_, true);
170 170
171 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 171 ExtensionService* service = browser()->profile()->GetExtensionService();
172 for (size_t i = 0; i < service->extensions()->size(); ++i) { 172 for (size_t i = 0; i < service->extensions()->size(); ++i) {
173 if (service->extensions()->at(i)->location() == Extension::COMPONENT) 173 if (service->extensions()->at(i)->location() == Extension::COMPONENT)
174 continue; 174 continue;
175 if (service->AllowFileAccess(service->extensions()->at(i))) { 175 if (service->AllowFileAccess(service->extensions()->at(i))) {
176 service->SetAllowFileAccess(service->extensions()->at(i), false); 176 service->SetAllowFileAccess(service->extensions()->at(i), false);
177 ui_test_utils::WaitForNotification( 177 ui_test_utils::WaitForNotification(
178 NotificationType::USER_SCRIPTS_UPDATED); 178 NotificationType::USER_SCRIPTS_UPDATED);
179 } 179 }
180 } 180 }
181 181
(...skipping 15 matching lines...) Expand all
197 .AppendASCII("Extensions") 197 .AppendASCII("Extensions")
198 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 198 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
199 .AppendASCII("1.0.0.0"); 199 .AppendASCII("1.0.0.0");
200 } 200 }
201 }; 201 };
202 202
203 IN_PROC_BROWSER_TEST_F(ExtensionsLoadTest, Test) { 203 IN_PROC_BROWSER_TEST_F(ExtensionsLoadTest, Test) {
204 WaitForServicesToStart(1, true); 204 WaitForServicesToStart(1, true);
205 TestInjection(true, true); 205 TestInjection(true, true);
206 } 206 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_sidebar_api.cc ('k') | chrome/browser/extensions/extension_tabs_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698