Bug 142786 - [GTK] webkit_web_extension_initialize[_with_user_data] not documented
Summary: [GTK] webkit_web_extension_initialize[_with_user_data] not documented
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-17 10:31 PDT by Philip Chimento
Modified: 2015-05-20 09:13 PDT (History)
7 users (show)

See Also:


Attachments
Patch (5.08 KB, patch)
2015-03-31 04:28 PDT, Marcos Chavarría Teijeiro (irc: chavaone)
no flags Details | Formatted Diff | Diff
Patch (5.09 KB, patch)
2015-03-31 08:53 PDT, Marcos Chavarría Teijeiro (irc: chavaone)
no flags Details | Formatted Diff | Diff
Patch (5.09 KB, patch)
2015-03-31 10:40 PDT, Marcos Chavarría Teijeiro (irc: chavaone)
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-mavericks-wk2 (659.06 KB, application/zip)
2015-03-31 11:05 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews103 for mac-mavericks (546.89 KB, application/zip)
2015-03-31 12:03 PDT, Build Bot
no flags Details
Patch (5.09 KB, patch)
2015-04-15 00:16 PDT, Marcos Chavarría Teijeiro (irc: chavaone)
no flags Details | Formatted Diff | Diff
Patch (4.61 KB, patch)
2015-05-20 03:43 PDT, Marcos Chavarría Teijeiro (irc: chavaone)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Chimento 2015-03-17 10:31:42 PDT
On this page [1] the function types WebKitWebExtensionInitializeFunction and WebKitWebExtensionInitializeWithUserDataFunction are documented, but nowhere does it state that those functions have specific names that webkit will look for when loading the web extension: webkit_web_extension_initialize and webkit_web_extension_initialize_with_user_data. These should be mentioned in the API documentation, perhaps even with a small howto for web extensions. Currently this information is only available by searching people's blogs or looking in the source code.

[1] http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebExtension.html
Comment 1 Marcos Chavarría Teijeiro (irc: chavaone) 2015-03-31 04:28:38 PDT
Created attachment 249819 [details]
Patch
Comment 2 Marcos Chavarría Teijeiro (irc: chavaone) 2015-03-31 04:34:46 PDT
I have create some documentation for the WebKitWebExtension class so new user can easily found out how to use it. Please review this to check if there is something wrong or missing.
Comment 3 Adrian Perez 2015-03-31 05:58:47 PDT
Comment on attachment 249819 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249819&action=review

(Reviewing informally…)

Thanks for the patch! I like the idea of having this documentation on how to make WebExtensions with the example code in the official documentation. So, it would be nice to land this patch after fixing a couple of nits.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:41
> + * #WebKitWebExtension works as a web plugin for the WebProcess. It allow you to execute code

I would just write “#WebKitWebExtensions is a plugin for the WebProcess” because calling it a “web plugin” might sounds misleading (people could understand that is a plugin made using web technologies, for example).

s/It allow/It allows/

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:45
> + * WebExtensions are a single compilation unit that are loaded similar to a GTK module.

s/loaded similar to/loaded in a way similar to/

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:52
> + *

Could we mark names of functions and macros with monospaced font? Provided we are using a recent-enough gtk-doc (which I think we are), it's just a matter of enclosing things in backticks, e.g.: `G_MODULE_EXPORT`.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:78
> + * WebKit has to know where it can to found the created #WebKitWebExtension. To do so you

s/where it can to found/where it can find/
Comment 4 Marcos Chavarría Teijeiro (irc: chavaone) 2015-03-31 08:53:42 PDT
Created attachment 249824 [details]
Patch
Comment 5 Adrian Perez 2015-03-31 09:06:03 PDT
Comment on attachment 249824 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249824&action=review

(Again, reviewing informally…)

Thanks for the updated patch. The new version looks good to me, with just a very small nit. We'll need now a reviewer to rubber-stamp the changes, and get the patch landed ☺

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:43
> + * Javascript code, for example.

