| 43 | namespace webdriver { |
| 44 | |
| 45 | Element::Element(IHTMLElement* element, HWND containing_window_handle) { |
| 46 | LOG(TRACE) << "Entering Element::Element"; |
| 47 | |
| 48 | // NOTE: COM should be initialized on this thread, so we |
| 49 | // could use CoCreateGuid() and StringFromGUID2() instead. |
| 50 | UUID guid; |
| 51 | RPC_WSTR guid_string = NULL; |
| 52 | RPC_STATUS status = ::UuidCreate(&guid); |
| 53 | if (status != RPC_S_OK) { |
| 54 | // If we encounter an error, not bloody much we can do about it. |
| 55 | // Just log it and continue. |
| 56 | LOG(WARN) << "UuidCreate returned a status other then RPC_S_OK: " << status; |
| 57 | } |
| 58 | status = ::UuidToString(&guid, &guid_string); |
| 59 | if (status != RPC_S_OK) { |
| 60 | // If we encounter an error, not bloody much we can do about it. |
| 61 | // Just log it and continue. |
| 62 | LOG(WARN) << "UuidToString returned a status other then RPC_S_OK: " << status; |
| 63 | } |
| 64 | |
| 65 | // RPC_WSTR is currently typedef'd in RpcDce.h (pulled in by rpc.h) |
| 66 | // as unsigned short*. It needs to be typedef'd as wchar_t* |
| 67 | wchar_t* cast_guid_string = reinterpret_cast<wchar_t*>(guid_string); |
| 68 | this->element_id_ = StringUtilities::ToString(cast_guid_string); |
| 69 | |
| 70 | ::RpcStringFree(&guid_string); |
| 71 | |
| 72 | this->element_ = element; |
| 73 | this->containing_window_handle_ = containing_window_handle; |
| 74 | } |
| 75 | |
| 76 | Element::Element(IHTMLElement* element, HWND containing_window_handle, const std::string& element_id) { |
| 77 | this->element_ = element; |