wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    GList* list = webkit_web_back_forward_list_get_forward_list_with_limit(history,
                                                                           m_historyLimit);
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for(guint i = 0; i < g_list_length(list); i++)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        forwardhist.push_back(item);
    }
    return forwardhist;
}
static char* gtkWebBrowserGetBackCountAttrib(Ihandle* ih)
{
  WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list ((WebKitWebView*)ih->handle);
  char* str = iupStrGetMemory(30);
  sprintf(str, "%d", webkit_web_back_forward_list_get_back_length(back_forward_list));
  return str;
}
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    GList* list = webkit_web_back_forward_list_get_back_list_with_limit(history,
                                                                        m_historyLimit);
    //We need to iterate in reverse to get the order we desire
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for(int i = g_list_length(list) - 1; i >= 0 ; i--)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        backhist.push_back(item);
    }
    return backhist;
}
static char* gtkWebBrowserGetItemHistoryAttrib(Ihandle* ih, int id)
{
  WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list ((WebKitWebView*)ih->handle);
  WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(back_forward_list, id);
  char* str = iupStrGetMemory(1024);
  sprintf(str, "%s", webkit_web_history_item_get_uri(item));
  return str;
}
示例#5
0
static char* gtkWebBrowserGetItemHistoryAttrib(Ihandle* ih, int id)
{
  WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list ((WebKitWebView*)ih->handle);
  WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(back_forward_list, id);
  if (item)
    return iupStrReturnStr(webkit_web_history_item_get_uri(item));
  else
    return NULL;
}
 BackForwardListTest()
     : m_list(webkit_web_view_get_back_forward_list(m_webView))
     , m_changedFlags(0)
     , m_hasChanged(false)
     , m_expectedRemovedItems(0)
 {
     g_signal_connect(m_list, "changed", G_CALLBACK(backForwardListChanged), this);
     assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_list));
 }
示例#7
0
void WebViewTest::goForward()
{
    if (webkit_web_view_can_go_forward(m_webView)) {
        WebKitBackForwardList* list = webkit_web_view_get_back_forward_list(m_webView);
        WebKitBackForwardListItem* item = webkit_back_forward_list_get_nth_item(list, 1);
        m_activeURI = webkit_back_forward_list_item_get_original_uri(item);
    }

    // Call go_forward even when can_go_forward returns FALSE to check nothing happens.
    webkit_web_view_go_forward(m_webView);
}
示例#8
0
文件: normal.c 项目: fanglingsu/vimb
static VbResult normal_navigate(Client *c, const NormalCmdInfo *info)
{
    int count;
    WebKitBackForwardList *list;
    WebKitBackForwardListItem *item;

    WebKitWebView *view = c->webview;
    switch (info->key) {
        case CTRL('I'): /* fall through */
        case CTRL('O'):
            count = info->count ? info->count : 1;
            if (info->key == CTRL('O')) {
                if (webkit_web_view_can_go_back(view)) {
                    list = webkit_web_view_get_back_forward_list(view);
                    item = webkit_back_forward_list_get_nth_item(list, -1 * count);
                    webkit_web_view_go_to_back_forward_list_item(view, item);
                }
            } else {
                if (webkit_web_view_can_go_forward(view)) {
                    list = webkit_web_view_get_back_forward_list(view);
                    item = webkit_back_forward_list_get_nth_item(list, count);
                    webkit_web_view_go_to_back_forward_list_item(view, item);
                }
            }
            break;

        case 'r':
            webkit_web_view_reload(view);
            break;

        case 'R':
            webkit_web_view_reload_bypass_cache(view);
            break;

        case CTRL('C'):
            webkit_web_view_stop_loading(view);
            break;
    }

    return RESULT_COMPLETE;
}
static void
ephy_session_tab_closed (EphySession *session,
			 EphyNotebook *notebook,
			 EphyEmbed *embed,
			 gint position)
{
	EphySessionPrivate *priv = session->priv;
	EphyWebView *view;
	const char *address;
#ifdef HAVE_WEBKIT2
	WebKitBackForwardList *source;
#else
	WebKitWebBackForwardList *source;
#endif
	ClosedTab *tab;
	GList *items = NULL;

	view = ephy_embed_get_web_view (embed);
	address = ephy_web_view_get_address (view);

	source = webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));
#ifdef HAVE_WEBKIT2
	items = webkit_back_forward_list_get_back_list_with_limit (source, EPHY_WEBKIT_BACK_FORWARD_LIMIT);
#else
	items = webkit_web_back_forward_list_get_back_list_with_limit (source, EPHY_WEBKIT_BACK_FORWARD_LIMIT);
