blob: ddd33481c42cd1cd35ae1d7dcc3c0635ca417d93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_EXTENSIONS_API_COMMANDS_COMMANDS_HANDLER_H_
#define CHROME_COMMON_EXTENSIONS_API_COMMANDS_COMMANDS_HANDLER_H_
#include <string>
#include "base/memory/scoped_ptr.h"
#include "chrome/common/extensions/command.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_handler.h"
namespace extensions {
struct CommandsInfo : public Extension::ManifestData {
CommandsInfo();
~CommandsInfo() override;
// Optional list of commands (keyboard shortcuts).
// These commands are the commands which the extension wants to use, which are
// not necessarily the ones it can use, as it might be inactive (see also
// Get*Command[s] in CommandService).
scoped_ptr<Command> browser_action_command;
scoped_ptr<Command> page_action_command;
CommandMap named_commands;
static const Command* GetBrowserActionCommand(const Extension* extension);
static const Command* GetPageActionCommand(const Extension* extension);
static const CommandMap* GetNamedCommands(const Extension* extension);
};
// Parses the "commands" manifest key.
class CommandsHandler : public ManifestHandler {
public:
CommandsHandler();
~CommandsHandler() override;
bool Parse(Extension* extension, base::string16* error) override;
bool AlwaysParseForType(Manifest::Type type) const override;
private:
// If the extension defines a browser action, but no command for it, then
// we synthesize a generic one, so the user can configure a shortcut for it.
// No keyboard shortcut will be assigned to it, until the user selects one.
void MaybeSetBrowserActionDefault(const Extension* extension,
CommandsInfo* info);
const std::vector<std::string> Keys() const override;
DISALLOW_COPY_AND_ASSIGN(CommandsHandler);
};
} // namespace extensions
#endif // CHROME_COMMON_EXTENSIONS_API_COMMANDS_COMMANDS_HANDLER_H_
|