Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: chrome/common/extensions/manifest_handlers/automation.h

Issue 377553003: Create a ManifestPermission implementation for Automation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Devlin review comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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);
40 static scoped_ptr<AutomationInfo> FromValue(const base::Value& value);
47 static scoped_ptr<AutomationInfo> FromValue( 41 static scoped_ptr<AutomationInfo> FromValue(
48 const base::Value& value, 42 const base::Value& value,
49 std::vector<InstallWarning>* install_warnings, 43 std::vector<InstallWarning>* install_warnings,
50 base::string16* error); 44 base::string16* error);
45 static scoped_ptr<const AutomationInfo> Clone(const AutomationInfo& info);
51 46
47 static scoped_ptr<base::Value> ToValue(const AutomationInfo& info);
48 static scoped_ptr<api::manifest_types::Automation> AsManifestType(
49 const AutomationInfo& info);
52 virtual ~AutomationInfo(); 50 virtual ~AutomationInfo();
53 51
54 // true if the extension has requested 'desktop' permission. 52 // true if the extension has requested 'desktop' permission.
55 const bool desktop; 53 const bool desktop;
56 54
57 // Returns the list of hosts that this extension can request an automation 55 // Returns the list of hosts that this extension can request an automation
58 // tree from. 56 // tree from.
59 const URLPatternSet matches; 57 const URLPatternSet matches;
60 58
61 // Whether the extension is allowed interactive access (true) or read-only 59 // Whether the extension is allowed interactive access (true) or read-only
62 // access (false) to the automation tree. 60 // access (false) to the automation tree.
63 const bool interact; 61 const bool interact;
64 62
65 // Whether any matches were specified (false if automation was specified as a 63 private:
66 // boolean, or no matches key was provided. 64 AutomationInfo();
67 const bool specified_matches; 65 AutomationInfo(bool desktop, URLPatternSet matches, bool interact);
66
67 DISALLOW_COPY_AND_ASSIGN(AutomationInfo);
68 friend class AutomationManifestPermission;
69 friend class AutomationHandler;
70 };
71
72 // Parses the automation manifest entry.
73 class AutomationHandler : public ManifestHandler {
74 public:
75 AutomationHandler();
76 virtual ~AutomationHandler();
77
78 virtual bool Parse(Extension* extensions, base::string16* error) OVERRIDE;
Devlin 2014/07/21 19:45:36 nit: If we don't need these exposed, let's go ahea
aboxhall 2014/07/21 22:44:11 Done.
79
80 virtual ManifestPermission* CreatePermission() OVERRIDE;
81 virtual ManifestPermission* CreateInitialRequiredPermission(
82 const Extension* extension) OVERRIDE;
68 83
69 private: 84 private:
70 AutomationInfo(); 85 virtual const std::vector<std::string> Keys() const OVERRIDE;
71 AutomationInfo(bool desktop, 86
72 const URLPatternSet& matches, 87 DISALLOW_COPY_AND_ASSIGN(AutomationHandler);
73 bool interact,
74 bool specified_matches);
75 DISALLOW_COPY_AND_ASSIGN(AutomationInfo);
76 }; 88 };
77 89
78 } // namespace extensions 90 } // namespace extensions
79 91
80 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ 92 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698