Use a boolean 'special' to identify special pages

We used to load special pages, such as error pages as 'blank'
pages internally and try to identify them indirectly. This
breaks navigating back to and forward to such pages and makes
it difficult to allow stock icons for them.

Now a boolean 'special' is used which is reset on any
navigation attempt and any finished load. It is set only
if a special page is loaded.

This should make icons in error pages work reliably.
This commit is contained in:
Christian Dywan 2010-03-13 16:46:45 +01:00
parent c7ee74610e
commit 25bbea02e2

View file

@ -64,6 +64,7 @@ struct _MidoriView
KatzeScrolled parent_instance; KatzeScrolled parent_instance;
gchar* uri; gchar* uri;
gboolean special;
gchar* title; gchar* title;
gchar* mime_type; gchar* mime_type;
GdkPixbuf* icon; GdkPixbuf* icon;
@ -904,6 +905,9 @@ midori_view_update_load_status (MidoriView* view,
if (view->load_status == load_status) if (view->load_status == load_status)
return; return;
if (load_status == MIDORI_LOAD_FINISHED)
view->special = FALSE;
view->load_status = load_status; view->load_status = load_status;
g_object_notify (G_OBJECT (view), "load-status"); g_object_notify (G_OBJECT (view), "load-status");
@ -931,6 +935,7 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view
} }
} }
/* TODO: Handle more external protocols */ /* TODO: Handle more external protocols */
view->special = FALSE;
return FALSE; return FALSE;
} }
@ -1041,9 +1046,7 @@ midori_view_web_view_resource_request_cb (WebKitWebView* web_view,
const gchar* uri = webkit_network_request_get_uri (request); const gchar* uri = webkit_network_request_get_uri (request);
/* Only apply custom URIs to special pages for security purposes */ /* Only apply custom URIs to special pages for security purposes */
if (view->uri && *view->uri && strncmp (view->uri, "about:", 6) if (!view->special)
&& !webkit_web_data_source_get_unreachable_uri (
webkit_web_frame_get_data_source (web_frame)))
return; return;
if (g_str_has_prefix (uri, "res://")) if (g_str_has_prefix (uri, "res://"))
@ -1143,9 +1146,10 @@ webkit_web_view_load_error_cb (WebKitWebView* web_view,
g_free (message); g_free (message);
g_free (title); g_free (title);
view->special = TRUE;
#if WEBKIT_CHECK_VERSION (1, 1, 14) #if WEBKIT_CHECK_VERSION (1, 1, 14)
webkit_web_frame_load_alternate_string (web_frame, webkit_web_frame_load_alternate_string (web_frame,
result, "about:blank", uri); result, uri, uri);
#else #else
webkit_web_frame_load_alternate_string (web_frame, webkit_web_frame_load_alternate_string (web_frame,
result, res_root, uri); result, res_root, uri);
@ -3372,6 +3376,7 @@ midori_view_set_uri (MidoriView* view,
"{are_you_sure}", _("Are you sure you want to delete this shortcut?"), NULL); "{are_you_sure}", _("Are you sure you want to delete this shortcut?"), NULL);
view->special = TRUE;
#if WEBKIT_CHECK_VERSION (1, 1, 14) #if WEBKIT_CHECK_VERSION (1, 1, 14)
webkit_web_frame_load_alternate_string ( webkit_web_frame_load_alternate_string (
webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)), webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)),