| 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 <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "extensions/common/extension.h" | 12 #include "extensions/common/extension.h" |
| 13 #include "extensions/common/manifest_handler.h" | 13 #include "extensions/common/manifest_handler.h" |
| 14 #include "extensions/common/url_pattern_set.h" | 14 #include "extensions/common/url_pattern_set.h" |
| 15 #include "extensions/common/user_script.h" | 15 #include "extensions/common/user_script.h" |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 namespace api { | 19 namespace api { |
| 20 namespace manifest_types { | 20 namespace manifest_types { |
| 21 struct Automation; | 21 struct Automation; |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 class URLPatternSet; | 25 class URLPatternSet; |
| 26 class AutomationManifestPermission; | 26 class AutomationManifestPermission; |
| 27 | 27 |
| 28 namespace automation_errors { | 28 namespace automation_errors { |
| 29 extern const char kErrorInvalidMatchPattern[]; | 29 extern const char kErrorInvalidMatchPattern[]; |
| 30 extern const char kErrorDesktopTrueInteractFalse[]; | 30 extern const char kErrorDesktopTrueInteractFalse[]; |
| 31 extern const char kErrorDesktopTrueMatchesSpecified[]; | 31 extern const char kErrorDesktopTrueMatchesSpecified[]; |
| 32 extern const char kErrorURLMalformed[]; | 32 extern const char kErrorURLMalformed[]; |
| 33 extern const char kErrorInvalidMatch[]; | 33 extern const char kErrorInvalidMatch[]; |
| 34 extern const char kErrorNoMatchesProvided[]; | 34 extern const char kErrorNoMatchesProvided[]; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // The parsed form of the automation manifest entry. | 37 // The parsed form of the automation manifest entry. |
| 38 struct AutomationInfo : public Extension::ManifestData { | 38 struct AutomationInfo : public Extension::ManifestData { |
| 39 public: | 39 public: |
| 40 static const AutomationInfo* Get(const Extension* extension); | 40 static const AutomationInfo* Get(const Extension* extension); |
| 41 static scoped_ptr<AutomationInfo> FromValue( | 41 static std::unique_ptr<AutomationInfo> FromValue( |
| 42 const base::Value& value, | 42 const base::Value& value, |
| 43 std::vector<InstallWarning>* install_warnings, | 43 std::vector<InstallWarning>* install_warnings, |
| 44 base::string16* error); | 44 base::string16* error); |
| 45 | 45 |
| 46 static scoped_ptr<base::Value> ToValue(const AutomationInfo& info); | 46 static std::unique_ptr<base::Value> ToValue(const AutomationInfo& info); |
| 47 ~AutomationInfo() override; | 47 ~AutomationInfo() override; |
| 48 | 48 |
| 49 // true if the extension has requested 'desktop' permission. | 49 // true if the extension has requested 'desktop' permission. |
| 50 const bool desktop; | 50 const bool desktop; |
| 51 | 51 |
| 52 // Returns the list of hosts that this extension can request an automation | 52 // Returns the list of hosts that this extension can request an automation |
| 53 // tree from. | 53 // tree from. |
| 54 const URLPatternSet matches; | 54 const URLPatternSet matches; |
| 55 | 55 |
| 56 // Whether the extension is allowed interactive access (true) or read-only | 56 // Whether the extension is allowed interactive access (true) or read-only |
| 57 // access (false) to the automation tree. | 57 // access (false) to the automation tree. |
| 58 const bool interact; | 58 const bool interact; |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 AutomationInfo(); | 61 AutomationInfo(); |
| 62 AutomationInfo(bool desktop, URLPatternSet matches, bool interact); | 62 AutomationInfo(bool desktop, URLPatternSet matches, bool interact); |
| 63 | 63 |
| 64 static scoped_ptr<api::manifest_types::Automation> AsManifestType( | 64 static std::unique_ptr<api::manifest_types::Automation> AsManifestType( |
| 65 const AutomationInfo& info); | 65 const AutomationInfo& info); |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(AutomationInfo); | 67 DISALLOW_COPY_AND_ASSIGN(AutomationInfo); |
| 68 friend class AutomationManifestPermission; | 68 friend class AutomationManifestPermission; |
| 69 friend class AutomationHandler; | 69 friend class AutomationHandler; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 // Parses the automation manifest entry. | 72 // Parses the automation manifest entry. |
| 73 class AutomationHandler : public ManifestHandler { | 73 class AutomationHandler : public ManifestHandler { |
| 74 public: | 74 public: |
| 75 AutomationHandler(); | 75 AutomationHandler(); |
| 76 ~AutomationHandler() override; | 76 ~AutomationHandler() override; |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 // ManifestHandler implementation. | 79 // ManifestHandler implementation. |
| 80 bool Parse(Extension* extensions, base::string16* error) override; | 80 bool Parse(Extension* extensions, base::string16* error) override; |
| 81 | 81 |
| 82 ManifestPermission* CreatePermission() override; | 82 ManifestPermission* CreatePermission() override; |
| 83 ManifestPermission* CreateInitialRequiredPermission( | 83 ManifestPermission* CreateInitialRequiredPermission( |
| 84 const Extension* extension) override; | 84 const Extension* extension) override; |
| 85 const std::vector<std::string> Keys() const override; | 85 const std::vector<std::string> Keys() const override; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(AutomationHandler); | 87 DISALLOW_COPY_AND_ASSIGN(AutomationHandler); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 } // namespace extensions | 90 } // namespace extensions |
| 91 | 91 |
| 92 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ | 92 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ |
| OLD | NEW |