#endif
	if (items == NULL && g_strcmp0 (address, "ephy-about:overview") == 0)
		return;

	if (g_queue_get_length (priv->closed_tabs) == MAX_CLOSED_TABS)
	{
		tab = g_queue_pop_tail (priv->closed_tabs);
		if (tab->parent_location && !find_tab_with_notebook (priv->closed_tabs, *tab->parent_location))
		{
			parent_location_free (tab->parent_location, TRUE);
		}

		closed_tab_free (tab);
		tab = NULL;
	}

	items = g_list_reverse (items);
	tab = closed_tab_new (priv->closed_tabs, address, items, position, notebook);
	g_list_free (items);

	g_queue_push_head (priv->closed_tabs, tab);

	if (g_queue_get_length (priv->closed_tabs) == 1)
		g_object_notify (G_OBJECT (session), "can-undo-tab-closed");

	LOG ("Added: %s to the list (%d elements)",
	     address, g_queue_get_length (priv->closed_tabs));
}
示例#10
0
void wxWebViewWebKit::EnableHistory(bool enable)
{
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view));
    if(enable)
    {
        webkit_web_back_forward_list_set_limit(history, m_historyLimit);
    }
    else
    {
        webkit_web_back_forward_list_set_limit(history, 0);
    }
}
示例#11
0
size_t LayoutTestController::webHistoryItemCount()
{
    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
    WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView);

    if (!list)
        return -1;

    // We do not add the current page to the total count as it's not
    // considered in DRT tests
    return webkit_web_back_forward_list_get_back_length(list) +
            webkit_web_back_forward_list_get_forward_length(list);
}
示例#12
0
bool
DumpRenderTreeWKC::beginTest(const char* uri)
{
    std::string path_or_url(uri);
    std::string expected_pixel_hash;

    size_t separator_pos = path_or_url.find("'");
    if (separator_pos != std::string::npos) {
        path_or_url = std::string(uri, 0, separator_pos);
        expected_pixel_hash = std::string(uri, separator_pos + 1);
    }

    const std::string test_url(uri);

    resetDefaultsToConsistentValues();

    fController = LayoutTestController::create(test_url, expected_pixel_hash).leakRef();
    fTopLoadingFrame = 0;
    fDone = false;

    fController->setIconDatabaseEnabled(false);

    if (shouldLogFrameLoadDelegates(path_or_url.c_str()))
        fController->setDumpFrameLoadCallbacks(true);

    if (shouldOpenWebInspector(path_or_url.c_str()))
        fController->showWebInspector();

#if 0
    bool isSVGW3CTest = (fController->testPathOrURL().find("svg/W3C-SVG-1.1") != string::npos);
    GtkAllocation size;
    size.x = size.y = 0;
    size.width = isSVGW3CTest ? 480 : maxViewWidth;
    size.height = isSVGW3CTest ? 360 : maxViewHeight;
    gtk_window_resize(GTK_WINDOW(window), size.width, size.height);
    gtk_widget_size_allocate(container, &size);
#endif

#if 0
    if (prevTestBFItem)
        g_object_unref(prevTestBFItem);
    WebKitWebBackForwardList* bfList = webkit_web_view_get_back_forward_list(webView);
    prevTestBFItem = webkit_web_back_forward_list_get_current_item(bfList);
    if (prevTestBFItem)
        g_object_ref(prevTestBFItem);
#endif

    fView->loadURI(uri);

    return true;
}
示例#13
0
static void
wxgtk_webview_webkit_load_status(GtkWidget* widget, 
                                 GParamSpec*,
                                 wxWebViewWebKit *webKitCtrl)
{
    if (!webKitCtrl->m_ready) return;

    wxString url = webKitCtrl->GetCurrentURL();

    WebKitLoadStatus status;
    g_object_get(G_OBJECT(widget), "load-status", &status, NULL);

    wxString target; // TODO: get target (if possible)

    if (status == WEBKIT_LOAD_FINISHED)
    {
        WebKitWebBackForwardList* hist = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(widget));
        WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_current_item(hist);
        //We have to check if we are actually storing history
        //If the item isn't added we add it ourselves, it isn't added otherwise
        //with a custom scheme.
        if(WEBKIT_IS_WEB_HISTORY_ITEM(item) && webkit_web_history_item_get_uri(item) != url)
        {
            WebKitWebHistoryItem*
                newitem = webkit_web_history_item_new_with_data
                          (
                            url.utf8_str(),
                            webKitCtrl->GetCurrentTitle().utf8_str()
                          );
            webkit_web_back_forward_list_add_item(hist, newitem);
        }

        webKitCtrl->m_busy = false;
        wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED,
                             webKitCtrl->GetId(),
                             url, target);

        if (webKitCtrl && webKitCtrl->GetEventHandler())
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
    }
    else if (status ==  WEBKIT_LOAD_COMMITTED)
    {
        webKitCtrl->m_busy = true;
        wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
                             webKitCtrl->GetId(),
                             url, target);

        if (webKitCtrl && webKitCtrl->GetEventHandler())
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
    }
}
示例#14
0
bool BackForwardItem::invoke() const
{
    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
    if (m_howFar == 1)
        webkit_web_view_go_forward(webView);
    else if (m_howFar == -1)
        webkit_web_view_go_back(webView);
    else {
        WebKitWebBackForwardList* webBackForwardList = webkit_web_view_get_back_forward_list(webView);
        WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(webBackForwardList, m_howFar);
        webkit_web_view_go_to_back_forward_item(webView, item);
    }
    return true;
}
示例#15
0
void LayoutTestController::clearBackForwardList()
{
    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
    WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView);
    WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_current_item(list);
    g_object_ref(item);

    // We clear the history by setting the back/forward list's capacity to 0
    // then restoring it back and adding back the current item.
    gint limit = webkit_web_back_forward_list_get_limit(list);
    webkit_web_back_forward_list_set_limit(list, 0);
    webkit_web_back_forward_list_set_limit(list, limit);
    webkit_web_back_forward_list_add_item(list, item);
    webkit_web_back_forward_list_go_to_item(list, item);
    g_object_unref(item);
}
示例#16
0
void WebViewTest::goForward()
{
    bool canGoForward = webkit_web_view_can_go_forward(m_webView);
    if (canGoForward) {
        WebKitBackForwardList* list = webkit_web_view_get_back_forward_list(m_webView);
        WebKitBackForwardListItem* item = webkit_back_forward_list_get_nth_item(list, 1);
        m_activeURI = webkit_back_forward_list_item_get_original_uri(item);
    }

    // Call go_forward even when can_go_forward returns FALSE to check nothing happens.
    webkit_web_view_go_forward(m_webView);
    if (canGoForward) {
        g_assert(webkit_web_view_is_loading(m_webView));
        g_assert_cmpstr(webkit_web_view_get_uri(m_webView), ==, m_activeURI.data());
    }
}
static void test_webkit_web_back_forward_list_clear(void)
{
    WebKitWebView* webView;
    WebKitWebBackForwardList* webBackForwardList;
    WebKitWebHistoryItem* addItem;
    g_test_bug("36173");

    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(webView);

    webBackForwardList = webkit_web_view_get_back_forward_list(webView);
    g_assert(webBackForwardList);

    // Check that there is no item.
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 0);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 0);
    g_assert(!webkit_web_back_forward_list_get_current_item(webBackForwardList));
    g_assert(!webkit_web_view_can_go_forward(webView));
    g_assert(!webkit_web_view_can_go_back(webView));

    // Check that clearing the empty list does not modify counters
    webkit_web_back_forward_list_clear(webBackForwardList);
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 0);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 0);
    g_assert(!webkit_web_back_forward_list_get_current_item(webBackForwardList));
    g_assert(!webkit_web_view_can_go_forward(webView));
    g_assert(!webkit_web_view_can_go_back(webView));

    // Add a new item
    addItem = webkit_web_history_item_new_with_data("http://example.com/", "Added site");
    webkit_web_back_forward_list_add_item(webBackForwardList, addItem);
    g_object_unref(addItem);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, addItem));

    // Check that after clearing the list the added item is no longer in the list
    webkit_web_back_forward_list_clear(webBackForwardList);
    g_assert(!webkit_web_back_forward_list_contains_item(webBackForwardList, addItem));

    // Check that after clearing it, the list is empty
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 0);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 0);
    g_assert(!webkit_web_back_forward_list_get_current_item(webBackForwardList));
    g_assert(!webkit_web_view_can_go_forward(webView));
    g_assert(!webkit_web_view_can_go_back(webView));

    g_object_unref(webView);
}
示例#18
0
文件: session.c 项目: adnandzebic/dwb
/* session_save(const char *) {{{*/
gboolean  
session_save(const char *name, int flags) 
{
    if (!name) 
    {
        if (s_session_name) 
            name = s_session_name;
        else if (flags & SESSION_FORCE) 
            name = "default";
    }
    if (!s_has_marked && (flags & SESSION_FORCE) == 0) 
        return false;
    GString *buffer = g_string_new(NULL);

    for (GList *l = g_list_first(dwb.state.views); l; l=l->next) 
    {
        WebKitWebView *web = WEBVIEW(l);
        WebKitWebBackForwardList *bf_list = webkit_web_view_get_back_forward_list(web);
        if (VIEW(l)->status->deferred) 
        {
            g_string_append_printf(buffer, "0|%d %s unknown\n", VIEW(l)->status->lockprotect, VIEW(l)->status->deferred_uri);
            continue;
        }
        for (int i= -webkit_web_back_forward_list_get_back_length(bf_list); i<=webkit_web_back_forward_list_get_forward_length(bf_list); i++) 
        {
            WebKitWebHistoryItem *item = webkit_web_back_forward_list_get_nth_item(bf_list, i);
            if (item) 
            {
                g_string_append_printf(buffer, "%d", i);
                if (i == 0) 
                    g_string_append_printf(buffer, "|%d", VIEW(l)->status->lockprotect);

                g_string_append_printf(buffer, " %s %s\n", 
                        webkit_web_history_item_get_uri(item), webkit_web_history_item_get_title(item));
            }
        }
    }
    session_save_file(name, buffer->str, (flags & SESSION_SYNC) != 0);

    if (! (flags & SESSION_SYNC))
        g_free(s_session_name);

    g_string_free(buffer, true);
    return true;
}/*}}}*/
示例#19
0
文件: session.c 项目: adnandzebic/dwb
/* session_load_webview(WebKitWebView *, char *, int *){{{*/
static void
session_load_webview(GList *gl, char *uri, int last, int lock_status) \
{
    if (last > 0) 
        webkit_web_view_go_back_or_forward(WEBVIEW(gl), -last);
    else 
    {
        WebKitWebBackForwardList *bf_list = webkit_web_view_get_back_forward_list(WEBVIEW(gl));
        webkit_web_view_go_to_back_forward_item(WEBVIEW(gl), webkit_web_back_forward_list_get_nth_item(bf_list, 0));
    }
    if (lock_status > 0) 
    {
        SessionTab *tab = dwb_malloc(sizeof(SessionTab));
        tab->gl = gl;
        tab->lock = lock_status;
        g_signal_connect(WEBVIEW(gl), "notify::load-status", G_CALLBACK(session_load_status_callback), tab);
    }
}/*}}}*/
示例#20
0
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
    WebKitBackForwardList* history =
        webkit_web_view_get_back_forward_list(m_web_view);
    GList* list = webkit_back_forward_list_get_forward_list_with_limit(history,
                                                                       m_historyLimit);
    for(guint i = 0; i < g_list_length(list); i++)
    {
        WebKitBackForwardListItem* gtkitem = (WebKitBackForwardListItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                              webkit_back_forward_list_item_get_uri(gtkitem),
                              webkit_back_forward_list_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        forwardhist.push_back(item);
    }
    return forwardhist;
}
示例#21
0
static void cbShowTab( GtkWidget *widget,TabInfo* tabinfo){
    //1.hide the current overlay
    gtk_widget_hide(GTK_WIDGET(tabinfo->window->webView));
    gtk_widget_hide(GTK_WIDGET(tabinfo->window->overlay));
    //2.show the tabid overlay
    TabView tv=tabinfo->window->tabmng->getTabView(tabinfo->window->tabmng,tabinfo->tabid);
    gtk_widget_show(GTK_WIDGET(tv.viewOverlay));
    gtk_widget_show(GTK_WIDGET(tv.webView));
    g_print("showtab id=%d overlay=%p view=%p\n",tabinfo->tabid,tv.viewOverlay,tv.webView);
    //3.reset the current webview and overlay
    tabinfo->window->webView=tv.webView;
    tabinfo->window->overlay=tv.viewOverlay;
    //3.re-bind the back-forword item\address\title ,see browserWindowConstructed
    webViewTitleChanged(tabinfo->window->webView,0,tabinfo->window);
    webViewURIChanged(tabinfo->window->webView,0,tabinfo->window);
    WebKitBackForwardList *backForwadlist = webkit_web_view_get_back_forward_list(tabinfo->window->webView);
    backForwadlistChanged(backForwadlist,0,0,tabinfo->window);
//    faviconChanged(0, 0, tabinfo->window);
}
示例#22
0
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
    WebKitBackForwardList* history =
        webkit_web_view_get_back_forward_list(m_web_view);
    GList* list = webkit_back_forward_list_get_back_list_with_limit(history,
                                                                    m_historyLimit);
    //We need to iterate in reverse to get the order we desire
    for(int i = g_list_length(list) - 1; i >= 0 ; i--)
    {
        WebKitBackForwardListItem* gtkitem = (WebKitBackForwardListItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                              webkit_back_forward_list_item_get_uri(gtkitem),
                              webkit_back_forward_list_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        backhist.push_back(item);
    }
    return backhist;
}
示例#23
0
static void
update_actions (void)
{
  GtkAction                *action;
  WebKitWebBackForwardList *back_forward_list;
  WebKitWebFrame           *frame;

  back_forward_list =
    webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));

  /*  update the back button and its menu  */

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/back");
  gtk_action_set_sensitive (action,
                            webkit_web_view_can_go_back (WEBKIT_WEB_VIEW (view)));

  if (back_forward_list)
    {
      const GList *list;

      list = webkit_web_back_forward_list_get_back_list_with_limit (back_forward_list,
                                                                    12);
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_prev),
                                     build_menu (list, TRUE));
    }
  else
    {
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_prev), NULL);
    }

  /*  update the forward button and its menu  */

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/forward");
  gtk_action_set_sensitive (action,
                            webkit_web_view_can_go_forward (WEBKIT_WEB_VIEW (view)));

  if (back_forward_list)
    {
      const GList *list;

      list = webkit_web_back_forward_list_get_forward_list_with_limit (back_forward_list,
                                                                       12);
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_next),
                                     build_menu (list, FALSE));
    }
  else
    {
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_next), NULL);
    }

  /*  update the copy-location action  */
  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/copy-location");

  frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view));
  gtk_action_set_sensitive (action, webkit_web_frame_get_uri (frame) != NULL);

  /*  update the show-index action  */
  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/show-index");
  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
                                gtk_widget_get_visible (sidebar));
}
bool wxWebViewWebKit::Create(wxWindow *parent,
                      wxWindowID id,
                      const wxString &url,
                      const wxPoint& pos,
                      const wxSize& size,
                      long style,
                      const wxString& name)
{
    m_busy = false;
    m_guard = false;
    m_creating = false;
    FindClear();

    // We currently unconditionally impose scrolling in both directions as it's
    // necessary to show arbitrary pages.
    style |= wxHSCROLL | wxVSCROLL;

    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxWebViewWebKit creation failed") );
        return false;
    }

    m_web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
    GTKCreateScrolledWindowWith(GTK_WIDGET(m_web_view));
    g_object_ref(m_widget);

    g_signal_connect_after(m_web_view, "navigation-policy-decision-requested",
                           G_CALLBACK(wxgtk_webview_webkit_navigation),
                           this);
    g_signal_connect_after(m_web_view, "load-error",
                           G_CALLBACK(wxgtk_webview_webkit_error),
                           this);

    g_signal_connect_after(m_web_view, "new-window-policy-decision-requested",
                           G_CALLBACK(wxgtk_webview_webkit_new_window), this);

    g_signal_connect_after(m_web_view, "title-changed",
                           G_CALLBACK(wxgtk_webview_webkit_title_changed), this);

    g_signal_connect_after(m_web_view, "resource-request-starting",
                           G_CALLBACK(wxgtk_webview_webkit_resource_req), this);
      
