Title: [99200] trunk/Tools
Revision
99200
Author
[email protected]
Date
2011-11-03 09:10:42 -0700 (Thu, 03 Nov 2011)

Log Message

[GTK] Remove WebKit2 C API from MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=71459

Reviewed by Martin Robinson.

Use the GTK+ API instead to add minimum functionality. The other
features will be ported to GTK+ API in following patches.

* MiniBrowser/gtk/BrowserWindow.c:
(activateUriEntryCallback): Use webkit_web_view_load_uri().
(goBackCallback): Use webkit_web_view_go_back().
(goForwardCallback): Use webkit_web_view_go_forward().
(webViewURIChanged): Update location entry with current uri using
webkit_web_view_get_uri().
(browserWindowFinalize):
(browserWindowGetProperty):
(browserWindowSetProperty):
(browser_window_init):
(browserWindowConstructed): Connect to notify::uri signal of
WebView to be notified when the URI changes.
(browser_window_class_init):
(browser_window_new): Use WebKitWebView.
(browser_window_get_view): Use WebKitWebView
* MiniBrowser/gtk/BrowserWindow.h:
* MiniBrowser/gtk/GNUmakefile.am:
* MiniBrowser/gtk/WebBundle/WebBundleMain.c: Removed.
* MiniBrowser/gtk/main.c:
(loadURI): Use webkit_web_view_new().
(main):

Modified Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (99199 => 99200)


--- trunk/Tools/ChangeLog	2011-11-03 16:07:22 UTC (rev 99199)
+++ trunk/Tools/ChangeLog	2011-11-03 16:10:42 UTC (rev 99200)
@@ -1,3 +1,35 @@
+2011-11-03  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Remove WebKit2 C API from MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=71459
+
+        Reviewed by Martin Robinson.
+
+        Use the GTK+ API instead to add minimum functionality. The other
+        features will be ported to GTK+ API in following patches.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (activateUriEntryCallback): Use webkit_web_view_load_uri().
+        (goBackCallback): Use webkit_web_view_go_back().
+        (goForwardCallback): Use webkit_web_view_go_forward().
+        (webViewURIChanged): Update location entry with current uri using
+        webkit_web_view_get_uri().
+        (browserWindowFinalize):
+        (browserWindowGetProperty):
+        (browserWindowSetProperty):
+        (browser_window_init):
+        (browserWindowConstructed): Connect to notify::uri signal of
+        WebView to be notified when the URI changes.
+        (browser_window_class_init):
+        (browser_window_new): Use WebKitWebView.
+        (browser_window_get_view): Use WebKitWebView
+        * MiniBrowser/gtk/BrowserWindow.h:
+        * MiniBrowser/gtk/GNUmakefile.am:
+        * MiniBrowser/gtk/WebBundle/WebBundleMain.c: Removed.
+        * MiniBrowser/gtk/main.c:
+        (loadURI): Use webkit_web_view_new().
+        (main):
+
 2011-11-03  Simon Hausmann  <[email protected]>
 
         [Qt] Unable to start MiniBrowser after run-webkit-tests

Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (99199 => 99200)


--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2011-11-03 16:07:22 UTC (rev 99199)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2011-11-03 16:10:42 UTC (rev 99200)
@@ -38,73 +38,62 @@
 
     GtkWidget *mainBox;
     GtkWidget *uriEntry;
-    GtkWidget *statusBar;
     GtkWidget *backItem;
     GtkWidget *forwardItem;
-    WKViewRef webView;
+    WebKitWebView *webView;
 
-    guint statusBarContextId;
-    WKBackForwardListRef history;
-
-    gchar *title;
-    gdouble loadProgress;
 };
 
 struct _BrowserWindowClass {
     GtkWindowClass parent;
 };
 
-static void browserWindowLoaderClientInit(BrowserWindow*);
-static void browserWindowUIClientInit(BrowserWindow*);
-static void browserWindowPolicyClientInit(BrowserWindow*);
-
 static gint windowCount = 0;
 
 G_DEFINE_TYPE(BrowserWindow, browser_window, GTK_TYPE_WINDOW)
 
-static void activateUriEntryCallback(BrowserWindow* window)
+static void activateUriEntryCallback(BrowserWindow *window)
 {
-    WKURLRef url = ""
-    WKPageLoadURL(WKViewGetPage(window->webView), url);
-    WKRelease(url);
+    webkit_web_view_load_uri(window->webView, gtk_entry_get_text(GTK_ENTRY(window->uriEntry)));
 }
 
