Changeset 113028 in webkit


Ignore:
Timestamp:
Apr 3, 2012 6:24:56 AM (12 years ago)
Author:
jocelyn.turcotte@nokia.com
Message:

Enable and connect the WebInspectorServer with WebKit2 pages.
https://bugs.webkit.org/show_bug.cgi?id=73094

Reviewed by Simon Hausmann.

Source/WebKit2:

Pages are registered/unregistered as they are created/destroyed, if they have
developer extras enabled. The server is run on the UI process and communicates
with the web process through IPC for each message between the inspector
controller and the remote frontend.

Includes the server spawning logic for the Qt port, the server is
started through an environment variable specifying the interface and
port to bind the server to, by default on 127.0.0.1.

  • UIProcess/WebInspectorProxy.cpp:

(WebKit::WebInspectorProxy::WebInspectorProxy):
(WebKit::WebInspectorProxy::invalidate):
(WebKit):
(WebKit::WebInspectorProxy::enableRemoteInspection):
(WebKit::WebInspectorProxy::remoteFrontendConnected):
(WebKit::WebInspectorProxy::remoteFrontendDisconnected):
(WebKit::WebInspectorProxy::dispatchMessageFromRemoteFrontend):
(WebKit::WebInspectorProxy::sendMessageToRemoteFrontend):

  • UIProcess/WebInspectorProxy.h:

(WebInspectorProxy):

  • UIProcess/WebInspectorProxy.messages.in:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::initializeWebPage):
(WebKit::WebPageProxy::preferencesDidChange):

  • UIProcess/qt/QtWebContext.cpp:

(WebKit::initInspectorServer):
(WebKit):
(WebKit::globalInitialization):
(WebKit::QtWebContext::create):

  • WebProcess/WebCoreSupport/WebInspectorClient.cpp:

(WebKit::WebInspectorClient::sendMessageToFrontend):

  • WebProcess/WebPage/WebInspector.cpp:

(WebKit::WebInspector::WebInspector):
(WebKit):
(WebKit::WebInspector::sendMessageToRemoteFrontend):
(WebKit::WebInspector::dispatchMessageFromRemoteFrontend):
(WebKit::WebInspector::remoteFrontendConnected):
(WebKit::WebInspector::remoteFrontendDisconnected):

  • WebProcess/WebPage/WebInspector.h:

(WebInspector):
(WebKit::WebInspector::hasRemoteFrontendConnected):

  • WebProcess/WebPage/WebInspector.messages.in:

Tools:

Enable developer extras on pages in MiniBrowser for Qt.

  • MiniBrowser/qt/qml/BrowserWindow.qml:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r113027 r113028  
     12012-04-02  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
     2
     3        Enable and connect the WebInspectorServer with WebKit2 pages.
     4        https://bugs.webkit.org/show_bug.cgi?id=73094
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Pages are registered/unregistered as they are created/destroyed, if they have
     9        developer extras enabled. The server is run on the UI process and communicates
     10        with the web process through IPC for each message between the inspector
     11        controller and the remote frontend.
     12
     13        Includes the server spawning logic for the Qt port, the server is
     14        started through an environment variable specifying the interface and
     15        port to bind the server to, by default on 127.0.0.1.
     16
     17        * UIProcess/WebInspectorProxy.cpp:
     18        (WebKit::WebInspectorProxy::WebInspectorProxy):
     19        (WebKit::WebInspectorProxy::invalidate):
     20        (WebKit):
     21        (WebKit::WebInspectorProxy::enableRemoteInspection):
     22        (WebKit::WebInspectorProxy::remoteFrontendConnected):
     23        (WebKit::WebInspectorProxy::remoteFrontendDisconnected):
     24        (WebKit::WebInspectorProxy::dispatchMessageFromRemoteFrontend):
     25        (WebKit::WebInspectorProxy::sendMessageToRemoteFrontend):
     26        * UIProcess/WebInspectorProxy.h:
     27        (WebInspectorProxy):
     28        * UIProcess/WebInspectorProxy.messages.in:
     29        * UIProcess/WebPageProxy.cpp:
     30        (WebKit::WebPageProxy::initializeWebPage):
     31        (WebKit::WebPageProxy::preferencesDidChange):
     32        * UIProcess/qt/QtWebContext.cpp:
     33        (WebKit::initInspectorServer):
     34        (WebKit):
     35        (WebKit::globalInitialization):
     36        (WebKit::QtWebContext::create):
     37        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
     38        (WebKit::WebInspectorClient::sendMessageToFrontend):
     39        * WebProcess/WebPage/WebInspector.cpp:
     40        (WebKit::WebInspector::WebInspector):
     41        (WebKit):
     42        (WebKit::WebInspector::sendMessageToRemoteFrontend):
     43        (WebKit::WebInspector::dispatchMessageFromRemoteFrontend):
     44        (WebKit::WebInspector::remoteFrontendConnected):
     45        (WebKit::WebInspector::remoteFrontendDisconnected):
     46        * WebProcess/WebPage/WebInspector.h:
     47        (WebInspector):
     48        (WebKit::WebInspector::hasRemoteFrontendConnected):
     49        * WebProcess/WebPage/WebInspector.messages.in:
     50
    1512012-03-29  Joseph Pecoraro  <joepeck@webkit.org> and Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    252
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp

    r112808 r113028  
    4040#include "WebURLRequest.h"
    4141
     42#if ENABLE(INSPECTOR_SERVER)
     43#include "WebInspectorServer.h"
     44#endif
    4245#if PLATFORM(WIN)
    4346#include "WebView.h"
     
    8285    , m_inspectorWindow(0)
    8386#endif
     87#if ENABLE(INSPECTOR_SERVER)
     88    , m_remoteInspectionPageId(0)
     89#endif
    8490{
    8591}
     
    9197void WebInspectorProxy::invalidate()
    9298{
     99#if ENABLE(INSPECTOR_SERVER)
     100    if (m_remoteInspectionPageId)
     101        WebInspectorServer::shared().unregisterPage(m_remoteInspectionPageId);
     102#endif
     103
    93104    m_page->close();
    94105    didClose();
     
    256267    webInspectorProxy->page()->loadURLRequest(toImpl(requestRef));
    257268}
     269
     270#if ENABLE(INSPECTOR_SERVER)
     271void WebInspectorProxy::enableRemoteInspection()
     272{
     273    if (!m_remoteInspectionPageId)
     274        m_remoteInspectionPageId = WebInspectorServer::shared().registerPage(this);
     275}
     276
     277void WebInspectorProxy::remoteFrontendConnected()
     278{
     279    m_page->process()->send(Messages::WebInspector::RemoteFrontendConnected(), m_page->pageID());
     280}
     281
     282void WebInspectorProxy::remoteFrontendDisconnected()
     283{
     284    m_page->process()->send(Messages::WebInspector::RemoteFrontendDisconnected(), m_page->pageID());
     285}
     286
     287void WebInspectorProxy::dispatchMessageFromRemoteFrontend(const String& message)
     288{
     289    m_page->process()->send(Messages::WebInspector::DispatchMessageFromRemoteFrontend(message), m_page->pageID());
     290}
     291#endif
    258292
    259293// Called by WebInspectorProxy messages
     
    349383}
    350384
     385#if ENABLE(INSPECTOR_SERVER)
     386void WebInspectorProxy::sendMessageToRemoteFrontend(const String& message)
     387{
     388    ASSERT(m_remoteInspectionPageId);
     389    WebInspectorServer::shared().sendMessageOverConnection(m_remoteInspectionPageId, message);
     390}
     391#endif
     392
    351393} // namespace WebKit
    352394
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h

    r112808 r113028  
    124124    String inspectorBaseURL() const;
    125125
     126#if ENABLE(INSPECTOR_SERVER)
     127    void enableRemoteInspection();
     128    void remoteFrontendConnected();
     129    void remoteFrontendDisconnected();
     130    void dispatchMessageFromRemoteFrontend(const String& message);
     131#endif
     132
    126133private:
    127134    WebInspectorProxy(WebPageProxy* page);
     
    146153    void bringToFront();
    147154    void inspectedURLChanged(const String&);
     155
     156#if ENABLE(INSPECTOR_SERVER)
     157    void sendMessageToRemoteFrontend(const String& message);
     158#endif
    148159
    149160    bool canAttach();
     
    195206    GtkWidget* m_inspectorWindow;
    196207#endif
     208#if ENABLE(INSPECTOR_SERVER)
     209    int m_remoteInspectionPageId;
     210#endif
    197211};
    198212
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in

    r92587 r113028  
    3333    Detach()
    3434    SetAttachedWindowHeight(unsigned height)
     35
     36#if ENABLE(INSPECTOR_SERVER)
     37    SendMessageToRemoteFrontend(WTF::String message)
     38#endif
    3539}
    3640
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r112821 r113028  
    340340    ASSERT(m_drawingArea);
    341341
     342#if ENABLE(INSPECTOR_SERVER)
     343    if (m_pageGroup->preferences()->developerExtrasEnabled())
     344        inspector()->enableRemoteInspection();
     345#endif
     346
    342347    process()->send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
    343348}
     
    15711576    if (!isValid())
    15721577        return;
     1578
     1579#if ENABLE(INSPECTOR_SERVER)
     1580    if (m_pageGroup->preferences()->developerExtrasEnabled())
     1581        inspector()->enableRemoteInspection();
     1582#endif
    15731583
    15741584    // FIXME: It probably makes more sense to send individual preference changes.
  • trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp

    r109121 r113028  
    2727#include "WKAPICast.h"
    2828#include "WebContext.h"
     29#include "WebInspectorServer.h"
    2930#include "WebPageProxy.h"
    3031#include <WKArray.h>
     
    4445
    4546QtWebContext* QtWebContext::s_defaultContext = 0;
     47
     48static void initInspectorServer()
     49{
     50    QString inspectorEnv = QString::fromUtf8(qgetenv("QTWEBKIT_INSPECTOR_SERVER"));
     51    if (!inspectorEnv.isEmpty()) {
     52        QString bindAddress = QLatin1String("127.0.0.1");
     53        QString portStr = inspectorEnv;
     54        int port = 0;
     55
     56        int portColonPos = inspectorEnv.lastIndexOf(':');
     57        if (portColonPos != -1) {
     58            portStr = inspectorEnv.mid(portColonPos + 1);
     59            bindAddress = inspectorEnv.mid(0, portColonPos);
     60        }
     61
     62        bool ok = false;
     63        port = portStr.toInt(&ok);
     64        if (!ok) {
     65            qWarning("Non numeric port for the inspector server \"%s\". Examples of valid input: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's interface).", qPrintable(portStr));
     66            return;
     67        }
     68
     69        bool success = WebInspectorServer::shared().listen(bindAddress, port);
     70        if (success) {
     71            QString inspectorServerUrl = QString::fromLatin1("http://%1:%2").arg(bindAddress).arg(port);
     72            qWarning("Inspector server started successfully. Try pointing a WebKit browser to %s", qPrintable(inspectorServerUrl));
     73        } else
     74            qWarning("Couldn't start the inspector server on bind address \"%s\" and port \"%d\". In case of invalid input, try something like: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's interface).", qPrintable(bindAddress), port);
     75    }
     76}
     77
     78static void globalInitialization()
     79{
     80    static bool initialized = false;
     81    if (initialized)
     82        return;
     83
     84    initInspectorServer();
     85    initialized = true;
     86}
    4687
    4788QtWebContext::QtWebContext(WebContext* context)
     
    64105PassRefPtr<QtWebContext> QtWebContext::create(WebContext* context)
    65106{
     107    globalInitialization();
    66108    return adoptRef(new QtWebContext(context));
    67109}
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp

    r110390 r113028  
    9090    if (!inspector)
    9191        return false;
     92
     93#if ENABLE(INSPECTOR_SERVER)
     94    if (inspector->hasRemoteFrontendConnected()) {
     95        inspector->sendMessageToRemoteFrontend(message);
     96        return true;
     97    }
     98#endif
     99
    92100    WebPage* inspectorPage = inspector->inspectorPage();
    93     if (!inspectorPage)
    94         return false;
    95     return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message);
     101    if (inspectorPage)
     102        return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message);
     103
     104    return false;
    96105}
    97106
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp

    r110390 r113028  
    5151    , m_inspectorPage(0)
    5252    , m_frontendClient(0)
     53#if ENABLE(INSPECTOR_SERVER)
     54    , m_remoteFrontendConnected(false)
     55#endif
    5356{
    5457}
     
    237240}
    238241
     242#if ENABLE(INSPECTOR_SERVER)
     243void WebInspector::sendMessageToRemoteFrontend(const String& message)
     244{
     245    ASSERT(m_remoteFrontendConnected);
     246    WebProcess::shared().connection()->send(Messages::WebInspectorProxy::SendMessageToRemoteFrontend(message), m_page->pageID());
     247}
     248
     249void WebInspector::dispatchMessageFromRemoteFrontend(const String& message)
     250{
     251    m_page->corePage()->inspectorController()->dispatchMessageFromFrontend(message);
     252}
     253
     254void WebInspector::remoteFrontendConnected()
     255{
     256    ASSERT(!m_remoteFrontendConnected);
     257    // Switching between in-process and remote inspectors isn't supported yet.
     258    ASSERT(!m_inspectorPage);
     259
     260    m_page->corePage()->inspectorController()->connectFrontend();
     261    m_remoteFrontendConnected = true;
     262}
     263
     264void WebInspector::remoteFrontendDisconnected()
     265{
     266    ASSERT(m_remoteFrontendConnected);
     267    m_page->corePage()->inspectorController()->disconnectFrontend();
     268    m_remoteFrontendConnected = false;
     269}
     270#endif
     271
    239272} // namespace WebKit
    240273
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h

    r110425 r113028  
    6262    void stopPageProfiling();
    6363
     64#if ENABLE(INSPECTOR_SERVER)
     65    bool hasRemoteFrontendConnected() const { return m_remoteFrontendConnected; }
     66    void sendMessageToRemoteFrontend(const String& message);
     67    void dispatchMessageFromRemoteFrontend(const String& message);
     68    void remoteFrontendConnected();
     69    void remoteFrontendDisconnected();
     70#endif
     71
    6472#if PLATFORM(MAC)
    6573    void setInspectorUsesWebKitUserInterface(bool);
     
    112120    String m_localizedStringsURL;
    113121#endif
     122#if ENABLE(INSPECTOR_SERVER)
     123    bool m_remoteFrontendConnected;
     124#endif
    114125};
    115126
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in

    r107757 r113028  
    3535    StartPageProfiling()
    3636    StopPageProfiling()
     37
     38#if ENABLE(INSPECTOR_SERVER)
     39    DispatchMessageFromRemoteFrontend(WTF::String message)
     40    RemoteFrontendConnected()
     41    RemoteFrontendDisconnected()
     42#endif
    3743}
    3844
  • trunk/Tools/ChangeLog

    r113018 r113028  
     12012-04-02  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
     2
     3        Enable and connect the WebInspectorServer with WebKit2 pages.
     4        https://bugs.webkit.org/show_bug.cgi?id=73094
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Enable developer extras on pages in MiniBrowser for Qt.
     9
     10        * MiniBrowser/qt/qml/BrowserWindow.qml:
     11
    1122012-04-03  Christophe Dumez  <christophe.dumez@intel.com>
    213
  • trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml

    r111722 r113028  
    315315        experimental.proxyAuthenticationDialog: ProxyAuthenticationDialog { }
    316316        experimental.filePicker: FilePicker { }
     317        experimental.preferences.developerExtrasEnabled: true
    317318        experimental.databaseQuotaDialog: Item {
    318319            Timer {
Note: See TracChangeset for help on using the changeset viewer.