Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/cpp/iedriver/DocumentHost.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_DOCUMENTHOST_H_
18
#define WEBDRIVER_IE_DOCUMENTHOST_H_
19
20
#include <map>
21
#include <memory>
22
#include <string>
23
24
#include "LocationInfo.h"
25
26
namespace webdriver {
27
28
// Forward declaration of classes.
29
class BrowserCookie;
30
class CookieManager;
31
32
class DocumentHost {
33
public:
34
DocumentHost(HWND hwnd, HWND executor_handle);
35
virtual ~DocumentHost(void);
36
37
virtual void GetDocument(const bool force_top_level_document,
38
IHTMLDocument2** doc) = 0;
39
virtual void GetDocument(IHTMLDocument2** doc) = 0;
40
virtual void Close(void) = 0;
41
virtual bool Wait(const std::string& page_load_strategy) = 0;
42
virtual bool IsBusy(void) = 0;
43
virtual HWND GetContentWindowHandle(void) = 0;
44
virtual HWND GetBrowserWindowHandle(void) = 0;
45
virtual std::string GetWindowName(void) = 0;
46
virtual std::string GetTitle(void) = 0;
47
virtual std::string GetBrowserUrl(void) = 0;
48
virtual HWND GetActiveDialogWindowHandle(void) = 0;
49
virtual HWND GetTopLevelWindowHandle(void) = 0;
50
51
virtual long GetWidth(void) = 0;
52
virtual long GetHeight(void) = 0;
53
virtual void SetWidth(long width) = 0;
54
virtual void SetHeight(long height) = 0;
55
56
virtual int NavigateToUrl(const std::string& url,
57
std::string* error_message) = 0;
58
virtual int NavigateBack(void) = 0;
59
virtual int NavigateForward(void) = 0;
60
virtual int Refresh(void) = 0;
61
62
virtual bool IsValidWindow(void) = 0;
63
64
virtual bool IsFullScreen(void) = 0;
65
virtual bool SetFullScreen(bool is_full_screen) = 0;
66
void Restore(void);
67
68
virtual bool IsProtectedMode(void);
69
virtual bool IsCrossZoneUrl(std::string url);
70
virtual void InitiateBrowserReattach(void) = 0;
71
virtual void ReattachBrowser(IWebBrowser2* browser) = 0;
72
73
virtual IWebBrowser2* browser(void) = 0;
74
75
std::string GetCurrentUrl(void);
76
std::string GetPageSource(void);
77
78
static int GetDocumentMode(IHTMLDocument2* doc);
79
static bool IsStandardsMode(IHTMLDocument2* doc);
80
static bool GetDocumentDimensions(IHTMLDocument2* doc, LocationInfo* info);
81
82
int SetFocusedFrameByIndex(const int frame_index);
83
int SetFocusedFrameByName(const std::string& frame_name);
84
int SetFocusedFrameByElement(IHTMLElement* frame_element);
85
void SetFocusedFrameToParent(void);
86
bool SetFocusToBrowser(void);
87
88
bool is_edge_chromium(void) const { return this->is_edge_chromium_; }
89
void set_is_edge_chromium(const bool value) { this->is_edge_chromium_ = value; }
90
91
bool wait_required(void) const { return this->wait_required_; }
92
void set_wait_required(const bool value) { this->wait_required_ = value; }
93
94
bool script_wait_required(void) const { return this->script_wait_required_; }
95
void set_script_wait_required(const bool value) { this->script_wait_required_ = value; }
96
97
HWND script_executor_handle(void) const { return this->script_executor_handle_; }
98
void set_script_executor_handle(HWND value) { this->script_executor_handle_ = value; }
99
100
bool is_closing(void) const { return this->is_closing_; }
101
bool is_awaiting_new_process(void) const { return this->is_awaiting_new_process_; }
102
103
std::string browser_id(void) const { return this->browser_id_; }
104
HWND window_handle(void) const { return this->window_handle_; }
105
CookieManager* cookie_manager(void) { return this->cookie_manager_; }
106
107
protected:
108
void PostQuitMessage(void);
109
HWND FindContentWindowHandle(HWND top_level_window_handle);
110
111
void set_window_handle(const HWND window_handle) {
112
this->window_handle_ = window_handle;
113
}
114
115
HWND executor_handle(void) const { return this->executor_handle_; }
116
117
void set_is_closing(const bool value) { this->is_closing_ = value; }
118
void set_is_awaiting_new_process(const bool value) {
119
this->is_awaiting_new_process_ = value;
120
}
121
122
IHTMLWindow2* focused_frame_window(void) {
123
return this->focused_frame_window_;
124
}
125
126
private:
127
int SetFocusedFrameByIdentifier(VARIANT frame_identifier);
128
129
CookieManager* cookie_manager_;
130
CComPtr<IHTMLWindow2> focused_frame_window_;
131
HWND window_handle_;
132
HWND executor_handle_;
133
HWND script_executor_handle_;
134
std::string browser_id_;
135
bool wait_required_;
136
bool script_wait_required_;
137
bool is_closing_;
138
bool is_awaiting_new_process_;
139
bool is_edge_chromium_;
140
};
141
142
} // namespace webdriver
143
144
#endif // WEBDRIVER_IE_DOCUMENTHOST_H_
145
146