#if WEBKIT_CHECK_VERSION(1, 10, 0)    
     g_signal_connect_after(m_web_view, "context-menu",
                           G_CALLBACK(wxgtk_webview_webkit_context_menu), this);
#endif
     
     g_signal_connect_after(m_web_view, "create-web-view",
                           G_CALLBACK(wxgtk_webview_webkit_create_webview), this);

    m_parent->DoAddChild( this );

    PostCreation(size);

    /* Open a webpage */
    webkit_web_view_load_uri(m_web_view, url.utf8_str());

    //Get the initial history limit so we can enable and disable it later
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    m_historyLimit = webkit_web_back_forward_list_get_limit(history);

    // last to avoid getting signal too early
    g_signal_connect_after(m_web_view, "notify::load-status",
                           G_CALLBACK(wxgtk_webview_webkit_load_status),
                           this);

    return true;
}
示例#25
0
void
ephy_session_undo_close_tab (EphySession *session)
{
	EphySessionPrivate *priv;
	EphyEmbed *embed, *new_tab;
	ClosedTab *tab;
#ifndef HAVE_WEBKIT2
	WebKitWebBackForwardList *dest;
	GList *i;
#endif
	EphyNewTabFlags flags = EPHY_NEW_TAB_OPEN_PAGE
		| EPHY_NEW_TAB_PRESENT_WINDOW
		| EPHY_NEW_TAB_JUMP
		| EPHY_NEW_TAB_DONT_COPY_HISTORY;

	g_return_if_fail (EPHY_IS_SESSION (session));

	priv = session->priv;

	tab = g_queue_pop_head (priv->closed_tabs);
	if (tab == NULL)
		return;

	LOG ("UNDO CLOSE TAB: %s", tab->url);
	if (*tab->parent_location != NULL)
	{
		GtkWidget *window;

		flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW;

		if (tab->position > 0)
		{
			/* Append in the n-th position. */
			embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (*tab->parent_location),
								       tab->position - 1));
			flags |= EPHY_NEW_TAB_APPEND_AFTER;
		}
		else
		{
			/* Just prepend in the first position. */
			embed = NULL;
			flags |= EPHY_NEW_TAB_FIRST;
		}

		window = gtk_widget_get_toplevel (GTK_WIDGET (*tab->parent_location));
		new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
					      EPHY_WINDOW (window), embed, tab->url,
					      flags);
		post_restore_cleanup (priv->closed_tabs, tab, FALSE);
	}
	else
	{
		EphyNotebook *notebook;
		flags |=  EPHY_NEW_TAB_IN_NEW_WINDOW;
		new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
					      NULL, NULL, tab->url, flags);

		/* FIXME: This makes the assumption that the notebook
		   is the parent of the returned EphyEmbed. */
		notebook = EPHY_NOTEBOOK (gtk_widget_get_parent (GTK_WIDGET (new_tab)));
		*tab->parent_location = notebook;
		post_restore_cleanup (priv->closed_tabs, tab, TRUE);
	}

	/* This is deficient: we need to recreate the whole
	 * BackForward list. Also, WebKit2 doesn't have this API. */
