Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/cpp/iedriver/HtmlDialog.h
2867 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#ifndef WEBDRIVER_IE_HTMLDIALOG_H_
18
#define WEBDRIVER_IE_HTMLDIALOG_H_
19
20
#include <mshtml.h>
21
#include <mshtmdid.h>
22
23
#include "DocumentHost.h"
24
#include "messages.h"
25
26
namespace webdriver {
27
28
struct DialogWindowInfo {
29
HWND hwndOwner;
30
HWND hwndDialog;
31
};
32
33
class HtmlDialog : public DocumentHost, public IDispEventSimpleImpl<1, HtmlDialog, &DIID_HTMLWindowEvents2> {
34
public:
35
HtmlDialog(IHTMLWindow2* window, HWND hwnd, HWND session_handle);
36
virtual ~HtmlDialog(void);
37
38
static inline _ATL_FUNC_INFO* DocEventInfo() {
39
static _ATL_FUNC_INFO kDocEvent = { CC_STDCALL, VT_EMPTY, 1, { VT_DISPATCH } };
40
return &kDocEvent;
41
}
42
43
BEGIN_SINK_MAP(HtmlDialog)
44
SINK_ENTRY_INFO(1, DIID_HTMLWindowEvents2, DISPID_HTMLWINDOWEVENTS2_ONBEFOREUNLOAD, OnBeforeUnload, DocEventInfo())
45
SINK_ENTRY_INFO(1, DIID_HTMLWindowEvents2, DISPID_HTMLWINDOWEVENTS2_ONLOAD, OnLoad, DocEventInfo())
46
END_SINK_MAP()
47
48
STDMETHOD_(void, OnBeforeUnload)(IHTMLEventObj* pEvtObj);
49
STDMETHOD_(void, OnLoad)(IHTMLEventObj* pEvtObj);
50
51
void GetDocument(const bool force_top_level_document,
52
IHTMLDocument2** doc);
53
void GetDocument(IHTMLDocument2** doc);
54
void Close(void);
55
bool Wait(const std::string& page_load_strategy);
56
bool IsBusy(void);
57
HWND GetContentWindowHandle(void);
58
HWND GetBrowserWindowHandle(void);
59
std::string GetWindowName(void);
60
std::string GetTitle(void);
61
std::string GetBrowserUrl(void);
62
HWND GetActiveDialogWindowHandle(void);
63
HWND GetTopLevelWindowHandle(void);
64
65
long GetWidth(void);
66
long GetHeight(void);
67
void SetWidth(long width);
68
void SetHeight(long height);
69
70
int NavigateToUrl(const std::string& url, std::string* error_message);
71
int NavigateBack(void);
72
int NavigateForward(void);
73
int Refresh(void);
74
75
bool IsValidWindow(void);
76
77
bool IsFullScreen(void);
78
bool SetFullScreen(bool is_full_screen);
79
80
void InitiateBrowserReattach(void) {};
81
void ReattachBrowser(IWebBrowser2* browser) {};
82
83
IWebBrowser2* browser(void) { return NULL; }
84
85
private:
86
static BOOL CALLBACK FindChildDialogWindow(HWND hwnd, LPARAM arg);
87
88
void AttachEvents(void);
89
void DetachEvents(void);
90
91
bool is_navigating_;
92
CComPtr<IHTMLWindow2> window_;
93
};
94
95
} // namespace webdriver
96
97
#endif // WEBDRIVER_IE_HTMLDIALOG_H_
98
99