Path: blob/trunk/cpp/iedriver/CommandHandlers/FullScreenWindowCommandHandler.cpp
2868 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the "License");5// you may not use this file except in compliance with the License.6// You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing, software11// distributed under the License is distributed on an "AS IS" BASIS,12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13// See the License for the specific language governing permissions and14// limitations under the License.1516#include "FullScreenWindowCommandHandler.h"17#include "errorcodes.h"18#include "logging.h"19#include "../Browser.h"20#include "../IECommandExecutor.h"21#include "../Script.h"2223namespace webdriver {2425FullScreenWindowCommandHandler::FullScreenWindowCommandHandler(void) {26}2728FullScreenWindowCommandHandler::~FullScreenWindowCommandHandler(void) {29}3031void FullScreenWindowCommandHandler::ExecuteInternal(32const IECommandExecutor& executor,33const ParametersMap& command_parameters,34Response* response) {35int status_code = WD_SUCCESS;3637BrowserHandle browser_wrapper;38status_code = executor.GetCurrentBrowser(&browser_wrapper);39if (status_code != WD_SUCCESS) {40response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Error retrieving window");41return;42}4344bool supports_full_screen = browser_wrapper->SetFullScreen(true);45if (!supports_full_screen) {46response->SetErrorResponse(ERROR_UNSUPPORTED_OPERATION,47"This version of Internet Explorer does not support setting to full screen");48}4950HWND window_handle = browser_wrapper->GetTopLevelWindowHandle();51RECT window_rect;52::GetWindowRect(window_handle, &window_rect);53Json::Value response_value;54response_value["width"] = window_rect.right - window_rect.left;55response_value["height"] = window_rect.bottom - window_rect.top;56response_value["x"] = window_rect.left;57response_value["y"] = window_rect.top;58response->SetSuccessResponse(response_value);59}6061} // namespace webdriver626364