Index: chrome/browser/extensions/extension_apitest.cc |
diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc |
index 893a25d49dff91686b211c8f8e95580fd1385b69..624f036885755a4844e44fb4ab8c51253a9c9ec4 100644 |
--- a/chrome/browser/extensions/extension_apitest.cc |
+++ b/chrome/browser/extensions/extension_apitest.cc |
@@ -202,28 +202,29 @@ bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, |
} |
} |
-// Test that exactly one extension loaded. |
+// Test that exactly one extension is loaded, and return it. |
const Extension* ExtensionApiTest::GetSingleLoadedExtension() { |
ExtensionService* service = browser()->profile()->GetExtensionService(); |
- int found_extension_index = -1; |
- for (size_t i = 0; i < service->extensions()->size(); ++i) { |
+ const Extension* extension = NULL; |
+ for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
+ it != service->extensions()->end(); ++it) { |
// Ignore any component extensions. They are automatically loaded into all |
// profiles and aren't the extension we're looking for here. |
- if (service->extensions()->at(i)->location() == Extension::COMPONENT) |
+ if ((*it)->location() == Extension::COMPONENT) |
continue; |
- if (found_extension_index != -1) { |
+ if (extension != NULL) { |
+ // TODO(yoz): this is misleading; it counts component extensions. |
message_ = base::StringPrintf( |
"Expected only one extension to be present. Found %u.", |
static_cast<unsigned>(service->extensions()->size())); |
return NULL; |
} |
- found_extension_index = static_cast<int>(i); |
+ extension = *it; |
} |
- const Extension* extension = service->extensions()->at(found_extension_index); |
if (!extension) { |
message_ = "extension pointer is NULL."; |
return NULL; |