1 // Copyright 2015 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 #ifndef EXTENSIONS_COMMON_API_DECLARATIVE_DECLARATIVE_MANIFEST_DATA_H_
6 #define EXTENSIONS_COMMON_API_DECLARATIVE_DECLARATIVE_MANIFEST_DATA_H_
10 #include "base/memory/linked_ptr.h"
11 #include "base/strings/string16.h"
12 #include "extensions/common/api/events.h"
13 #include "extensions/common/extension.h"
14 #include "extensions/common/manifest_handler.h"
16 namespace extensions
{
18 // The parsed form of the "event_rules" manifest entry.
19 class DeclarativeManifestData
: public Extension::ManifestData
{
21 typedef extensions::api::events::Rule Rule
;
23 DeclarativeManifestData();
24 ~DeclarativeManifestData() override
;
26 // Gets the DeclarativeManifestData for |extension|, or NULL if none was
28 static DeclarativeManifestData
* Get(const Extension
* extension
);
30 // Tries to construct the info based on |value|, as it would have appeared in
31 // the manifest. Sets |error| and returns an empty scoped_ptr on failure.
32 static scoped_ptr
<DeclarativeManifestData
> FromValue(const base::Value
& value
,
33 base::string16
* error
);
35 std::vector
<linked_ptr
<DeclarativeManifestData::Rule
>>& RulesForEvent(
36 const std::string
& event
);
39 std::map
<std::string
, std::vector
<linked_ptr
<Rule
>>> event_rules_map_
;
40 DISALLOW_COPY_AND_ASSIGN(DeclarativeManifestData
);
43 } // namespace extensions
45 #endif // EXTENSIONS_COMMON_API_DECLARATIVE_DECLARATIVE_MANIFEST_DATA_H_