Nit: capitalization → s/Javascript/JavaScript/
Comment 6 Marcos Chavarría Teijeiro (irc: chavaone) 2015-03-31 10:40:51 PDT
Created attachment 249832 [details]
Patch
Comment 7 Marcos Chavarría Teijeiro (irc: chavaone) 2015-03-31 10:42:03 PDT
> (Again, reviewing informally…)

Thank you for the quick review!! :))
Comment 8 Build Bot 2015-03-31 11:05:40 PDT
Comment on attachment 249832 [details]
Patch

Attachment 249832 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6057621261910016

New failing tests:
media/invalid-media-url-crash.html
Comment 9 Build Bot 2015-03-31 11:05:44 PDT
Created attachment 249835 [details]
Archive of layout-test-results from ews107 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 10 Build Bot 2015-03-31 12:03:52 PDT
Comment on attachment 249832 [details]
Patch

Attachment 249832 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5481830966886400

New failing tests:
media/invalid-media-url-crash.html
Comment 11 Build Bot 2015-03-31 12:03:56 PDT
Created attachment 249838 [details]
Archive of layout-test-results from ews103 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 12 Marcos Chavarría Teijeiro (irc: chavaone) 2015-04-15 00:16:54 PDT
Created attachment 250778 [details]
Patch
Comment 13 Carlos Garcia Campos 2015-05-20 01:40:58 PDT
Comment on attachment 250778 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250778&action=review

> Source/WebKit2/ChangeLog:8
> +        WebKitWebExtension has no documentation at all the only information

no documentation at all is at least inaccurate, WebKitWebExtension has a signal and a public method and both are documented. Initialization functions are also documented in WebKitWebExtension.h

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:37
> + * SECTION: WebKitWebExtension

So, the section documentation is what is missing then.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:41
> + * #WebKitWebExtension is a plugin for the WebProcess. It allows you to execute code in the

Do not use # here, since this creates a link to this point exactly. I would avoid using 'plugin' here, since it could be confused with browser plugins. I would use loadable module, for example.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:45
> + * WebExtensions are a single compilation unit that are loaded in a way similar to a GTK module.

I wouldn't mention GTK modules here either, I think previous paragraph already explained that this is loadable module loaded by the web process.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:46
> + * To create a #WebKitWebExtension you should write a module which implements a function

Do not use # here.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:47
> + * named `webkit_web_extension_initialize` or, in case you need to initilize the extension with

Use webkit_web_extension_initialize() instead of the quotes

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:48
> + * some data from the UI, `webkit_web_extension_initialize_with_user_data`. These functions

webkit_web_extension_initialize_with_user_data()

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:49
> + * types are WebKitWebExtensionInitializeFunction() and WebKitWebExtensionInitializeWithUserDataFunction()

WebKitWebExtensionInitializeFunction and WebKitWebExtensionInitializeWithUserDataFunction are not functions, use # instead of ().

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:50
> + * respectively. In addition the implemented function has to be public and it has to use

I would rephrase this a bit, something like. Web extensions must have a initialization function that could be either webkit_web_extension_initialize() with prototype #WebKitWebExtensionInitializeFunction or webkit_web_extension_initialize_with_user_data() with prototype #WebKitWebExtensionInitializeWithUserDataFunction. This function is called when the web process is initialized.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:51
> + * the `G_MODULE_EXPORT` macro.

#G_MODULE_EXPORT

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:71
> + * G_MODULE_EXPORT void
> + * webkit_web_extension_initialize_with_user_data (WebKitWebExtension *extension,
> + *                                                 const GVariant     *user_data)
> + * {
> + *     g_signal_connect (extension, "page-created",
> + *                       G_CALLBACK (web_page_created_callback),
> + *                       NULL);
> + * }

If we are not going to use the data in the example, it would be better to use webkit_web_extension_initialize() instead.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:76
> + * a #WebKitWebPage is created. You should also modify your building tools (e.g. CMake or
> + * Autotools) to compile this individual module.

