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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ 7 8 #include <string> 9 10 #include "base/memory/scoped_ptr.h" 11 #include "extensions/common/extension.h" 12 #include "extensions/common/manifest_handler.h" 13 #include "extensions/common/url_pattern_set.h" 14 #include "extensions/common/user_script.h" 15 16 namespace extensions { 17 18 class URLPatternSet; 19 20 namespace automation_errors { 21 extern const char kErrorInvalidMatchPattern[]; 22 extern const char kErrorDesktopTrueInteractFalse[]; 23 extern const char kErrorDesktopTrueMatchesSpecified[]; 24 extern const char kErrorURLMalformed[]; 25 extern const char kErrorInvalidMatch[]; 26 extern const char kErrorNoMatchesProvided[]; 27 } 28 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. 44 struct AutomationInfo : public Extension::ManifestData { 45 public: 46 static const AutomationInfo* Get(const Extension* extension); 47 static scoped_ptr<AutomationInfo> FromValue( 48 const base::Value& value, 49 std::vector<InstallWarning>* install_warnings, 50 base::string16* error); 51 52 virtual ~AutomationInfo(); 53 54 // true if the extension has requested 'desktop' permission. 55 const bool desktop; 56 57 // Returns the list of hosts that this extension can request an automation 58 // tree from. 59 const URLPatternSet matches; 60 61 // Whether the extension is allowed interactive access (true) or read-only 62 // access (false) to the automation tree. 63 const bool interact; 64 65 // Whether any matches were specified (false if automation was specified as a 66 // boolean, or no matches key was provided. 67 const bool specified_matches; 68 69 private: 70 AutomationInfo(); 71 AutomationInfo(bool desktop, 72 const URLPatternSet& matches, 73 bool interact, 74 bool specified_matches); 75 DISALLOW_COPY_AND_ASSIGN(AutomationInfo); 76 }; 77 78 } // namespace extensions 79 80 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ 81