OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_TEST_WEBDRIVER_WEBDRIVER_CAPABILITIES_PARSER_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_WEBDRIVER_CAPABILITIES_PARSER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/command_line.h" |
| 14 #include "base/file_path.h" |
| 15 |
| 16 namespace base { |
| 17 class DictionaryValue; |
| 18 class Value; |
| 19 } |
| 20 |
| 21 namespace webdriver { |
| 22 |
| 23 class Error; |
| 24 |
| 25 // Contains all the capabilities that a user may request when starting a |
| 26 // new session. |
| 27 struct Capabilities { |
| 28 Capabilities(); |
| 29 ~Capabilities(); |
| 30 |
| 31 // Command line to use for starting Chrome. |
| 32 CommandLine command; |
| 33 |
| 34 // Channel ID to use for connecting to an already running Chrome. |
| 35 std::string channel; |
| 36 |
| 37 // Whether the lifetime of the started Chrome browser process should be |
| 38 // bound to ChromeDriver's process. If true, Chrome will not quit if |
| 39 // ChromeDriver dies. |
| 40 bool detach; |
| 41 |
| 42 // List of paths for extensions to install on startup. |
| 43 std::vector<FilePath> extensions; |
| 44 |
| 45 // Whether Chrome should not block when loading. |
| 46 bool load_async; |
| 47 |
| 48 // Whether Chrome should simulate input events using OS APIs instead of |
| 49 // WebKit APIs. |
| 50 bool native_events; |
| 51 |
| 52 // Path to a custom profile to use. |
| 53 FilePath profile; |
| 54 |
| 55 // Whether ChromeDriver should log verbosely. |
| 56 bool verbose; |
| 57 }; |
| 58 |
| 59 // Parses the given capabilities dictionary to produce a |Capabilities| |
| 60 // instance. |
| 61 // See webdriver's desired capabilities for more info. |
| 62 class CapabilitiesParser { |
| 63 public: |
| 64 // Create a new parser. |capabilities_dict| is the dictionary for all |
| 65 // of the user's desired capabilities. |root_path| is the root directory |
| 66 // to use for writing any necessary files to disk. This function will not |
| 67 // create it or delete it. All files written to disk will be placed in |
| 68 // this directory. |
| 69 CapabilitiesParser(const base::DictionaryValue* capabilities_dict, |
| 70 const FilePath& root_path, |
| 71 Capabilities* capabilities); |
| 72 ~CapabilitiesParser(); |
| 73 |
| 74 // Parses the capabilities. May return an error. |
| 75 Error* Parse(); |
| 76 |
| 77 private: |
| 78 Error* ParseArgs(const base::Value* option); |
| 79 Error* ParseBinary(const base::Value* option); |
| 80 Error* ParseChannel(const base::Value* option); |
| 81 Error* ParseDetach(const base::Value* option); |
| 82 Error* ParseExtensions(const base::Value* option); |
| 83 Error* ParseLoadAsync(const base::Value* option); |
| 84 Error* ParseNativeEvents(const base::Value* option); |
| 85 Error* ParseProfile(const base::Value* option); |
| 86 Error* ParseVerbose(const base::Value* option); |
| 87 // Decodes the given base64-encoded string, optionally unzips it, and |
| 88 // writes the result to |path|. |
| 89 // On error, false will be returned and |error_msg| will be set. |
| 90 bool DecodeAndWriteFile(const FilePath& path, |
| 91 const std::string& base64, |
| 92 bool unzip, |
| 93 std::string* error_msg); |
| 94 |
| 95 // The capabilities dictionary to parse. |
| 96 const base::DictionaryValue* dict_; |
| 97 |
| 98 // The root directory under which to write all files. |
| 99 const FilePath root_; |
| 100 |
| 101 // A pointer to the capabilities to modify while parsing. |
| 102 Capabilities* caps_; |
| 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(CapabilitiesParser); |
| 105 }; |
| 106 |
| 107 } // namespace webdriver |
| 108 |
| 109 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_CAPABILITIES_PARSER_H_ |
OLD | NEW |