1 // Copyright (c) 2012 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_AUTOMATION_CONSTANTS_H__ 6 #define CHROME_COMMON_AUTOMATION_CONSTANTS_H__ 7 8 #include <string> 9 10 namespace automation { 11 12 // JSON value labels for proxy settings that are passed in via 13 // AutomationMsg_SetProxyConfig. These are here since they are used by both 14 // AutomationProvider and AutomationProxy. 15 extern const char kJSONProxyAutoconfig[]; 16 extern const char kJSONProxyNoProxy[]; 17 extern const char kJSONProxyPacUrl[]; 18 extern const char kJSONProxyPacMandatory[]; 19 extern const char kJSONProxyBypassList[]; 20 extern const char kJSONProxyServer[]; 21 22 // When passing the kTestingChannelID switch to the browser, prepend 23 // this prefix to the channel id to enable the named testing interface. 24 // Named testing interface is used when you want to connect an 25 // AutomationProxy to an already-running browser instance. 26 extern const char kNamedInterfacePrefix[]; 27 28 // Amount of time to wait before querying the browser. 29 static const int kSleepTime = 250; 30 31 // Recognized by the AutomationProvider's SendWebKeyboardEventToSelectedTab 32 // command. Specifies the type of the keyboard event. 33 enum KeyEventTypes { 34 kRawKeyDownType = 0, 35 kKeyDownType, 36 kCharType, 37 kKeyUpType, 38 }; 39 40 // Recognized by the AutomationProvider's SendWebKeyboardEventToSelectedTab 41 // command. Specifies masks to be used in constructing keyboard event modifiers. 42 enum KeyModifierMasks { 43 kShiftKeyMask = 1 << 0, 44 kControlKeyMask = 1 << 1, 45 kAltKeyMask = 1 << 2, 46 kMetaKeyMask = 1 << 3, 47 kNumLockKeyMask = 1 << 4, 48 }; 49 50 // Recognized by the AutomationProvider's ProcessWebMouseEvent command. 51 enum MouseEventType { 52 kMouseDown = 0, 53 kMouseUp, 54 kMouseMove, 55 kMouseEnter, 56 kMouseLeave, 57 kContextMenu, 58 }; 59 60 enum MouseButton { 61 kLeftButton = 0, 62 kMiddleButton, 63 kRightButton, 64 kNoButton, 65 }; 66 67 // The current version of ChromeDriver automation supported by Chrome. 68 // This needs to be incremented for each change to ChromeDriver automation that 69 // is not backwards compatible. Some examples of this would be: 70 // - SendJSONRequest or Hello IPC messages change 71 // - The interface for an individual ChromeDriver automation call changes in an 72 // incompatible way 73 // TODO(kkania): Investigate a better backwards compatible automation solution. 74 extern const int kChromeDriverAutomationVersion; 75 76 // Automation error codes. These provide the client a simple way 77 // to detect certain types of errors it may be interested in handling. 78 // The error code values must stay consistent across compatible versions. 79 enum ErrorCode { 80 // An unknown error occurred. 81 kUnknownError = 0, 82 // Trying to operate on a JavaScript modal dialog when none is open. 83 kNoJavaScriptModalDialogOpen = 1, 84 // An open modal dialog blocked the operation. The operation may have 85 // partially completed. 86 kBlockedByModalDialog = 2, 87 // An ID was supplied that is invalid or does not refer to an existing object. 88 kInvalidId = 3, 89 }; 90 91 // Represents an automation error. Each error has a code and an error message. 92 class Error { 93 public: 94 // Creates an invalid error. 95 Error(); 96 97 // Creates an error for the given code. A default message for the given code 98 // will be used as the error message. 99 explicit Error(ErrorCode code); 100 101 // Creates an error for the given message. The |kUnknownError| type will 102 // be used. 103 explicit Error(const std::string& error_msg); 104 105 // Creates an error for the given code and message. 106 Error(ErrorCode code, const std::string& error_msg); 107 108 virtual ~Error(); 109 110 ErrorCode code() const; 111 const std::string& message() const; 112 113 private: 114 ErrorCode code_; 115 std::string message_; 116 }; 117 118 } // namespace automation 119 120 // Used by AutomationProxy, declared here so that other headers don't need 121 // to include automation_proxy.h. 122 enum AutomationLaunchResult { 123 AUTOMATION_LAUNCH_RESULT_INVALID = -1, 124 AUTOMATION_SUCCESS, 125 AUTOMATION_TIMEOUT, 126 AUTOMATION_VERSION_MISMATCH, 127 AUTOMATION_CREATE_TAB_FAILED, 128 AUTOMATION_SERVER_CRASHED, 129 AUTOMATION_CHANNEL_ERROR, 130 }; 131 132 enum AutomationMsg_NavigationResponseValues { 133 AUTOMATION_MSG_NAVIGATION_ERROR = 0, 134 AUTOMATION_MSG_NAVIGATION_SUCCESS, 135 AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, 136 AUTOMATION_MSG_NAVIGATION_BLOCKED_BY_MODAL_DIALOG, 137 }; 138 139 // Used in the AutomationMsg_GetExtensionProperty to identify which extension 140 // property should be retrieved, instead of having separate messages for each 141 // property. 142 enum AutomationMsg_DEPRECATED_ExtensionProperty { 143 AUTOMATION_MSG_EXTENSION_ID = 0, 144 AUTOMATION_MSG_EXTENSION_NAME, 145 AUTOMATION_MSG_EXTENSION_VERSION, 146 AUTOMATION_MSG_EXTENSION_BROWSER_ACTION_INDEX, 147 }; 148 149 // Specifies the font size on a page which is requested by an automation 150 // client. 151 enum AutomationPageFontSize { 152 SMALLEST_FONT = 8, 153 SMALL_FONT = 12, 154 MEDIUM_FONT = 16, 155 LARGE_FONT = 24, 156 LARGEST_FONT = 36 157 }; 158 159 enum FindInPageDirection { BACK = 0, FWD = 1 }; 160 enum FindInPageCase { IGNORE_CASE = 0, CASE_SENSITIVE = 1 }; 161 162 #endif // CHROME_COMMON_AUTOMATION_CONSTANTS_H__ 163