#ifndef HAVE_WEBKIT2
	dest = webkit_web_view_get_back_forward_list (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_tab));
	for (i = tab->bflist; i; i = i->next)
	{
		LOG ("ADDING TO BF: %s",
		     webkit_web_history_item_get_title ((WebKitWebHistoryItem*) i->data));
		webkit_web_back_forward_list_add_item (dest,
						       webkit_web_history_item_copy ((WebKitWebHistoryItem*) i->data));
	}
#endif
	closed_tab_free (tab);

	if (g_queue_is_empty (priv->closed_tabs))
		g_object_notify (G_OBJECT (session), "can-undo-tab-closed");
}
static void test_webkit_web_back_forward_list_order(void)
{
    WebKitWebView* webView;
    WebKitWebBackForwardList* webBackForwardList;
    WebKitWebHistoryItem* item1;
    WebKitWebHistoryItem* item2;
    WebKitWebHistoryItem* item3;
    WebKitWebHistoryItem* item4;
    WebKitWebHistoryItem* currentItem;
    GList* backList = NULL;
    GList* forwardList = NULL;
    g_test_bug("22694");

    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(webView);

    webkit_web_view_set_maintains_back_forward_list(webView, TRUE);
    webBackForwardList = webkit_web_view_get_back_forward_list(webView);
    g_assert(webBackForwardList);

    // Check that there is no item.
    g_assert(!webkit_web_back_forward_list_get_current_item(webBackForwardList));
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 0);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 0);
    g_assert(!webkit_web_view_can_go_forward(webView));
    g_assert(!webkit_web_view_can_go_back(webView));

    // Add a new items
    item1 = webkit_web_history_item_new_with_data("http://example.com/1/", "Site 1");
    webkit_web_back_forward_list_add_item(webBackForwardList, item1);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item1));

    item2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Site 2");
    webkit_web_back_forward_list_add_item(webBackForwardList, item2);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item2));

    item3 = webkit_web_history_item_new_with_data("http://example.com/3/", "Site 3");
    webkit_web_back_forward_list_add_item(webBackForwardList, item3);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item3));

    item4 = webkit_web_history_item_new_with_data("http://example.com/4/", "Site 4");
    webkit_web_back_forward_list_add_item(webBackForwardList, item4);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item4));

    // check the back list order
    backList = webkit_web_back_forward_list_get_back_list_with_limit(webBackForwardList, 5);
    g_assert(backList);

    currentItem = WEBKIT_WEB_HISTORY_ITEM(backList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/3/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 3");
    backList = backList->next;

    currentItem = WEBKIT_WEB_HISTORY_ITEM(backList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/2/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 2");
    backList = backList->next;

    currentItem = WEBKIT_WEB_HISTORY_ITEM(backList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/1/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 1");
    g_list_free(backList);

    // check the forward list order
    g_assert(webkit_web_view_go_to_back_forward_item(webView, item1));
    forwardList = webkit_web_back_forward_list_get_forward_list_with_limit(webBackForwardList,5);
    g_assert(forwardList);

    currentItem = WEBKIT_WEB_HISTORY_ITEM(forwardList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/4/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 4");
    forwardList = forwardList->next;

    currentItem = WEBKIT_WEB_HISTORY_ITEM(forwardList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/3/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 3");
    forwardList = forwardList->next;

    currentItem = WEBKIT_WEB_HISTORY_ITEM(forwardList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/2/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 2");

    g_list_free(forwardList);
    g_object_unref(webView);
}
static void test_webkit_web_back_forward_list_add_item(void)
{
    WebKitWebView* webView;
    WebKitWebBackForwardList* webBackForwardList;
    WebKitWebHistoryItem* addItem1;
    WebKitWebHistoryItem* addItem2;
    WebKitWebHistoryItem* backItem;
    WebKitWebHistoryItem* currentItem;
    g_test_bug("22988");

    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(webView);

    webkit_web_view_set_maintains_back_forward_list(webView, TRUE);
    webBackForwardList = webkit_web_view_get_back_forward_list(webView);
    g_assert(webBackForwardList);

    // Check that there is no item.
    g_assert(!webkit_web_back_forward_list_get_current_item(webBackForwardList));
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 0);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 0);
    g_assert(!webkit_web_view_can_go_forward(webView));
    g_assert(!webkit_web_view_can_go_back(webView));

    // Add a new item
    addItem1 = webkit_web_history_item_new_with_data("http://example.com/", "Added site");
    webkit_web_back_forward_list_add_item(webBackForwardList, addItem1);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, addItem1));

    // Check that the added item is the current item.
    currentItem = webkit_web_back_forward_list_get_current_item(webBackForwardList);
    g_assert(currentItem);
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 0);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 0);
    g_assert(!webkit_web_view_can_go_forward(webView));
    g_assert(!webkit_web_view_can_go_back(webView));
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Added site");

    // Add another item.
    addItem2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Added site 2");
    webkit_web_back_forward_list_add_item(webBackForwardList, addItem2);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, addItem2));

    // Check that the added item is new current item.
    currentItem = webkit_web_back_forward_list_get_current_item(webBackForwardList);
    g_assert(currentItem);
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 0);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 1);
    g_assert(!webkit_web_view_can_go_forward(webView));
    g_assert(webkit_web_view_can_go_back(webView));
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/2/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Added site 2");

    backItem = webkit_web_back_forward_list_get_back_item(webBackForwardList);
    g_assert(backItem);
    g_assert_cmpstr(webkit_web_history_item_get_uri(backItem), ==, "http://example.com/");
    g_assert_cmpstr(webkit_web_history_item_get_title(backItem), ==, "Added site");

    // Go to the first added item.
    g_assert(webkit_web_view_go_to_back_forward_item(webView, addItem1));
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 1);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 0);
    g_assert(webkit_web_view_can_go_forward(webView));
    g_assert(!webkit_web_view_can_go_back(webView));

    g_object_unref(webView);
}
示例#28
0
void wxWebViewWebKit::ClearHistory()
{
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view));
    webkit_web_back_forward_list_clear(history);
}
示例#29
0
bool wxWebViewWebKit::Create(wxWindow *parent,
                      wxWindowID id,
                      const wxString &url,
                      const wxPoint& pos,
                      const wxSize& size,
                      long style,
                      const wxString& name)
{
    m_ready = false;
    m_busy = false;
    m_guard = false;

    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxWebViewWebKit creation failed") );
        return false;
    }

    GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    web_view = webkit_web_view_new ();
    g_object_ref(web_view); // TODO: check memory management

    m_widget = scrolled_window;
    g_object_ref(m_widget); // TODO: check memory management

    /* Place the WebKitWebView in the GtkScrolledWindow */
    gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
    gtk_widget_show(m_widget);
    gtk_widget_show(web_view);

    g_signal_connect_after(web_view, "notify::load-status",
                           G_CALLBACK(wxgtk_webview_webkit_load_status),
                           this);
    g_signal_connect_after(web_view, "navigation-policy-decision-requested",
                           G_CALLBACK(wxgtk_webview_webkit_navigation),
                           this);
    g_signal_connect_after(web_view, "load-error", 
                           G_CALLBACK(wxgtk_webview_webkit_error),
                           this);

    g_signal_connect_after(web_view, "new-window-policy-decision-requested",
                           G_CALLBACK(wxgtk_webview_webkit_new_window), this);

    g_signal_connect_after(web_view, "title-changed",
                           G_CALLBACK(wxgtk_webview_webkit_title_changed), this);

    g_signal_connect_after(web_view, "resource-request-starting",
                           G_CALLBACK(wxgtk_webview_webkit_resource_req), this);

    m_parent->DoAddChild( this );

    PostCreation(size);

    /* Open a webpage */
    webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), url.utf8_str());

    //Get the initial history limit so we can enable and disable it later
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view));
    m_historyLimit = webkit_web_back_forward_list_get_limit(history);

    m_ready = true;

    return true;
}
static void test_webkit_web_history_item_lifetime(void)
{
    WebKitWebView* webView;
    WebKitWebBackForwardList* backForwardList;
    WebKitWebHistoryItem* currentItem;
    WebKitWebHistoryItem* forwardItem;
    WebKitWebHistoryItem* backItem;
    WebKitWebHistoryItem* nthItem;
    WebKitWebHistoryItem* item1;
    WebKitWebHistoryItem* item2;
    WebKitWebHistoryItem* item3;
    WebKitWebHistoryItem* item4;
    GList* backList = NULL;
    GList* forwardList = NULL;
    g_test_bug("19898");

    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(webView);
    backForwardList = webkit_web_view_get_back_forward_list(webView);
    g_assert_cmpint(G_OBJECT(backForwardList)->ref_count, ==, 1);

    /* add test items */
    item1 = webkit_web_history_item_new_with_data("http://example.com/1/", "Site 1");
    webkit_web_back_forward_list_add_item(backForwardList, item1);

    item2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Site 2");
    webkit_web_back_forward_list_add_item(backForwardList, item2);

    item3 = webkit_web_history_item_new_with_data("http://example.com/3/", "Site 3");
    webkit_web_back_forward_list_add_item(backForwardList, item3);

    item4 = webkit_web_history_item_new_with_data("http://example.com/4/", "Site 4");
    webkit_web_back_forward_list_add_item(backForwardList, item4);

    /* make sure these functions don't add unnecessary ref to the history item */
    backItem = webkit_web_back_forward_list_get_back_item(backForwardList);
    g_object_ref(backItem);
    g_assert_cmpint(G_OBJECT(backItem)->ref_count, ==, 2);
    g_object_unref(backItem);
    g_assert_cmpint(G_OBJECT(backItem)->ref_count, ==, 1);

    currentItem = webkit_web_back_forward_list_get_current_item(backForwardList);
    g_object_ref(currentItem);
    g_assert_cmpint(G_OBJECT(currentItem)->ref_count, ==, 2);
    g_object_unref(currentItem);
    g_assert_cmpint(G_OBJECT(currentItem)->ref_count, ==, 1);

    webkit_web_back_forward_list_go_to_item(backForwardList, item2);
    forwardItem = webkit_web_back_forward_list_get_forward_item(backForwardList);
    g_object_ref(forwardItem);
    g_assert_cmpint(G_OBJECT(forwardItem)->ref_count, ==, 2);
    g_object_unref(forwardItem);
    g_assert_cmpint(G_OBJECT(forwardItem)->ref_count, ==, 1);

    nthItem = webkit_web_back_forward_list_get_nth_item(backForwardList, 1);
    g_object_ref(nthItem);
    g_assert_cmpint(G_OBJECT(nthItem)->ref_count, ==, 2);
    g_object_unref(nthItem);
    g_assert_cmpint(G_OBJECT(nthItem)->ref_count, ==, 1);

    backList = webkit_web_back_forward_list_get_back_list_with_limit(backForwardList, 5);
    for (; backList; backList = backList->next)
        g_assert_cmpint(G_OBJECT(backList->data)->ref_count, ==, 1);

    forwardList = webkit_web_back_forward_list_get_forward_list_with_limit(backForwardList, 5);
    for (; forwardList; forwardList = forwardList->next)
        g_assert_cmpint(G_OBJECT(forwardList->data)->ref_count, ==, 1);

    g_list_free(forwardList);
    g_list_free(backList);
    g_assert_cmpint(G_OBJECT(item1)->ref_count, ==, 1);
    g_assert_cmpint(G_OBJECT(item2)->ref_count, ==, 1);
    g_assert_cmpint(G_OBJECT(item3)->ref_count, ==, 1);
    g_assert_cmpint(G_OBJECT(item4)->ref_count, ==, 1);
    g_assert_cmpint(G_OBJECT(backForwardList)->ref_count, ==, 1);
    g_object_unref(webView);
}