OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ |
6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ | 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
12 #include "extensions/common/manifest_handler.h" | 12 #include "extensions/common/manifest_handler.h" |
13 #include "extensions/common/url_pattern_set.h" | 13 #include "extensions/common/url_pattern_set.h" |
14 #include "extensions/common/user_script.h" | 14 #include "extensions/common/user_script.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 namespace api { | |
19 namespace manifest_types { | |
20 struct Automation; | |
21 } | |
22 } | |
23 | |
18 class URLPatternSet; | 24 class URLPatternSet; |
25 class AutomationManifestPermission; | |
19 | 26 |
20 namespace automation_errors { | 27 namespace automation_errors { |
21 extern const char kErrorInvalidMatchPattern[]; | 28 extern const char kErrorInvalidMatchPattern[]; |
22 extern const char kErrorDesktopTrueInteractFalse[]; | 29 extern const char kErrorDesktopTrueInteractFalse[]; |
23 extern const char kErrorDesktopTrueMatchesSpecified[]; | 30 extern const char kErrorDesktopTrueMatchesSpecified[]; |
24 extern const char kErrorURLMalformed[]; | 31 extern const char kErrorURLMalformed[]; |
25 extern const char kErrorInvalidMatch[]; | 32 extern const char kErrorInvalidMatch[]; |
26 extern const char kErrorNoMatchesProvided[]; | 33 extern const char kErrorNoMatchesProvided[]; |
27 } | 34 } |
28 | 35 |
29 // Parses the automation manifest entry. | |
30 class AutomationHandler : public ManifestHandler { | |
31 public: | |
32 AutomationHandler(); | |
33 virtual ~AutomationHandler(); | |
34 | |
35 virtual bool Parse(Extension* extensions, base::string16* error) OVERRIDE; | |
36 | |
37 private: | |
38 virtual const std::vector<std::string> Keys() const OVERRIDE; | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(AutomationHandler); | |
41 }; | |
42 | |
43 // The parsed form of the automation manifest entry. | 36 // The parsed form of the automation manifest entry. |
44 struct AutomationInfo : public Extension::ManifestData { | 37 struct AutomationInfo : public Extension::ManifestData { |
45 public: | 38 public: |
46 static const AutomationInfo* Get(const Extension* extension); | 39 static const AutomationInfo* Get(const Extension* extension); |
47 static scoped_ptr<AutomationInfo> FromValue( | 40 static scoped_ptr<AutomationInfo> FromValue( |
48 const base::Value& value, | 41 const base::Value& value, |
49 std::vector<InstallWarning>* install_warnings, | 42 std::vector<InstallWarning>* install_warnings, |
50 base::string16* error); | 43 base::string16* error); |
51 | 44 |
45 static scoped_ptr<base::Value> ToValue(const AutomationInfo& info); | |
52 virtual ~AutomationInfo(); | 46 virtual ~AutomationInfo(); |
53 | 47 |
54 // true if the extension has requested 'desktop' permission. | 48 // true if the extension has requested 'desktop' permission. |
55 const bool desktop; | 49 const bool desktop; |
56 | 50 |
57 // Returns the list of hosts that this extension can request an automation | 51 // Returns the list of hosts that this extension can request an automation |
58 // tree from. | 52 // tree from. |
59 const URLPatternSet matches; | 53 const URLPatternSet matches; |
60 | 54 |
61 // Whether the extension is allowed interactive access (true) or read-only | 55 // Whether the extension is allowed interactive access (true) or read-only |
62 // access (false) to the automation tree. | 56 // access (false) to the automation tree. |
63 const bool interact; | 57 const bool interact; |
64 | 58 |
65 // Whether any matches were specified (false if automation was specified as a | 59 private: |
66 // boolean, or no matches key was provided. | 60 AutomationInfo(); |
67 const bool specified_matches; | 61 AutomationInfo(bool desktop, URLPatternSet matches, bool interact); |
62 | |
63 static scoped_ptr<api::manifest_types::Automation> AsManifestType( | |
64 const AutomationInfo& info); | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(AutomationInfo); | |
67 friend class AutomationManifestPermission; | |
68 friend class AutomationHandler; | |
69 }; | |
70 | |
71 // Parses the automation manifest entry. | |
72 class AutomationHandler : public ManifestHandler { | |
73 public: | |
74 AutomationHandler(); | |
75 virtual ~AutomationHandler(); | |
68 | 76 |
69 private: | 77 private: |
70 AutomationInfo(); | 78 // ManifestHandler implementation |
Devlin
2014/07/21 23:43:53
nit: either a ':' or a '.' at the end.
aboxhall
2014/07/22 17:00:09
Done.
| |
71 AutomationInfo(bool desktop, | 79 virtual bool Parse(Extension* extensions, base::string16* error) OVERRIDE; |
72 const URLPatternSet& matches, | 80 |
73 bool interact, | 81 virtual ManifestPermission* CreatePermission() OVERRIDE; |
74 bool specified_matches); | 82 virtual ManifestPermission* CreateInitialRequiredPermission( |
75 DISALLOW_COPY_AND_ASSIGN(AutomationInfo); | 83 const Extension* extension) OVERRIDE; |
84 virtual const std::vector<std::string> Keys() const OVERRIDE; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(AutomationHandler); | |
76 }; | 87 }; |
77 | 88 |
78 } // namespace extensions | 89 } // namespace extensions |
79 | 90 |
80 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ | 91 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ |
OLD | NEW |