Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/cpp/iedriver/CommandHandlers/FullScreenWindowCommandHandler.cpp
2868 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
#include "FullScreenWindowCommandHandler.h"
18
#include "errorcodes.h"
19
#include "logging.h"
20
#include "../Browser.h"
21
#include "../IECommandExecutor.h"
22
#include "../Script.h"
23
24
namespace webdriver {
25
26
FullScreenWindowCommandHandler::FullScreenWindowCommandHandler(void) {
27
}
28
29
FullScreenWindowCommandHandler::~FullScreenWindowCommandHandler(void) {
30
}
31
32
void FullScreenWindowCommandHandler::ExecuteInternal(
33
const IECommandExecutor& executor,
34
const ParametersMap& command_parameters,
35
Response* response) {
36
int status_code = WD_SUCCESS;
37
38
BrowserHandle browser_wrapper;
39
status_code = executor.GetCurrentBrowser(&browser_wrapper);
40
if (status_code != WD_SUCCESS) {
41
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Error retrieving window");
42
return;
43
}
44
45
bool supports_full_screen = browser_wrapper->SetFullScreen(true);
46
if (!supports_full_screen) {
47
response->SetErrorResponse(ERROR_UNSUPPORTED_OPERATION,
48
"This version of Internet Explorer does not support setting to full screen");
49
}
50
51
HWND window_handle = browser_wrapper->GetTopLevelWindowHandle();
52
RECT window_rect;
53
::GetWindowRect(window_handle, &window_rect);
54
Json::Value response_value;
55
response_value["width"] = window_rect.right - window_rect.left;
56
response_value["height"] = window_rect.bottom - window_rect.top;
57
response_value["x"] = window_rect.left;
58
response_value["y"] = window_rect.top;
59
response->SetSuccessResponse(response_value);
60
}
61
62
} // namespace webdriver
63
64