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

Side by Side Diff: chrome/browser/extensions/extension_apitest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "chrome/browser/extensions/extension_test_api.h" 9 #include "chrome/browser/extensions/extension_test_api.h"
10 #include "chrome/browser/extensions/extensions_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/notification_registrar.h" 13 #include "chrome/common/notification_registrar.h"
14 #include "chrome/test/ui_test_utils.h" 14 #include "chrome/test/ui_test_utils.h"
15 15
16 namespace { 16 namespace {
17 17
18 const char kTestServerPort[] = "testServer.port"; 18 const char kTestServerPort[] = "testServer.port";
19 19
20 }; // namespace 20 }; // namespace
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 if (!page_url.empty()) { 136 if (!page_url.empty()) {
137 GURL url = GURL(page_url); 137 GURL url = GURL(page_url);
138 138
139 // Note: We use is_valid() here in the expectation that the provided url 139 // Note: We use is_valid() here in the expectation that the provided url
140 // may lack a scheme & host and thus be a relative url within the loaded 140 // may lack a scheme & host and thus be a relative url within the loaded
141 // extension. 141 // extension.
142 if (!url.is_valid()) { 142 if (!url.is_valid()) {
143 DCHECK(!std::string(extension_name).empty()) << 143 DCHECK(!std::string(extension_name).empty()) <<
144 "Relative page_url given with no extension_name"; 144 "Relative page_url given with no extension_name";
145 145
146 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 146 ExtensionService* service = browser()->profile()->GetExtensionService();
147 const Extension* extension = 147 const Extension* extension =
148 service->GetExtensionById(last_loaded_extension_id_, false); 148 service->GetExtensionById(last_loaded_extension_id_, false);
149 if (!extension) 149 if (!extension)
150 return false; 150 return false;
151 151
152 url = extension->GetResourceURL(page_url); 152 url = extension->GetResourceURL(page_url);
153 } 153 }
154 154
155 LOG(ERROR) << "Loading page url: " << url.spec(); 155 LOG(ERROR) << "Loading page url: " << url.spec();
156 ui_test_utils::NavigateToURL(browser(), url); 156 ui_test_utils::NavigateToURL(browser(), url);
157 } 157 }
158 158
159 if (!catcher.GetNextResult()) { 159 if (!catcher.GetNextResult()) {
160 message_ = catcher.message(); 160 message_ = catcher.message();
161 return false; 161 return false;
162 } else { 162 } else {
163 return true; 163 return true;
164 } 164 }
165 } 165 }
166 166
167 // Test that exactly one extension loaded. 167 // Test that exactly one extension loaded.
168 const Extension* ExtensionApiTest::GetSingleLoadedExtension() { 168 const Extension* ExtensionApiTest::GetSingleLoadedExtension() {
169 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 169 ExtensionService* service = browser()->profile()->GetExtensionService();
170 170
171 int found_extension_index = -1; 171 int found_extension_index = -1;
172 for (size_t i = 0; i < service->extensions()->size(); ++i) { 172 for (size_t i = 0; i < service->extensions()->size(); ++i) {
173 // Ignore any component extensions. They are automatically loaded into all 173 // Ignore any component extensions. They are automatically loaded into all
174 // profiles and aren't the extension we're looking for here. 174 // profiles and aren't the extension we're looking for here.
175 if (service->extensions()->at(i)->location() == Extension::COMPONENT) 175 if (service->extensions()->at(i)->location() == Extension::COMPONENT)
176 continue; 176 continue;
177 177
178 if (found_extension_index != -1) { 178 if (found_extension_index != -1) {
179 message_ = base::StringPrintf( 179 message_ = base::StringPrintf(
(...skipping 23 matching lines...) Expand all
203 test_config_->SetInteger(kTestServerPort, 203 test_config_->SetInteger(kTestServerPort,
204 test_server()->host_port_pair().port()); 204 test_server()->host_port_pair().port());
205 205
206 return true; 206 return true;
207 } 207 }
208 208
209 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { 209 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) {
210 ExtensionBrowserTest::SetUpCommandLine(command_line); 210 ExtensionBrowserTest::SetUpCommandLine(command_line);
211 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); 211 test_data_dir_ = test_data_dir_.AppendASCII("api_test");
212 } 212 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_accessibility_api.cc ('k') | chrome/browser/extensions/extension_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698