1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/manifest_handlers/synthesize_browser_action_handler.h"
7 #include "chrome/common/extensions/api/extension_action/action_info.h"
8 #include "extensions/common/feature_switch.h"
9 #include "extensions/common/manifest_constants.h"
11 namespace extensions {
13 SynthesizeBrowserActionHandler::SynthesizeBrowserActionHandler() {
16 SynthesizeBrowserActionHandler::~SynthesizeBrowserActionHandler() {
19 bool SynthesizeBrowserActionHandler::Parse(Extension* extension,
20 base::string16* error) {
21 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled())
22 return true; // Do nothing.
24 if (extension->location() == Manifest::COMPONENT ||
25 extension->location() == Manifest::EXTERNAL_COMPONENT)
26 return true; // Return no error (we're done).
28 if (extension->manifest()->HasKey(manifest_keys::kSynthesizeBrowserAction))
29 return false; // This key is reserved, no extension should be using it.
31 if (!extension->manifest()->HasKey(manifest_keys::kBrowserAction) &&
32 !extension->manifest()->HasKey(manifest_keys::kPageAction))
33 ActionInfo::SetBrowserActionInfo(extension, new ActionInfo());
37 bool SynthesizeBrowserActionHandler::AlwaysParseForType(
38 Manifest::Type type) const {
39 return type == Manifest::TYPE_EXTENSION;
42 const std::vector<std::string> SynthesizeBrowserActionHandler::Keys() const {
43 return SingleKey(manifest_keys::kSynthesizeBrowserAction);
46 } // namespace extensions