-static void goBackCallback(BrowserWindow* window)
+static void goBackCallback(BrowserWindow *window)
 {
-    WKPageGoBack(WKViewGetPage(window->webView));
+    webkit_web_view_go_back(window->webView);
 }
 
-static void goForwardCallback(BrowserWindow* window)
+static void goForwardCallback(BrowserWindow *window)
 {
-    WKPageGoForward(WKViewGetPage(window->webView));
+    webkit_web_view_go_forward(window->webView);
 }
 
-static void browserWindowFinalize(GObject* gObject)
+static void webViewURIChanged(WebKitWebView *webView,  GParamSpec *pspec, BrowserWindow *window)
 {
-    BrowserWindow* window = BROWSER_WINDOW(gObject);
+    gtk_entry_set_text(GTK_ENTRY(window->uriEntry), webkit_web_view_get_uri(webView));
+}
 
-    g_free(window->title);
-
+static void browserWindowFinalize(GObject *gObject)
+{
     G_OBJECT_CLASS(browser_window_parent_class)->finalize(gObject);
 
     if (g_atomic_int_dec_and_test(&windowCount))
         gtk_main_quit();
 }
 
-static void browserWindowGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* pspec)
+static void browserWindowGetProperty(GObject *object, guint propId, GValue *value, GParamSpec *pspec)
 {
-    BrowserWindow* window = BROWSER_WINDOW(object);
+    BrowserWindow *window = BROWSER_WINDOW(object);
 
     switch (propId) {
     case PROP_VIEW:
-        g_value_set_object(value, (gpointer)browser_window_get_view(window));
+        g_value_set_object(value, browser_window_get_view(window));
         break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
     }
 }
 
-static void browserWindowSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* pspec)
+static void browserWindowSetProperty(GObject *object, guint propId, const GValue *value, GParamSpec *pspec)
 {
     BrowserWindow* window = BROWSER_WINDOW(object);
 
@@ -117,7 +106,7 @@
     }
 }
 
-static void browser_window_init(BrowserWindow* window)
+static void browser_window_init(BrowserWindow *window)
 {
     g_atomic_int_inc(&windowCount);
 
@@ -127,11 +116,7 @@
     g_signal_connect_swapped(window->uriEntry, "activate", G_CALLBACK(activateUriEntryCallback), (gpointer)window);
 
     GtkWidget *toolbar = gtk_toolbar_new();
-#if GTK_CHECK_VERSION(2, 15, 0)
     gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
-#else
-    gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL);
-#endif
     gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
 
     GtkToolItem *item = gtk_menu_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
@@ -169,32 +154,20 @@
     gtk_widget_show(vbox);
 }
 
-static void browserWindowConstructed(GObject* gObject)
+static void browserWindowConstructed(GObject *gObject)
 {
-    BrowserWindow* window = BROWSER_WINDOW(gObject);
+    BrowserWindow *window = BROWSER_WINDOW(gObject);
 
+    g_signal_connect(window->webView, "notify::uri", G_CALLBACK(webViewURIChanged), window);
+
     gtk_box_pack_start(GTK_BOX(window->mainBox), GTK_WIDGET(window->webView), TRUE, TRUE, 0);
     gtk_widget_show(GTK_WIDGET(window->webView));
-
-    window->statusBar = gtk_statusbar_new();
-    window->statusBarContextId = gtk_statusbar_get_context_id(GTK_STATUSBAR(window->statusBar), "Link Hover");
-    gtk_box_pack_start(GTK_BOX(window->mainBox), window->statusBar, FALSE, FALSE, 0);
-    gtk_widget_show(window->statusBar);
-
-    window->history = WKPageGetBackForwardList(WKViewGetPage(window->webView));
-
-    browserWindowLoaderClientInit(window);
-    browserWindowUIClientInit(window);
-    browserWindowPolicyClientInit(window);
-
-    WKPageGroupRef groupRef = WKPageGetPageGroup(WKViewGetPage(window->webView));
-    WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(groupRef);
-    WKPreferencesSetDeveloperExtrasEnabled(preferencesRef, true);
 }
 
