Bug 40630 - WebKit2: Add mechanism to inject code into the WebProcess on startup
Summary: WebKit2: Add mechanism to inject code into the WebProcess on startup
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-15 10:03 PDT by Sam Weinig
Modified: 2010-06-15 19:44 PDT (History)
0 users

See Also:


Attachments
patch (89.70 KB, patch)
2010-06-15 10:14 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2010-06-15 10:03:03 PDT
We need a mechanism to allow injecting code into the WebProcess on startup, sort of like a plugin, but for the embedding app instead of the web content.
Comment 1 Sam Weinig 2010-06-15 10:14:21 PDT
Created attachment 58793 [details]
patch
Comment 2 Darin Adler 2010-06-15 12:15:43 PDT
Comment on attachment 58793 [details]
patch

Double change log in this patch.
Comment 3 Anders Carlsson 2010-06-15 13:55:44 PDT
Comment on attachment 58793 [details]
patch

> Index: WebKit2/ChangeLog
> ===================================================================
> --- WebKit2/ChangeLog	(revision 61196)
> +++ WebKit2/ChangeLog	(working copy)
> @@ -1,3 +1,172 @@
> +2010-06-15  Sam Weinig  <sam@webkit.org>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        Fix for https://bugs.webkit.org/show_bug.cgi?id=40630
> +        WebKit2: Add mechanism to inject code into the WebProcess on startup
> +
> +        Add initial WebBundle support.

Let's call it "Injected Bundle" instead.


> Index: WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
> ===================================================================
> --- WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h	(revision 61159)
> +++ WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h	(working copy)
> @@ -33,6 +33,7 @@
>  namespace WebProcessMessage {
>  
>  enum Kind {
> +    LoadWebBundle,
>      Create
>  };
> 

Injected bundle.
 
> Index: WebKit2/UIProcess/WebContext.cpp
> ===================================================================
> --- WebKit2/UIProcess/WebContext.cpp	(revision 61159)
> +++ WebKit2/UIProcess/WebContext.cpp	(working copy)
> @@ -36,6 +36,8 @@
>  #include <wtf/RefCountedLeakCounter.h>
>  #endif
>  
> +using namespace WebCore;
> +
>  namespace WebKit {
>  
>  #ifndef NDEBUG
> @@ -55,6 +57,20 @@ WebContext::WebContext(ProcessModel proc
>  #endif
>  }
>  
> +WebContext::WebContext(ProcessModel processModel, const WebCore::String& bundlePath)
> +    : m_processModel(processModel)
> +    , m_bundlePath(bundlePath)
> +{
> +    RunLoop::initializeMainRunLoop();
> +
> +    m_preferences = WebPreferences::shared();
> +    m_preferences->addContext(this);
> +
> +#ifndef NDEBUG
> +    webContextCounter.increment();
> +#endif
> +}
> +

No need for an extra constructor, just add a bundlePath parameter to the already existing constructor.

>  WebContext::~WebContext()
>  {
>      ASSERT(m_pageNamespaces.isEmpty());
> Index: WebKit2/UIProcess/WebContext.h
> ===================================================================
> --- WebKit2/UIProcess/WebContext.h	(revision 61159)
> +++ WebKit2/UIProcess/WebContext.h	(working copy)
> @@ -27,6 +27,7 @@
>  #define WebContext_h
>  
>  #include "ProcessModel.h"
> +#include <WebCore/PlatformString.h>
>  #include <wtf/HashSet.h>
>  #include <wtf/PassRefPtr.h>
>  #include <wtf/RefCounted.h>
> @@ -46,26 +47,35 @@ public:
>          return adoptRef(new WebContext(processModel));
>      }
>  
> +    static PassRefPtr<WebContext> create(ProcessModel processModel, const WebCore::String& bundlePath)
> +    {
> +        return adoptRef(new WebContext(processModel, bundlePath));
> +    }
> +

No need for an extra ::create function here.
>  
> +void WebProcess::loadWebBundle(const WebCore::String& path)
> +{

InjectedBundle! (I'm gonna stop complaining about that now).

> +void WebBundle::initializeClient(WKBundleClient* client)
> +{
> +    if (client && !client->version)
> +        m_client = *client;

Maybe we should log an error if the client version didn't match?


r=me!
Comment 4 Sam Weinig 2010-06-15 16:17:41 PDT
Landed in r61222.
Comment 5 David Levin 2010-06-15 19:44:53 PDT
Comment on attachment 58793 [details]
patch

Cleared r? since the patch was "r=me" (in comments) and landed.