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

Unified Diff: chrome/common/extensions/api/commands/commands_handler.cc

Issue 12084034: Change manifest handler interface to always (implicitly) pass the entire manifest to handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tts, TODO Created 7 years, 11 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/common/extensions/api/commands/commands_handler.cc
diff --git a/chrome/common/extensions/api/commands/commands_handler.cc b/chrome/common/extensions/api/commands/commands_handler.cc
index 33ab34459106a75f94dcd439fde33cf33456fe6d..8cfafcc22ec700f006a28d05cafe0d5345d1cbf9 100644
--- a/chrome/common/extensions/api/commands/commands_handler.cc
+++ b/chrome/common/extensions/api/commands/commands_handler.cc
@@ -11,6 +11,8 @@
#include "chrome/common/extensions/manifest.h"
#include "extensions/common/error_utils.h"
+namespace keys = extension_manifest_keys;
+
namespace extensions {
namespace {
@@ -29,28 +31,28 @@ CommandsInfo::~CommandsInfo() {
const Command* CommandsInfo::GetBrowserActionCommand(
const Extension* extension) {
CommandsInfo* info = static_cast<CommandsInfo*>(
- extension->GetManifestData(extension_manifest_keys::kCommands));
+ extension->GetManifestData(keys::kCommands));
return info ? info->browser_action_command.get() : NULL;
}
// static
const Command* CommandsInfo::GetPageActionCommand(const Extension* extension) {
CommandsInfo* info = static_cast<CommandsInfo*>(
- extension->GetManifestData(extension_manifest_keys::kCommands));
+ extension->GetManifestData(keys::kCommands));
return info ? info->page_action_command.get() : NULL;
}
// static
const Command* CommandsInfo::GetScriptBadgeCommand(const Extension* extension) {
CommandsInfo* info = static_cast<CommandsInfo*>(
- extension->GetManifestData(extension_manifest_keys::kCommands));
+ extension->GetManifestData(keys::kCommands));
return info ? info->script_badge_command.get() : NULL;
}
// static
const CommandMap* CommandsInfo::GetNamedCommands(const Extension* extension) {
CommandsInfo* info = static_cast<CommandsInfo*>(
- extension->GetManifestData(extension_manifest_keys::kCommands));
+ extension->GetManifestData(keys::kCommands));
return info ? &info->named_commands : NULL;
}
@@ -60,11 +62,17 @@ CommandsHandler::CommandsHandler() {
CommandsHandler::~CommandsHandler() {
}
-bool CommandsHandler::Parse(const base::Value* value,
- Extension* extension,
- string16* error) {
+bool CommandsHandler::Parse(Extension* extension, string16* error) {
+ if (!extension->manifest()->HasKey(keys::kCommands)) {
+ scoped_ptr<CommandsInfo> commands_info(new CommandsInfo);
+ MaybeSetBrowserActionDefault(extension, commands_info.get());
+ extension->SetManifestData(keys::kCommands,
+ commands_info.release());
+ return true;
+ }
+
const base::DictionaryValue* dict = NULL;
- if (!value->GetAsDictionary(&dict)) {
+ if (!extension->manifest()->GetDictionary(keys::kCommands, &dict)) {
*error = ASCIIToUTF16(extension_manifest_errors::kInvalidCommandsKey);
return false;
}
@@ -112,23 +120,20 @@ bool CommandsHandler::Parse(const base::Value* value,
MaybeSetBrowserActionDefault(extension, commands_info.get());
- extension->SetManifestData(extension_manifest_keys::kCommands,
+ extension->SetManifestData(keys::kCommands,
commands_info.release());
return true;
}
-bool CommandsHandler::HasNoKey(Extension* extension,
- string16* error) {
- scoped_ptr<CommandsInfo> commands_info(new CommandsInfo);
- MaybeSetBrowserActionDefault(extension, commands_info.get());
- extension->SetManifestData(extension_manifest_keys::kCommands,
- commands_info.release());
- return true;
+bool CommandsHandler::AlwaysParseForType(Extension::Type type) {
+ return type == Extension::TYPE_EXTENSION ||
+ type == Extension::TYPE_LEGACY_PACKAGED_APP ||
+ type == Extension::TYPE_PLATFORM_APP;
}
void CommandsHandler::MaybeSetBrowserActionDefault(const Extension* extension,
CommandsInfo* info) {
- if (extension->manifest()->HasKey(extension_manifest_keys::kBrowserAction) &&
+ if (extension->manifest()->HasKey(keys::kBrowserAction) &&
!info->browser_action_command.get()) {
info->browser_action_command.reset(new Command(
extension_manifest_values::kBrowserActionCommandEvent, string16(), ""));

Powered by Google App Engine
This is Rietveld 408576698