-static void browser_window_class_init(BrowserWindowClass* klass)
+static void browser_window_class_init(BrowserWindowClass *klass)
 {
-    GObjectClass* gobjectClass = G_OBJECT_CLASS(klass);
+    GObjectClass *gobjectClass = G_OBJECT_CLASS(klass);
+
     gobjectClass->constructed = browserWindowConstructed;
     gobjectClass->get_property = browserWindowGetProperty;
     gobjectClass->set_property = browserWindowSetProperty;
@@ -205,518 +178,21 @@
                                     g_param_spec_object("view",
                                                         "View",
                                                         "The web view of this window",
-                                                        GTK_TYPE_WIDGET,
+                                                        WEBKIT_TYPE_WEB_VIEW,
                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
-static char* WKStringGetCString(WKStringRef string)
-{
-    size_t length = WKStringGetMaximumUTF8CStringSize(string);
-    char *buffer = (char *) g_malloc(length);
-    WKStringGetUTF8CString(string, buffer, length);
-    return buffer;
-}
-
-static char* WKURLGetCString(WKURLRef url)
-{
-    WKStringRef urlString = WKURLCopyString(url);
-    char *urlText = WKStringGetCString(urlString);
-    WKRelease(urlString);
-    return urlText;
-}
-
-static void browserWindowUpdateTitle(BrowserWindow* window)
-{
-    GString *string = g_string_new(window->title);
-    gdouble loadProgress = window->loadProgress * 100;
-    g_string_append(string, " - WebKit Launcher");
-    if (loadProgress < 100)
-        g_string_append_printf(string, " (%f%%)", loadProgress);
-    gchar *title = g_string_free(string, FALSE);
-    gtk_window_set_title(GTK_WINDOW(window), title);
-    g_free(title);
-}
-
-static void browserWindowSetTitle(BrowserWindow* window, const gchar* title)
-{
-    if (!g_strcmp0(window->title, title))
-        return;
-
-    g_free(window->title);
-    window->title = g_strdup(title);
-    browserWindowUpdateTitle(window);
-}
-
-static void browserWindowSetLoadProgress(BrowserWindow* window, gdouble progress)
-{
-    window->loadProgress = progress;
-    browserWindowUpdateTitle(window);
-}
-
-static void browserWindowUpdateURL(BrowserWindow* window, WKURLRef url)
-{
-    if (!url) {
-        gtk_entry_set_text(GTK_ENTRY(window->uriEntry), "");
-        return;
-    }
-
-    char *urlText = WKURLGetCString(url);
-    gtk_entry_set_text(GTK_ENTRY(window->uriEntry), urlText);
-    g_free(urlText);
-}
-
-static void browserWindowHistoryItemActivated(BrowserWindow *window, GtkAction *action)
-{
-    WKBackForwardListItemRef item = g_object_get_data(G_OBJECT(action), "back-forward-list-item");
-    if (!item)
-        return;
-
-    WKPageGoToBackForwardListItem(WKViewGetPage(window->webView), item);
-}
-
-static void browserWindowHistoryItemSelected(BrowserWindow *window, GtkMenuItem *item)
-{
-    gtk_statusbar_pop(GTK_STATUSBAR(window->statusBar), window->statusBarContextId);
-
-    GtkAction *action = ""
-    if (!action)
-        return;
-
-    gtk_statusbar_push(GTK_STATUSBAR(window->statusBar), window->statusBarContextId, gtk_action_get_name(action));
-}
-
-static GtkAction *createGtkActionFromBackForwardItem(WKBackForwardListItemRef item)
-{
-    if (!item)
-        return 0;
-
-    WKURLRef url = ""
-    char *name = WKURLGetCString(url);
-    WKRelease(url);
-
-    WKStringRef title = WKBackForwardListItemCopyTitle(item);
-    char *label = WKStringGetCString(title);
-    WKRelease(title);
-
-    GtkAction *action = "" label, 0, 0);
-    g_free(name);
-    g_free(label);
-
-    return action;
-}
-
-static GtkWidget *browserWindowCreateMenuItemFromBackForwardItem(BrowserWindow *window, WKBackForwardListItemRef item)
-{
-    GtkAction *action = ""
-    if (!action)
-        return 0;
-
-    g_object_set_data_full(G_OBJECT(action), "back-forward-list-item", (gpointer)WKRetain(item), (GDestroyNotify)WKRelease);
-    g_signal_connect_swapped(action, "activate", G_CALLBACK(browserWindowHistoryItemActivated), window);
-
-    GtkWidget *menuItem = gtk_action_create_menu_item(action);
-    g_signal_connect_swapped(menuItem, "select", G_CALLBACK(browserWindowHistoryItemSelected), window);
-    g_object_unref(action);
-
-    return menuItem;
-}
-
-static GtkWidget *browserWindowCreateBackForwardMenu(BrowserWindow *window, WKArrayRef list)
-{
-    if (!list)
-        return 0;
-
-    guint listCount = WKArrayGetSize(list);
-    if (!listCount)
-        return 0;
-
-    GtkWidget *menu = gtk_menu_new();
-    gboolean hasItems = FALSE;
-    guint i;
-    for (i = 0; i < listCount; i++) {
-        WKBackForwardListItemRef item = WKArrayGetItemAtIndex(list, i);
-        GtkWidget *menuItem = browserWindowCreateMenuItemFromBackForwardItem(window, item);
-        if (!menuItem)
-            continue;
-
-        gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuItem);
-        gtk_widget_show(menuItem);
-        hasItems = TRUE;
-    }
-
-    if (!hasItems) {
-        gtk_widget_destroy(menu);
-        return 0;
-    }
-
-    return menu;
-}
-
-static void browserWindowUpdateNavigationActions(BrowserWindow* window)
-{
-    gtk_widget_set_sensitive(window->backItem, WKPageCanGoBack(WKViewGetPage(window->webView)));
-    gtk_widget_set_sensitive(window->forwardItem, WKPageCanGoForward(WKViewGetPage(window->webView)));
-
-    WKArrayRef list = WKBackForwardListCopyBackListWithLimit(window->history, 10);
-    GtkWidget *menu = browserWindowCreateBackForwardMenu(window, list);
-    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(window->backItem), menu);
-    if (list)
-        WKRelease(list);
-
-    list = WKBackForwardListCopyForwardListWithLimit(window->history, 10);
-    menu = browserWindowCreateBackForwardMenu(window, list);
-    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(window->forwardItem), menu);
-    if (list)
-        WKRelease(list);
-}
-
-// Loader client.
-static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-
-    WKURLRef url = ""
-    browserWindowUpdateURL(BROWSER_WINDOW(clientInfo), url);
-    if (url)
-        WKRelease(url);
-}
-
-static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-
-    WKURLRef url = ""
-    browserWindowUpdateURL(BROWSER_WINDOW(clientInfo), url);
-    if (url)
-        WKRelease(url);
-}
-
-static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-
-    WKURLRef url = ""
-    browserWindowUpdateURL(BROWSER_WINDOW(clientInfo), url);
-    if (url)
-        WKRelease(url);
-}
-
-static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-
-    WKURLRef url = ""
-    browserWindowUpdateURL(BROWSER_WINDOW(clientInfo), url);
-    if (url)
-        WKRelease(url);
-}
-
-static void didFinishDocumentLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-}
-
-static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-
-    BrowserWindow* window = BROWSER_WINDOW(clientInfo);
-    gtk_widget_grab_focus(GTK_WIDGET(window->webView));
-}
-
-static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-}
-
-static void didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-
-    char *titleText = WKStringGetCString(title);
-    browserWindowSetTitle(BROWSER_WINDOW(clientInfo), titleText);
-    g_free(titleText);
-}
-
-static void didFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-}
-
-static void didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-}
-
-static void didRemoveFrameFromHierarchy(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
-{
-    if (!WKFrameIsMainFrame(frame))
-        return;
-}
-
-static void didStartProgress(WKPageRef page, const void* clientInfo)
-{
-    browserWindowSetLoadProgress(BROWSER_WINDOW(clientInfo), 0.);
-}
-
-static void didChangeProgress(WKPageRef page, const void* clientInfo)
-{
-    browserWindowSetLoadProgress(BROWSER_WINDOW(clientInfo), WKPageGetEstimatedProgress(page));
-}
-
-static void didFinishProgress(WKPageRef page, const void* clientInfo)
-{
-    browserWindowSetLoadProgress(BROWSER_WINDOW(clientInfo), 1.);
-}
-
-static void didBecomeUnresponsive(WKPageRef page, const void* clientInfo)
-{
-}
-
-static void didBecomeResponsive(WKPageRef page, const void* clientInfo)
-{
-}
-
-static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo)
-{
-    browserWindowUpdateNavigationActions(BROWSER_WINDOW(clientInfo));
-}
-
-static void browserWindowLoaderClientInit(BrowserWindow* window)
-{
-    WKPageLoaderClient loadClient = {
-        kWKPageLoaderClientCurrentVersion,
-        window,  /* clientInfo */
-        didStartProvisionalLoadForFrame,
-        didReceiveServerRedirectForProvisionalLoadForFrame,
-        didFailProvisionalLoadWithErrorForFrame,
-        didCommitLoadForFrame,
-        didFinishDocumentLoadForFrame,
-        didFinishLoadForFrame,
-        didFailLoadWithErrorForFrame,
-        0,       /* didSameDocumentNavigationForFrame */
-        didReceiveTitleForFrame,
-        didFirstLayoutForFrame,
-        didFirstVisuallyNonEmptyLayoutForFrame,
-        didRemoveFrameFromHierarchy,
-        0,       /* didDisplayInsecureContentForFrame */
-        0,       /* didRunInsecureContentForFrame */
-        0,       /* canAuthenticateAgainstProtectionSpaceInFrame */
-        0,       /* didReceiveAuthenticationChallengeInFrame */
-        didStartProgress,
-        didChangeProgress,
-        didFinishProgress,
-        didBecomeUnresponsive,
-        didBecomeResponsive,
-        0,       /* processDidCrash */
-        didChangeBackForwardList,
-        0,       /* shouldGoToBackForwardListItem */
-        0        /* didFailToInitializePlugin */
-    };
-    WKPageSetPageLoaderClient(WKViewGetPage(window->webView), &loadClient);
-}
-
-// UI Client.
-static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef request, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton button, const void *clientInfo)
-{
-    WKViewRef webView = WKViewCreate(WKPageGetContext(page), 0);
-    BrowserWindow* window = BROWSER_WINDOW(browser_window_new(webView));
-    return WKRetain(WKViewGetPage(window->webView));
-}
-
-static void showPage(WKPageRef page, const void *clientInfo)
-{
-    gtk_widget_show(GTK_WIDGET(clientInfo));
-}
-
-static void closePage(WKPageRef page, const void *clientInfo)
-{
-    gtk_widget_destroy(GTK_WIDGET(clientInfo));
-}
-
-static GtkWidget* createMessageDialog(GtkWindow *parent, GtkMessageType type, GtkButtonsType buttons, gint defaultResponse, WKStringRef message, WKFrameRef frame)
-{
-    char *messageText = WKStringGetCString(message);
-    GtkWidget *dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT, type, buttons, "%s", messageText);
-    g_free(messageText);
-
-    WKURLRef url = ""
-    char *urlText = WKURLGetCString(url);
-    WKRelease(url);
-    gchar *title = g_strdup_printf("_javascript_ - %s", urlText);
-    g_free(urlText);
-    gtk_window_set_title(GTK_WINDOW(dialog), title);
-    g_free(title);
-
-    gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse);
-
-    return dialog;
-}
-
-static void focus(WKPageRef page, const void *clientInfo)
-{
-    BrowserWindow *window = BROWSER_WINDOW(clientInfo);
-    gtk_widget_grab_focus(GTK_WIDGET(window->webView));
-} 
-
-static void unfocus(WKPageRef page, const void *clientInfo)
-{
-    BrowserWindow *window = BROWSER_WINDOW(clientInfo);
-    if (gtk_widget_is_toplevel(GTK_WIDGET(window)))
-        gtk_window_set_focus(GTK_WINDOW(window), NULL);
-} 
-
-static void runJavaScriptAlert(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo)
-{
-    GtkWidget *dialog = createMessageDialog(GTK_WINDOW(clientInfo), GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, GTK_RESPONSE_CLOSE, message, frame);
-    gtk_dialog_run(GTK_DIALOG(dialog));
-    gtk_widget_destroy(dialog);
-}
-
-static bool runJavaScriptConfirm(WKPageRef page, WKStringRef message, WKFrameRef frame, const void* clientInfo)
-{
-    GtkWidget *dialog = createMessageDialog(GTK_WINDOW(clientInfo), GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, message, frame);
-    bool returnValue = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK);
-    gtk_widget_destroy(dialog);
-
-    return returnValue;
-}
-
-static WKStringRef runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void* clientInfo)
-{
-    GtkWidget *dialog = createMessageDialog(GTK_WINDOW(clientInfo), GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, message, frame);
-
-    GtkWidget *entry = gtk_entry_new();
-    char *value = WKStringGetCString(defaultValue);
-    gtk_entry_set_text(GTK_ENTRY(entry), value);
-    g_free(value);
-    gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry);
-    gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
-    gtk_widget_show(entry);
-
-    WKStringRef returnValue = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) ? WKStringCreateWithUTF8CString(gtk_entry_get_text(GTK_ENTRY(entry))) : 0;
-    gtk_widget_destroy(dialog);
-
-    return returnValue;
-}
-
-static void mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo)
-{
-    BrowserWindow *window = BROWSER_WINDOW(clientInfo);
-    gtk_statusbar_pop(GTK_STATUSBAR(window->statusBar), window->statusBarContextId);
-
-    WKURLRef linkUrlRef = WKHitTestResultCopyAbsoluteLinkURL(hitTestResult);
-    if (!linkUrlRef)
-        return;
-
-    gchar *link = WKURLGetCString(linkUrlRef);
-    WKRelease(linkUrlRef);
-    gtk_statusbar_push(GTK_STATUSBAR(window->statusBar), window->statusBarContextId, link);
-    g_free(link);
-}
-
-static void browserWindowUIClientInit(BrowserWindow *window)
-{
-    WKPageUIClient uiClient = {
-        kWKPageUIClientCurrentVersion,
-        window, /* clientInfo */
-        0,      /* createNewPage_deprecatedForUseWithV0 */
-        showPage,
-        closePage,
-        0,      /* takeFocus */
-        focus,
-        unfocus,
-        runJavaScriptAlert,
-        runJavaScriptConfirm,
-        runJavaScriptPrompt,
-        0,      /* setStatusText */
-        0,      /* mouseDidMoveOverElement_deprecatedForUseWithV0 */
-        0,      /* missingPluginButtonClicked */
-        0,      /* didNotHandleKeyEvent */
-        0,      /* didNotHandleWheelEvent */
-        0,      /* toolbarsAreVisible */
-        0,      /* setToolbarsAreVisible */
-        0,      /* menuBarIsVisible */
-        0,      /* setMenuBarIsVisible */
-        0,      /* statusBarIsVisible */
-        0,      /* setStatusBarIsVisible */
-        0,      /* isResizable */
-        0,      /* setIsResizable */
-        0,      /* getWindowFrame */
-        0,      /* setWindowFrame */
-        0,      /* runBeforeUnloadConfirmPanel */
-        0,      /* didDraw */
-        0,      /* pageDidScroll */
-        0,      /* exceededDatabaseQuota */
-        0,      /* runOpenPanel */
-        0,      /* decidePolicyForGeolocationPermissionRequest */
-        0,      /* headerHeight */
-        0,      /* footerHeight */
-        0,      /* drawHeader */
-        0,      /* drawFooter */
-        0,      /* printFrame */
-        0,      /* runModal */
-        0,      /* didCompleteRubberBandForMainFrame */
-        0,      /* saveDataToFileInDownloadsFolder */
-        0,      /* shouldInterruptJavaScript */
-        createNewPage,
-        mouseDidMoveOverElement
-    };
-    WKPageSetPageUIClient(WKViewGetPage(window->webView), &uiClient);
-}
-
-static void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
-{
-    if (navigationType != kWKFrameNavigationTypeLinkClicked || mouseButton != kWKEventMouseButtonMiddleButton) {
-        WKFramePolicyListenerUse(listener);
-        return;
-    }
-
-    WKViewRef webView = WKViewCreate(WKPageGetContext(page), 0);
-    GtkWidget *window = browser_window_new(webView);
-    WKURLRef url = ""
-    WKPageLoadURL(WKViewGetPage(webView), url);
-    WKRelease(url);
-    gtk_widget_grab_focus(GTK_WIDGET(webView));
-    gtk_widget_show(window);
-
-    WKFramePolicyListenerIgnore(listener);
-}
-
-static void browserWindowPolicyClientInit(BrowserWindow* window)
-{
-    WKPagePolicyClient policyClient = {
-        kWKPagePolicyClientCurrentVersion,
-        window, /* clientInfo */
-        decidePolicyForNavigationAction,
-        0,      /* decidePolicyForNewWindowAction */
-        0,      /* decidePolicyForResponse */
-        0       /* unableToImplementPolicy */
-    };
-    WKPageSetPagePolicyClient(WKViewGetPage(window->webView), &policyClient);
-}
-
 // Public API.