I'm not sure we should mention build systems in api docs.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:78
> + * WebKit has to know where it can find the created #WebKitWebExtension. To do so you

Dot not use # here.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:80
> + * must be called as soon as posible in our app and before any WebProcess is launched.

in our app? I would just mention initialize-web-extensions signal as the recommended place to avoid confusions.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:83
> + * To provide the initialization data used by the `webkit_web_extension_initialize_with_user_data`

I guess you provide init data to the function, not by the function. In any case, I think Martin or any other native english speaker should review all this doc.

> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:100
> + *       context, WEB_EXTENSIONS_DIRECTORY);
> + *   webkit_web_context_set_web_extensions_initialization_user_data (
> + *      context, g_variant_new_uint32 (unique_id++));

It seems one of these lines is not correctly indented
Comment 14 Marcos Chavarría Teijeiro (irc: chavaone) 2015-05-20 03:43:22 PDT
Created attachment 253437 [details]
Patch
Comment 15 Marcos Chavarría Teijeiro (irc: chavaone) 2015-05-20 03:47:24 PDT
Comment on attachment 250778 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250778&action=review

>> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:83
>> + * To provide the initialization data used by the `webkit_web_extension_initialize_with_user_data`
> 
> I guess you provide init data to the function, not by the function. In any case, I think Martin or any other native english speaker should review all this doc.

I think this is OK because it is "initialization data **used by** the function". Anyway I agree that a English native speaker review would be very helpful.
Comment 16 Michael Catanzaro 2015-05-20 07:59:06 PDT
Marcos's sentence is better. You could say "To provide initialization data to the function" instead, but Marcos's version is more clear. I would not say "To provide the initialization data used to the function."

A few comments:

"It allows you to execute code in the WebProcess and being able to use the DOM API, to change any request or to inject custom JavaScript code, for example." Since you started off a list of items that begin with "to," the rest of the items should work following "to" as well; in particular, the tense change "being able" is out of place. I don't know what the fancy grammar rule for that is (in school I was taught "parallelism," but the Internet thinks that is something different). There are many different ways to fix this, e.g. "It allows you to execute code in the web process; for example, you can use the DOM API, modify HTTP requests, or inject custom JavaScript."

"GTK module" -> "GTK+ module"

Add the word "process" after "in case you need to initilize the extension with some data from the UI"

"These functions types" -> "These functions' types" since this is possessive. Later in this sentence, add a comma before "respectively," and then one more after "In addition" in the next sentence.

"This function must be called as soon as posible in our app and before any WebProcess is launched." I would say "This function must be called as soon as posible in our app, before any WebProcess is launched."

I could nitpick quite a bit more, but I don't think there's value in that. The English is pretty good. :)
Comment 17 Michael Catanzaro 2015-05-20 08:02:33 PDT
Actually, I almost missed this: initilize -> initialize

If you use gedit, you could temporarily turn on Highlight Misspelled Words to catch this.
Comment 18 Carlos Garcia Campos 2015-05-20 08:17:31 PDT
(In reply to comment #15)
> Comment on attachment 250778 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=250778&action=review
> 
> >> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:83
> >> + * To provide the initialization data used by the `webkit_web_extension_initialize_with_user_data`
> > 
> > I guess you provide init data to the function, not by the function. In any case, I think Martin or any other native english speaker should review all this doc.
> 
> I think this is OK because it is "initialization data **used by** the
> function". Anyway I agree that a English native speaker review would be very
> helpful.

Right, I missed the *used* when I read it, that's why it sounded weird to me.
Comment 19 Carlos Garcia Campos 2015-05-20 08:23:02 PDT
Comment on attachment 253437 [details]
Patch

Thanks
Comment 20 WebKit Commit Bot 2015-05-20 09:13:33 PDT
Comment on attachment 253437 [details]
Patch

Clearing flags on attachment: 253437

Committed r184638: <http://trac.webkit.org/changeset/184638>
Comment 21 WebKit Commit Bot 2015-05-20 09:13:40 PDT
All reviewed patches have been landed.  Closing bug.