1 // Copyright (c) 2013 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 CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_HOST_MANIFEST_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_HOST_MANIFEST_H_
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "extensions/common/url_pattern_set.h"
16 class DictionaryValue
;
19 namespace extensions
{
21 class NativeMessagingHostManifest
{
27 ~NativeMessagingHostManifest();
29 // Verifies that the name is valid. Valid names must match regular expression
30 // "([a-z0-9_]+.)*[a-z0-9_]+".
31 static bool IsValidName(const std::string
& name
);
33 // Load manifest file from |file_path|.
34 static scoped_ptr
<NativeMessagingHostManifest
> Load(
35 const base::FilePath
& file_path
,
36 std::string
* error_message
);
38 const std::string
& name() const { return name_
; }
39 const std::string
& description() const { return description_
; }
40 HostInterface
interface() const { return interface_
; }
41 const base::FilePath
& path() const { return path_
; }
42 const URLPatternSet
& allowed_origins() const { return allowed_origins_
; }
45 NativeMessagingHostManifest();
47 // Parses manifest |dictionary|. In case of an error sets |error_message| and
49 bool Parse(base::DictionaryValue
* dictionary
, std::string
* error_message
);
52 std::string description_
;
53 HostInterface interface_
;
55 URLPatternSet allowed_origins_
;
57 DISALLOW_COPY_AND_ASSIGN(NativeMessagingHostManifest
);
60 } // namespace extensions
62 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_HOST_MANIFEST_H_