-GtkWidget* browser_window_new(WKViewRef view)
+GtkWidget *browser_window_new(WebKitWebView *view)
 {
-    g_return_val_if_fail(GTK_IS_WIDGET(view), 0);
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(view), 0);
 
     return GTK_WIDGET(g_object_new(BROWSER_TYPE_WINDOW,
                                    "type", GTK_WINDOW_TOPLEVEL,
                                    "view", view, NULL));
 }
 
-WKViewRef browser_window_get_view(BrowserWindow* window)
+WebKitWebView *browser_window_get_view(BrowserWindow *window)
 {
     g_return_val_if_fail(BROWSER_IS_WINDOW(window), 0);
 

Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.h (99199 => 99200)


--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.h	2011-11-03 16:07:22 UTC (rev 99199)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.h	2011-11-03 16:10:42 UTC (rev 99200)
@@ -26,7 +26,7 @@
 #ifndef BrowserWindow_h
 #define BrowserWindow_h
 
-#include <WebKit2/WebKit2.h>
+#include <webkit2/webkit2.h>
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
@@ -43,8 +43,8 @@
 
 GType browser_window_get_type(void);
 
-GtkWidget* browser_window_new(WKViewRef);
-WKViewRef browser_window_get_view(BrowserWindow*);
+GtkWidget* browser_window_new(WebKitWebView*);
+WebKitWebView* browser_window_get_view(BrowserWindow*);
 
 G_END_DECLS
 

Modified: trunk/Tools/MiniBrowser/gtk/GNUmakefile.am (99199 => 99200)


--- trunk/Tools/MiniBrowser/gtk/GNUmakefile.am	2011-11-03 16:07:22 UTC (rev 99199)
+++ trunk/Tools/MiniBrowser/gtk/GNUmakefile.am	2011-11-03 16:10:42 UTC (rev 99200)
@@ -1,9 +1,10 @@
-bin_PROGRAMS += \
+noinst_PROGRAMS += \
 	Programs/MiniBrowser
 
 Programs_MiniBrowser_CPPFLAGS = \
 	-I$(srcdir)/Source \
-	-I$(top_builddir)/DerivedSources/WebKit2/include \
+	-I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk \
+	-I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk/include \
 	-DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs/\" \
 	$(global_cppflags) \
 	$(GLIB_CFLAGS) \
@@ -14,15 +15,6 @@
 	Tools/MiniBrowser/gtk/BrowserWindow.c \
 	Tools/MiniBrowser/gtk/main.c
 
-BUILT_SOURCES += \
-	generate-minibrowser-forward-headers
-
-MiniBrowser := $(srcdir)/Tools/MiniBrowser/gtk
-MiniBrowserFwdHeaders := $(GENSOURCES_WEBKIT2)/include
-generate-minibrowser-forward-headers: $(WebKit2)/Scripts/generate-forwarding-headers.pl $(Programs_MiniBrowser_SOURCES)
-	$(AM_V_GEN)$(PERL) $< $(MiniBrowser) $(MiniBrowserFwdHeaders) gtk
-	$(AM_V_GEN)$(PERL) $< $(MiniBrowser) $(MiniBrowserFwdHeaders) soup
-
 Programs_MiniBrowser_LDADD = \
 	libwebkit2gtk-@WEBKITGTK_API_MAJOR_VERSION@.@[email protected] \
 	$(GLIB_LIBS) \
@@ -35,20 +27,3 @@
 CLEANFILES += \
 	$(top_builddir)/Programs/MiniBrowser
 
-# Injected bundle
-noinst_LTLIBRARIES += Libraries/libMiniBrowserWebBundle.la
-Libraries_libMiniBrowserWebBundle_la_SOURCES = \
-	Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c
-
-Libraries_libMiniBrowserWebBundle_la_LDFLAGS = \
-	-rpath ${shell pwd}/$(top_builddir)/../unix/TestNetscapePlugin/.libs \
-	$(no_undefined) \
-	-avoid-version \
-	-module
-
-Libraries_libMiniBrowserWebBundle_la_CPPFLAGS = \
-	-I$(top_builddir)/DerivedSources/InjectedBundle \
-	-I$(top_builddir)/DerivedSources/WebKit2/include \
-	$(global_cppflags) \
-	$(_javascript_core_cppflags) \
-	$(GLIB_CFLAGS)

Deleted: trunk/Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c (99199 => 99200)


--- trunk/Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c	2011-11-03 16:07:22 UTC (rev 99199)
+++ trunk/Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c	2011-11-03 16:10:42 UTC (rev 99200)
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <WebKit2/WKBundle.h>
-#include <WebKit2/WKBundleHitTestResult.h>
-#include <WebKit2/WKBundleInitialize.h>
-#include <WebKit2/WKBundlePage.h>
-#include <glib.h>
-#include <string.h>
-
-static WKBundleRef globalBundle;
-
-static void mouseDidMoveOverElement(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef *userData, const void *clientInfo)
-{
-    *userData = WKBundleHitTestResultCopyAbsoluteLinkURL(hitTestResult);
-}
-
-static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
-{
-    WKBundlePageUIClient uiClient;
-    memset(&uiClient, 0, sizeof(uiClient));
-    uiClient.version = kWKBundlePageUIClientCurrentVersion;
-    uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement;
-
-    WKBundlePageSetUIClient(page, &uiClient);
-}
-
-void WKBundleInitialize(WKBundleRef bundle, WKTypeRef initializationUserData)
-{
-    globalBundle = bundle;
-
-    WKBundleClient client = {
-        kWKBundleClientCurrentVersion,
-        0,
-        didCreatePage,
-        0, /* willDestroyPage */
-        0, /* didInitializePageGroup */
-        0, /* didRecieveMessage */
-    };
-    WKBundleSetClient(bundle, &client);
-}

Modified: trunk/Tools/MiniBrowser/gtk/main.c (99199 => 99200)


--- trunk/Tools/MiniBrowser/gtk/main.c	2011-11-03 16:07:22 UTC (rev 99199)
+++ trunk/Tools/MiniBrowser/gtk/main.c	2011-11-03 16:10:42 UTC (rev 99200)
@@ -26,27 +26,11 @@
  */
 
 #include "BrowserWindow.h"
-#include <WebKit2/WebKit2.h>
+#include <webkit2/webkit2.h>
 #include <gtk/gtk.h>
 
 static const gchar **uriArguments = NULL;
 
-static WKContextRef createWKContextWithInjectedBundle()
-{
-    WKStringRef bundlePath = WKStringCreateWithUTF8CString("Libraries/.libs/libMiniBrowserWebBundle.so");
-    WKContextRef processContext = WKContextCreateWithInjectedBundlePath(bundlePath);
-    WKContextInjectedBundleClient bundleClient = {
-        kWKContextInjectedBundleClientCurrentVersion,
-        0, /* clientInfo */
-        0, /* didRecieveMessageFromInjectedBundle,*/
-        0
-    };
-    WKContextSetInjectedBundleClient(processContext, &bundleClient);
-    WKRelease(bundlePath);
-
-    return processContext;
-}
-
 static gchar *argumentToURL(const char *filename)
 {
     GFile *gfile = g_file_new_for_commandline_arg(filename);
@@ -56,17 +40,15 @@
     return fileURL;
 }
 
-static void loadURI(const gchar *uri, WKContextRef processContext)
+static void loadURI(const gchar *uri)
 {
-    WKViewRef webView = WKViewCreate(processContext, 0);
-    GtkWidget *mainWindow = browser_window_new(webView);
+    GtkWidget *webView = webkit_web_view_new();
+    GtkWidget *mainWindow = browser_window_new(WEBKIT_WEB_VIEW(webView));
     gchar *url = ""
-    WKURLRef wkURL = WKURLCreateWithUTF8CString(url);
+    webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webView), url);
     g_free(url);
-    WKPageLoadURL(WKViewGetPage(webView), wkURL);
-    WKRelease(wkURL);
 
-    gtk_widget_grab_focus(GTK_WIDGET(webView));
+    gtk_widget_grab_focus(webView);
     gtk_widget_show(mainWindow);
 }
 
@@ -97,15 +79,13 @@
     // Prefer the not installed web and plugin processes.
     g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE);
 
-    WKContextRef processContext = createWKContextWithInjectedBundle();
-
     if (uriArguments) {
         int i;
 
         for (i = 0; uriArguments[i]; i++)
-            loadURI(uriArguments[i], processContext);
+            loadURI(uriArguments[i]);
     } else
-        loadURI("http://www.webkitgtk.org/", processContext);
+        loadURI("http://www.webkitgtk.org/");
 
     gtk_main();
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to