1/* 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27#include "WebInspectorFrontendClient.h" 28 29#if ENABLE(INSPECTOR) 30 31#include "WebInspector.h" 32#include "WebPage.h" 33#include <WebCore/InspectorController.h> 34#include <WebCore/Page.h> 35#include <inspector/InspectorAgentBase.h> 36#include <wtf/text/WTFString.h> 37 38using namespace WebCore; 39 40namespace WebKit { 41 42WebInspectorFrontendClient::WebInspectorFrontendClient(WebPage* page, WebPage* inspectorPage) 43 : InspectorFrontendClientLocal(&page->corePage()->inspectorController(), inspectorPage->corePage(), std::make_unique<Settings>()) 44 , m_page(page) 45{ 46} 47 48String WebInspectorFrontendClient::localizedStringsURL() 49{ 50 return m_page->inspector()->localizedStringsURL(); 51} 52 53void WebInspectorFrontendClient::bringToFront() 54{ 55 m_page->inspector()->bringToFront(); 56} 57 58void WebInspectorFrontendClient::closeWindow() 59{ 60 m_page->corePage()->inspectorController().disconnectFrontend(Inspector::InspectorDisconnectReason::InspectorDestroyed); 61 m_page->inspector()->didClose(); 62} 63 64bool WebInspectorFrontendClient::canSave() 65{ 66 return m_page->inspector()->canSave(); 67} 68 69void WebInspectorFrontendClient::save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs) 70{ 71 m_page->inspector()->save(filename, content, base64Encoded, forceSaveAs); 72} 73 74void WebInspectorFrontendClient::append(const String& filename, const String& content) 75{ 76 m_page->inspector()->append(filename, content); 77} 78 79void WebInspectorFrontendClient::attachWindow(DockSide dockSide) 80{ 81 switch (dockSide) { 82 case InspectorFrontendClient::UNDOCKED: 83 ASSERT_NOT_REACHED(); 84 break; 85 case InspectorFrontendClient::DOCKED_TO_BOTTOM: 86 m_page->inspector()->attachBottom(); 87 break; 88 case InspectorFrontendClient::DOCKED_TO_RIGHT: 89 m_page->inspector()->attachRight(); 90 break; 91 } 92} 93 94void WebInspectorFrontendClient::detachWindow() 95{ 96 m_page->inspector()->detach(); 97} 98 99void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned height) 100{ 101 m_page->inspector()->setAttachedWindowHeight(height); 102} 103 104void WebInspectorFrontendClient::setAttachedWindowWidth(unsigned width) 105{ 106 m_page->inspector()->setAttachedWindowWidth(width); 107} 108 109void WebInspectorFrontendClient::setToolbarHeight(unsigned height) 110{ 111 m_page->inspector()->setToolbarHeight(height); 112} 113 114void WebInspectorFrontendClient::inspectedURLChanged(const String& urlString) 115{ 116 m_page->inspector()->inspectedURLChanged(urlString); 117} 118 119} // namespace WebKit 120 121#endif // ENABLE(INSPECTOR) 122