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

Unified Diff: chrome/browser/extensions/api/developer_private/extension_info_generator.cc

Issue 1049483003: [Extensions] Update extensions UI to observe events and add test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/developer_private/extension_info_generator.cc
diff --git a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
index 81bf3a5684a2079847a541afb504588a20ea87d3..45817278c2fdf3e0cba2b89eab9b35f1034a416c 100644
--- a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
+++ b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
@@ -71,8 +71,7 @@ developer::ExtensionType GetExtensionType(Manifest::Type manifest_type) {
// Populates the common fields of an extension error.
template <typename ErrorType>
-void PopulateErrorBase(const ExtensionError& error,
- ErrorType* out) {
+void PopulateErrorBase(const ExtensionError& error, ErrorType* out) {
CHECK(out);
out->type = error.type() == ExtensionError::MANIFEST_ERROR ?
developer::ERROR_TYPE_MANIFEST : developer::ERROR_TYPE_RUNTIME;
@@ -365,6 +364,25 @@ ExtensionInfoGenerator::CreateExtensionInfo(const Extension& extension,
return info.Pass();
}
+scoped_ptr<api::developer_private::ExtensionInfo>
+ExtensionInfoGenerator::CreateExtensionInfo(const std::string& id) {
+ developer::ExtensionState state = developer::EXTENSION_STATE_ENABLED;
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_);
+ const Extension* extension = registry->enabled_extensions().GetByID(id);
Dan Beam 2015/04/06 23:53:12 nit: this is easier for me to read: const Extensi
Devlin 2015/04/07 16:07:54 As you wish.
+ if (!extension &&
+ (extension = registry->disabled_extensions().GetByID(id)) != nullptr) {
+ state = developer::EXTENSION_STATE_DISABLED;
+ } else if (!extension &&
+ (extension =
+ registry->terminated_extensions().GetByID(id)) != nullptr) {
+ state = developer::EXTENSION_STATE_TERMINATED;
+ }
+ scoped_ptr<api::developer_private::ExtensionInfo> info;
+ if (extension)
+ info = CreateExtensionInfo(*extension, state);
+ return info.Pass();
+}
+
ExtensionInfoGenerator::ExtensionInfoList
ExtensionInfoGenerator::CreateExtensionsInfo(bool include_disabled,
bool include_terminated) {

Powered by Google App Engine
This is Rietveld 408576698