Merge lp:~midori/midori/webKitTwoOnly into lp:midori

Proposed by Cris Dywan
Status: Work in progress
Proposed branch: lp:~midori/midori/webKitTwoOnly
Merge into: lp:midori
Diff against target: 6316 lines (+248/-3830) (has conflicts)
43 files modified
CMakeLists.txt (+19/-54)
data/gtk3.css (+1/-6)
extensions/CMakeLists.txt (+9/-11)
extensions/about.vala (+0/-4)
extensions/adblock/extension.vala (+26/-60)
extensions/adblock/subscriptions.vala (+0/-34)
extensions/addons.c (+3/-3)
extensions/colorful-tabs.c (+0/-5)
extensions/cookie-manager/cookie-manager.c (+2/-8)
extensions/external-download-manager.vala (+0/-12)
extensions/feed-panel/feed-panel.c (+0/-33)
extensions/feed-panel/katze-net.c (+0/-117)
extensions/notes.vala (+0/-5)
extensions/open-with.vala (+0/-28)
extensions/transfers.vala (+0/-22)
katze/katze-item.c (+0/-27)
katze/katze.h (+1/-6)
katze/midori-paths.vala (+6/-27)
katze/midori-uri.vala (+0/-6)
midori/main.c (+3/-15)
midori/midori-browser.c (+0/-402)
midori/midori-browser.h (+0/-4)
midori/midori-contextaction.vala (+0/-2)
midori/midori-download.vala (+0/-191)
midori/midori-frontend.c (+0/-3)
midori/midori-locationaction.c (+26/-40)
midori/midori-preferences.c (+0/-29)
midori/midori-privatedata.c (+0/-39)
midori/midori-searchaction.c (+1/-118)
midori/midori-session.c (+5/-271)
midori/midori-settings.vala (+36/-33)
midori/midori-speeddial.vala (+0/-83)
midori/midori-tab.vala (+5/-46)
midori/midori-view.c (+74/-1650)
midori/midori-websettings.c (+31/-301)
midori/midori-websettings.h (+0/-9)
midori/sokoke.c (+0/-39)
tests/actions.vala (+0/-28)
tests/browser.c (+0/-7)
tests/download.vala (+0/-24)
tests/extensions.c (+0/-4)
tests/properties.c (+0/-5)
tests/tab.vala (+0/-19)
Text conflict in midori/main.c
To merge this branch: bzr merge lp:~midori/midori/webKitTwoOnly
Reviewer Review Type Date Requested Status
Midori Devs Pending
Review via email: mp+285295@code.launchpad.net

Commit message

Drop non-WebKit2 code paths

To post a comment you must log in.
lp:~midori/midori/webKitTwoOnly updated
7102. By gue5t <email address hidden>

support user-stylesheet-uri with wk2 by adding a WebKit.UserContentManager to Midori.Settings

7103. By Cris Dywan

Use WebExtension without the bindings

Revision history for this message
gue5t gue5t (gue5t) wrote :

With these last changes, adblock works, but *only* if I install Midori after building. Running from the uninstalled build directory results in adblock silently not blocking ads.

lp:~midori/midori/webKitTwoOnly updated
7104. By gue5t <email address hidden>

Fix four MidoriView/MidoriTab bugs causing popup window opening to segfault or misbehave

Before these changes, clicking the first green arrow on http://javascript.info/tutorial/popup-windows results in a segfault, instead of the expected popup.

There were four bugs here:

1. The constructor for Midori.Tab was mistakenly setting the nonexistent "related" property instead of the "related-view" property.
2. The signature of webkit_web_view_create_web_view_cb did not match the signature of the "create" signal for a WK2 WebKitWebView, causing a WebKitNavigationAction to be used as a MidoriView.
3. The function called when a popup is ready to be shown was asking for the "width" and "height" properties used by WebKitWindowProperties in WK1 rather than the "geometry" property used in WK2.

(Fixing these three resulted in no more crashes, but popups would be empty instead of loading the expected URIs.)

4. An old (WK1, touched in r5389 and r842, originally in 2009) workaround was unconditionally doing "web_view.load_uri ("")" which cancelled the loading of the intended URI for popups.

After the other fixes, removing this workaround results in everything working as expected.

7105. By Cris Dywan

Merge lp:midori

7106. By Cris Dywan

Use load-failed-with-tls-errors to handle certificate errors

7107. By gue5t <email address hidden>

fix theming issues under GTK+ 3.20

7108. By gue5t <email address hidden>

partially fix LocationAction dropdown under Wayland

Unmerged revisions

7108. By gue5t <email address hidden>

partially fix LocationAction dropdown under Wayland

7107. By gue5t <email address hidden>

fix theming issues under GTK+ 3.20

7106. By Cris Dywan

Use load-failed-with-tls-errors to handle certificate errors

7105. By Cris Dywan

Merge lp:midori

7104. By gue5t <email address hidden>

Fix four MidoriView/MidoriTab bugs causing popup window opening to segfault or misbehave

Before these changes, clicking the first green arrow on http://javascript.info/tutorial/popup-windows results in a segfault, instead of the expected popup.

There were four bugs here:

1. The constructor for Midori.Tab was mistakenly setting the nonexistent "related" property instead of the "related-view" property.
2. The signature of webkit_web_view_create_web_view_cb did not match the signature of the "create" signal for a WK2 WebKitWebView, causing a WebKitNavigationAction to be used as a MidoriView.
3. The function called when a popup is ready to be shown was asking for the "width" and "height" properties used by WebKitWindowProperties in WK1 rather than the "geometry" property used in WK2.

(Fixing these three resulted in no more crashes, but popups would be empty instead of loading the expected URIs.)

4. An old (WK1, touched in r5389 and r842, originally in 2009) workaround was unconditionally doing "web_view.load_uri ("")" which cancelled the loading of the intended URI for popups.

After the other fixes, removing this workaround results in everything working as expected.

7103. By Cris Dywan

Use WebExtension without the bindings

7102. By gue5t <email address hidden>

support user-stylesheet-uri with wk2 by adding a WebKit.UserContentManager to Midori.Settings

7101. By Cris Dywan

Drop non-WebKit2 code paths

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-02-04 19:54:52 +0000
+++ CMakeLists.txt 2016-09-20 20:57:01 +0000
@@ -112,13 +112,13 @@
112 sqlite3>=3.6.19112 sqlite3>=3.6.19
113 gmodule-2.0113 gmodule-2.0
114 gio-2.0>=2.32.3114 gio-2.0>=2.32.3
115 libsoup-gnome-2.4>=2.37.1115 libsoup-2.4>=2.42.0
116 )116 )
117add_definitions("-DHAVE_LIBXML")117add_definitions("-DHAVE_LIBXML")
118add_definitions("-DGIO_VERSION=\"${DEPS_gio-2.0_VERSION}\"")118add_definitions("-DGIO_VERSION=\"${DEPS_gio-2.0_VERSION}\"")
119add_definitions("-DLIBSOUP_VERSION=\"${DEPS_libsoup-gnome-2.4_VERSION}\"")119add_definitions("-DLIBSOUP_VERSION=\"${DEPS_libsoup-2.4_VERSION}\"")
120set(PKGS posix linux libxml-2.0 sqlite3 gmodule-2.0 gio-2.0 libsoup-2.4)120set(PKGS posix linux libxml-2.0 sqlite3 gmodule-2.0 gio-2.0 libsoup-2.4 gtk+-3.0)
121if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.40.0")121if (${DEPS_libsoup-2.4_VERSION} VERSION_GREATER "2.40.0")
122 # valac 0.16 didn't have the bindings yet122 # valac 0.16 didn't have the bindings yet
123 # For consistency we need to ensure C code makes the same assumptions123 # For consistency we need to ensure C code makes the same assumptions
124 if (${VALA_VERSION} VERSION_GREATER "0.17.0")124 if (${VALA_VERSION} VERSION_GREATER "0.17.0")
@@ -126,7 +126,7 @@
126 set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_40_0)126 set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_40_0)
127 endif ()127 endif ()
128endif ()128endif ()
129if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.48.0")129if (${DEPS_libsoup-2.4_VERSION} VERSION_GREATER "2.48.0")
130 add_definitions("-DHAVE_LIBSOUP_2_48_0")130 add_definitions("-DHAVE_LIBSOUP_2_48_0")
131 set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_48_0)131 set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_48_0)
132endif ()132endif ()
@@ -142,21 +142,14 @@
142 set(PKGS ${PKGS} libnotify)142 set(PKGS ${PKGS} libnotify)
143endif ()143endif ()
144144
145option(USE_GTK3 "Use GTK+3" OFF)
146option(HALF_BRO_INCOM_WEBKIT2 "Serve as a guniea pig" OFF)
147option(USE_ZEITGEIST "Zeitgeist history integration" ON)145option(USE_ZEITGEIST "Zeitgeist history integration" ON)
148option(USE_GRANITE "Fancy notebook and pop-overs" OFF)146option(USE_GRANITE "Fancy notebook and pop-overs" OFF)
149option(USE_APIDOCS "API documentation" OFF)147option(USE_APIDOCS "API documentation" OFF)
150option(USE_GIR "Generate GObject Introspection bindings" OFF)148option(USE_GIR "Generate GObject Introspection bindings" OFF)
151option(EXTRA_WARNINGS "Additional compiler warnings" OFF)149option(EXTRA_WARNINGS "Additional compiler warnings" OFF)
152150
153# GTK+3 is implied here, whether set or not
154if (USE_GRANITE OR HALF_BRO_INCOM_WEBKIT2)
155 set(USE_GTK3 ON)
156endif ()
157
158if (USE_GRANITE)151if (USE_GRANITE)
159 pkg_check_modules(GRANITE granite>=0.2)152 pkg_check_modules(GRANITE REQUIRED granite>=0.2)
160 set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${GRANITE_INCLUDE_DIRS}")153 set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${GRANITE_INCLUDE_DIRS}")
161 set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${GRANITE_LIBRARIES}")154 set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${GRANITE_LIBRARIES}")
162 add_definitions("-DHAVE_GRANITE")155 add_definitions("-DHAVE_GRANITE")
@@ -178,53 +171,25 @@
178if (WIN32)171if (WIN32)
179 add_definitions("-DGCR_VERSION=\"No\"")172 add_definitions("-DGCR_VERSION=\"No\"")
180else ()173else ()
181 if (USE_GTK3)174 pkg_check_modules(GCR REQUIRED gcr-3>=2.32)
182 pkg_check_modules(GCR REQUIRED gcr-3>=2.32)
183 else ()
184 pkg_check_modules(GCR REQUIRED gcr-base-3>=2.32)
185 endif ()
186 add_definitions("-DGCR_VERSION=\"${GCR_VERSION}\"")175 add_definitions("-DGCR_VERSION=\"${GCR_VERSION}\"")
187 add_definitions("-DHAVE_GCR")176 add_definitions("-DHAVE_GCR")
188 set(OPTS_INCLUDE_DIRS ${OPTS_INCLUDE_DIRS} ${GCR_INCLUDE_DIRS})177 set(OPTS_INCLUDE_DIRS ${OPTS_INCLUDE_DIRS} ${GCR_INCLUDE_DIRS})
189 set(OPTS_LIBRARIES ${OPTS_LIBRARIES} ${GCR_LIBRARIES})178 set(OPTS_LIBRARIES ${OPTS_LIBRARIES} ${GCR_LIBRARIES})
190endif ()179endif ()
191180
192if (HALF_BRO_INCOM_WEBKIT2)181pkg_check_modules(DEPS_GTK REQUIRED
193 pkg_check_modules(DEPS_GTK REQUIRED182 gtk+-3.0>=3.10.0
194 gtk+-3.0>=3.10.0183 webkit2gtk-4.0>=2.3.91
195 webkit2gtk-4.0>=2.3.91184 )
196 )185add_definitions("-DHAVE_WEBKIT2")
197 add_definitions("-DHAVE_WEBKIT2")186add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"")
198 add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"")187add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit2gtk-4.0_VERSION}\"")
199 add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit2gtk-4.0_VERSION}\"")188# set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-web-extension-4.0.vapi")
200 set(PKGS ${PKGS} gtk+-3.0)189set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-4.0.vapi")
201 # set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-web-extension-4.0.vapi")190set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)
202 set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-4.0.vapi")191set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2)
203 set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)192set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2_3_91)
204 set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2)
205 set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2_3_91)
206elseif (USE_GTK3)
207 pkg_check_modules(DEPS_GTK REQUIRED
208 gtk+-3.0>=3.10.0
209 webkitgtk-3.0>=1.8.1
210 javascriptcoregtk-3.0
211 )
212 add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"")
213 add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkitgtk-3.0_VERSION}\"")
214 set(PKGS ${PKGS} gtk+-3.0)
215 set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkitgtk-3.0.vapi")
216 set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)
217else ()
218 pkg_check_modules(DEPS_GTK REQUIRED
219 gtk+-2.0>=2.24.0
220 webkit-1.0>=1.8.1
221 javascriptcoregtk-1.0
222 )
223 add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-2.0_VERSION}\"")
224 add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit-1.0_VERSION}\"")
225 set(PKGS ${PKGS} gtk+-2.0)
226 set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkitgtk-3.0.vapi")
227endif ()
228set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/katze/katze.vapi")193set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/katze/katze.vapi")
229194
230# dh_translations detects this if there's no variable used195# dh_translations detects this if there's no variable used
231196
=== modified file 'data/gtk3.css'
--- data/gtk3.css 2014-01-13 22:55:08 +0000
+++ data/gtk3.css 2016-09-20 20:57:01 +0000
@@ -1,9 +1,4 @@
1.notebook tab .button {1.notebook tab .button {
2 -GtkButton-default-border: 0;
3 -GtkButton-default-outside-border: 0;
4 -GtkButton-inner-border: 0;
5 -GtkWidget-focus-line-width: 0;
6 -GtkWidget-focus-padding: 0;
7 padding: 0;2 padding: 0;
8 border-width: 1px 1px 0 0;3 border-width: 1px 1px 0 0;
9}4}
@@ -23,7 +18,7 @@
23/* Kill grey backround on inactive buttons */18/* Kill grey backround on inactive buttons */
24GtkDrawingArea,19GtkDrawingArea,
25GtkImage,20GtkImage,
26GtkImage:insensitive,21GtkImage:disabled,
27GtkImage:selected {22GtkImage:selected {
28 background-color: @transparent;23 background-color: @transparent;
29}24}
3025
=== modified file 'extensions/CMakeLists.txt'
--- extensions/CMakeLists.txt 2015-04-19 14:06:12 +0000
+++ extensions/CMakeLists.txt 2016-09-20 20:57:01 +0000
@@ -13,17 +13,15 @@
13 "${CMAKE_BINARY_DIR}/midori"13 "${CMAKE_BINARY_DIR}/midori"
14 )14 )
15file(GLOB EXTENSIONS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)15file(GLOB EXTENSIONS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
16if (HALF_BRO_INCOM_WEBKIT2)16list(REMOVE_ITEM EXTENSIONS
17 list(REMOVE_ITEM EXTENSIONS17 "cookie-permissions"
18 "cookie-permissions"18 "addons.c"
19 "addons.c"19 "formhistory"
20 "formhistory"20 "external-download-manager.vala"
21 "external-download-manager.vala"21 "nojs"
22 "nojs"22 "nsplugin-manager.vala"
23 "nsplugin-manager.vala"23 "tabs2one.c"
24 "tabs2one.c"24 )
25 )
26endif ()
2725
28# FIXME: re-enable webmedia extension26# FIXME: re-enable webmedia extension
29# once we have working notifications on win27# once we have working notifications on win
3028
=== modified file 'extensions/about.vala'
--- extensions/about.vala 2015-06-11 22:33:48 +0000
+++ extensions/about.vala 2016-09-20 20:57:01 +0000
@@ -15,11 +15,7 @@
15 public abstract string uri { get; set; }15 public abstract string uri { get; set; }
16 public abstract void get_contents (Midori.View view, string uri);16 public abstract void get_contents (Midori.View view, string uri);
17 protected void load_html (Midori.View view, string content, string uri) {17 protected void load_html (Midori.View view, string content, string uri) {
18 #if HAVE_WEBKIT2
19 view.web_view.load_html (content, uri);18 view.web_view.load_html (content, uri);
20 #else
21 view.web_view.load_html_string (content, uri);
22 #endif
23 }19 }
24 }20 }
2521
2622
=== modified file 'extensions/adblock/extension.vala'
--- extensions/adblock/extension.vala 2016-02-01 19:48:47 +0000
+++ extensions/adblock/extension.vala 2016-09-20 20:57:01 +0000
@@ -55,22 +55,20 @@
55 internal string? js_hider_function_body;55 internal string? js_hider_function_body;
56#endif56#endif
5757
58#if HAVE_WEBKIT258 public Extension.WebExtension (GLib.Object extension) {
59#if !HAVE_WEBKIT2_3_9159 Midori.Paths.init_exec_path ({"/usr/share"});
60 public Extension.WebExtension (WebKit.WebExtension web_extension) {60 extension.connect ("signal::page-created", page_created, null);
61 init ();61 }
62 web_extension.page_created.connect (page_created);62
63 }63 void page_created (GLib.Object page) {
6464 page.connect ("signal::send-request", send_request, page);
65 void page_created (WebKit.WebPage web_page) {65 }
66 web_page.send_request.connect (send_request);66
67 }67 bool send_request (WebKit.URIRequest request, WebKit.URIResponse? redirected_response, GLib.Object page) {
6868 string uri;
69 bool send_request (WebKit.WebPage web_page, WebKit.URIRequest request, WebKit.URIResponse? redirected_response) {69 page.get ("uri", out uri);
70 return request_handled (request.uri, web_page.uri);70 return request_handled (request.uri, uri);
71 }71 }
72#endif
73#endif
7472
75 public Extension () {73 public Extension () {
76 GLib.Object (name: _("Advertisement blocker"),74 GLib.Object (name: _("Advertisement blocker"),
@@ -87,7 +85,6 @@
87 }85 }
8886
89 void extension_activated (Midori.App app) {87 void extension_activated (Midori.App app) {
90#if HAVE_WEBKIT2
91 string cache_dir = Environment.get_user_cache_dir ();88 string cache_dir = Environment.get_user_cache_dir ();
92 string wk2path = Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext");89 string wk2path = Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext");
93 Midori.Paths.mkdir_with_parents (wk2path);90 Midori.Paths.mkdir_with_parents (wk2path);
@@ -101,7 +98,6 @@
101 } catch (Error error) {98 } catch (Error error) {
102 critical ("Failed to create WebKit2 link: %s", error.message);99 critical ("Failed to create WebKit2 link: %s", error.message);
103 }100 }
104#endif
105 init ();101 init ();
106 foreach (var browser in app.get_browsers ())102 foreach (var browser in app.get_browsers ())
107 browser_added (browser);103 browser_added (browser);
@@ -136,17 +132,11 @@
136132
137 void tab_added (Midori.View view) {133 void tab_added (Midori.View view) {
138 view.navigation_requested.connect (navigation_requested);134 view.navigation_requested.connect (navigation_requested);
139#if !HAVE_WEBKIT2
140 view.web_view.resource_request_starting.connect (resource_requested);
141#endif
142 view.notify["load-status"].connect (load_status_changed);135 view.notify["load-status"].connect (load_status_changed);
143 view.context_menu.connect (context_menu);136 view.context_menu.connect (context_menu);
144 }137 }
145138
146 void tab_removed (Midori.View view) {139 void tab_removed (Midori.View view) {
147#if !HAVE_WEBKIT2
148 view.web_view.resource_request_starting.disconnect (resource_requested);
149#endif
150 view.navigation_requested.disconnect (navigation_requested);140 view.navigation_requested.disconnect (navigation_requested);
151 view.notify["load-status"].disconnect (load_status_changed);141 view.notify["load-status"].disconnect (load_status_changed);
152 view.context_menu.disconnect (context_menu);142 view.context_menu.disconnect (context_menu);
@@ -179,23 +169,6 @@
179 menu.add (action);169 menu.add (action);
180 }170 }
181171
182#if !HAVE_WEBKIT2
183 void resource_requested (WebKit.WebView web_view, WebKit.WebFrame frame,
184 WebKit.WebResource resource, WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
185
186 WebKit.WebFrame main_frame = web_view.get_main_frame ();
187
188 WebKit.WebDataSource? ds = main_frame.get_provisional_data_source ();
189 WebKit.NetworkRequest? main_frame_request = (ds != null) ? ds.get_request () : null;
190 string? main_frame_uri = (main_frame_request != null) ? main_frame_request.uri : null;
191
192 bool is_main_frame_request = (frame == main_frame) && (request.uri == main_frame_uri);
193 if (!is_main_frame_request && request_handled (request.uri, web_view.uri)) {
194 request.set_uri ("about:blank");
195 }
196 }
197#endif
198
199 bool navigation_requested (Midori.Tab tab, string uri) {172 bool navigation_requested (Midori.Tab tab, string uri) {
200 if (uri.has_prefix ("abp:")) {173 if (uri.has_prefix ("abp:")) {
201 string parsed_uri = parse_subscription_uri (uri);174 string parsed_uri = parse_subscription_uri (uri);
@@ -346,7 +319,7 @@
346319
347 internal void init () {320 internal void init () {
348 hider_selectors = new StringBuilder ();321 hider_selectors = new StringBuilder ();
349 load_config ();322 config = load_config ();
350 manager = new SubscriptionManager (config);323 manager = new SubscriptionManager (config);
351 status_icon = new StatusIcon (config, manager);324 status_icon = new StatusIcon (config, manager);
352 foreach (unowned Subscription sub in config) {325 foreach (unowned Subscription sub in config) {
@@ -374,29 +347,26 @@
374 hider_selectors = new StringBuilder ();347 hider_selectors = new StringBuilder ();
375 }348 }
376349
377 void load_config () {350 static Config load_config () {
378#if HAVE_WEBKIT2
379 string config_dir = Path.build_filename (GLib.Environment.get_user_config_dir (), PACKAGE_NAME, "extensions", "libadblock." + GLib.Module.SUFFIX);351 string config_dir = Path.build_filename (GLib.Environment.get_user_config_dir (), PACKAGE_NAME, "extensions", "libadblock." + GLib.Module.SUFFIX);
380 Midori.Paths.mkdir_with_parents (config_dir);352 Midori.Paths.mkdir_with_parents (config_dir);
381#else
382 string config_dir = Midori.Paths.get_extension_config_dir ("adblock");
383#endif
384 string presets = Midori.Paths.get_extension_preset_filename ("adblock", "config");353 string presets = Midori.Paths.get_extension_preset_filename ("adblock", "config");
385 string filename = Path.build_filename (config_dir, "config");354 string filename = Path.build_filename (config_dir, "config");
386 config = new Config (filename, presets);355 var config = new Config (filename, presets);
387 string custom_list = GLib.Path.build_filename (config_dir, "custom.list");356 string custom_list = GLib.Path.build_filename (config_dir, "custom.list");
388 try {357 try {
389 custom = new Subscription (Filename.to_uri (custom_list, null));358 var custom = new Subscription (Filename.to_uri (custom_list, null));
390 custom.mutable = false;359 custom.mutable = false;
391 custom.title = _("Custom");360 custom.title = _("Custom");
392 config.add (custom);361 config.add (custom);
393 } catch (Error error) {362 } catch (Error error) {
394 custom = null;
395 warning ("Failed to add custom list %s: %s", custom_list, error.message);363 warning ("Failed to add custom list %s: %s", custom_list, error.message);
396 }364 }
365 return config;
397 }366 }
398367
399 public Adblock.Directive get_directive_for_uri (string request_uri, string page_uri) {368 static Adblock.Directive get_directive_for_uri (string request_uri, string page_uri) {
369 var config = load_config ();
400 if (!config.enabled)370 if (!config.enabled)
401 return Directive.ALLOW;371 return Directive.ALLOW;
402372
@@ -422,11 +392,11 @@
422 if (directive == null)392 if (directive == null)
423 directive = Directive.ALLOW;393 directive = Directive.ALLOW;
424 else if (directive == Directive.BLOCK) {394 else if (directive == Directive.BLOCK) {
425 status_icon.set_state (State.BLOCKED);395 // FIXME: status_icon.set_state (State.BLOCKED);
426#if USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES396#if USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES
427 hider_selectors.append ("img[src*=\"%s\"] , iframe[src*=\"%s\"] , ".printf (request_uri, request_uri));397 // FIXME: hider_selectors.append ("img[src*=\"%s\"] , iframe[src*=\"%s\"] , ".printf (request_uri, request_uri));
428#else398#else
429 hider_selectors.append (" uris.push ('%s');\n".printf (request_uri));399 // FIXME: hider_selectors.append (" uris.push ('%s');\n".printf (request_uri));
430#endif400#endif
431 }401 }
432 return directive;402 return directive;
@@ -482,14 +452,10 @@
482 }452 }
483}453}
484454
485#if HAVE_WEBKIT2
486#if !HAVE_WEBKIT2_3_91
487Adblock.Extension? filter;455Adblock.Extension? filter;
488public static void webkit_web_extension_initialize (WebKit.WebExtension web_extension) {456public static void webkit_web_extension_initialize (GLib.Object extension) {
489 filter = new Adblock.Extension.WebExtension (web_extension);457 filter = new Adblock.Extension.WebExtension (extension);
490}458}
491#endif
492#endif
493459
494public Midori.Extension extension_init () {460public Midori.Extension extension_init () {
495 return new Adblock.Extension ();461 return new Adblock.Extension ();
496462
=== modified file 'extensions/adblock/subscriptions.vala'
--- extensions/adblock/subscriptions.vala 2015-06-12 21:43:40 +0000
+++ extensions/adblock/subscriptions.vala 2016-09-20 20:57:01 +0000
@@ -40,9 +40,6 @@
40 public Options optslist;40 public Options optslist;
41 public Whitelist whitelist;41 public Whitelist whitelist;
42 public Element element;42 public Element element;
43#if !HAVE_WEBKIT2
44 WebKit.Download? download;
45#endif
4643
47 public Subscription (string uri) {44 public Subscription (string uri) {
48 debug_parse = "adblock:parse" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");45 debug_parse = "adblock:parse" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");
@@ -292,20 +289,6 @@
292 }289 }
293 }290 }
294291
295#if !HAVE_WEBKIT2
296 void download_status (ParamSpec pspec) {
297 if (download.get_status () != WebKit.DownloadStatus.FINISHED)
298 return;
299
300 download = null;
301 try {
302 parse ();
303 } catch (Error error) {
304 warning ("Error parsing %s: %s", uri, error.message);
305 }
306 }
307#endif
308
309 public void parse () throws Error292 public void parse () throws Error
310 {293 {
311 if (!active)294 if (!active)
@@ -329,24 +312,7 @@
329 try {312 try {
330 stream = new DataInputStream (filter_file.read ());313 stream = new DataInputStream (filter_file.read ());
331 } catch (IOError.NOT_FOUND exist_error) {314 } catch (IOError.NOT_FOUND exist_error) {
332#if HAVE_WEBKIT2
333 /* TODO */315 /* TODO */
334#else
335 /* Don't bother trying to download local files */
336 if (!uri.has_prefix ("file://")) {
337 if (download != null)
338 return;
339
340 string destination_uri = Filename.to_uri (path, null);
341 debug ("Fetching %s to %s now", uri, destination_uri);
342 download = new WebKit.Download (new WebKit.NetworkRequest (uri));
343 if (!Midori.Download.has_enough_space (download, destination_uri, true))
344 throw new FileError.EXIST ("Can't download to \"%s\"", path);
345 download.destination_uri = destination_uri;
346 download.notify["status"].connect (download_status);
347 download.start ();
348 }
349#endif
350 return;316 return;
351 }317 }
352318
353319
=== modified file 'extensions/addons.c'
--- extensions/addons.c 2015-04-15 22:51:01 +0000
+++ extensions/addons.c 2016-09-20 20:57:01 +0000
@@ -1599,7 +1599,7 @@
1599 MidoriApp* app = midori_extension_get_app (extension);1599 MidoriApp* app = midori_extension_get_app (extension);
1600 MidoriWebSettings* settings = katze_object_get_object (app, "settings");1600 MidoriWebSettings* settings = katze_object_get_object (app, "settings");
1601 gchar* data = addons_generate_global_stylesheet (extension);1601 gchar* data = addons_generate_global_stylesheet (extension);
1602 midori_web_settings_add_style (settings, "addons", data);1602 midori_settings_add_style (MIDORI_SETTINGS (settings), "addons", data);
1603 g_free (data);1603 g_free (data);
1604 g_object_unref (settings);1604 g_object_unref (settings);
1605}1605}
@@ -1738,7 +1738,7 @@
17381738
1739 addons_disable_monitors (extension);1739 addons_disable_monitors (extension);
1740 addons_save_settings (NULL, extension);1740 addons_save_settings (NULL, extension);
1741 midori_web_settings_remove_style (settings, "addons");1741 midori_settings_remove_style (MIDORI_SETTINGS (settings), "addons");
17421742
1743 browsers = katze_object_get_object (app, "browsers");1743 browsers = katze_object_get_object (app, "browsers");
1744 KATZE_ARRAY_FOREACH_ITEM (browser, browsers)1744 KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
@@ -1860,7 +1860,7 @@
1860 addons_update_elements (extension, ADDONS_USER_SCRIPTS);1860 addons_update_elements (extension, ADDONS_USER_SCRIPTS);
1861 addons_monitor_directories (extension, ADDONS_USER_SCRIPTS);1861 addons_monitor_directories (extension, ADDONS_USER_SCRIPTS);
1862 data = addons_generate_global_stylesheet (extension);1862 data = addons_generate_global_stylesheet (extension);
1863 midori_web_settings_add_style (settings, "addons", data);1863 midori_settings_add_style (MIDORI_SETTINGS (settings), "addons", data);
18641864
1865 KATZE_ARRAY_FOREACH_ITEM (browser, browsers)1865 KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
1866 addons_app_add_browser_cb (app, browser, extension);1866 addons_app_add_browser_cb (app, browser, extension);
18671867
=== modified file 'extensions/colorful-tabs.c'
--- extensions/colorful-tabs.c 2016-02-24 21:45:09 +0000
+++ extensions/colorful-tabs.c 2016-09-20 20:57:01 +0000
@@ -244,11 +244,6 @@
244void244void
245extension_test (void)245extension_test (void)
246{246{
247 #ifndef HAVE_WEBKIT2
248 g_object_set_data (G_OBJECT (webkit_get_default_session ()),
249 "midori-session-initialized", (void*)1);
250 #endif
251
252 /* TODO: Add test which uses favicon codepath */247 /* TODO: Add test which uses favicon codepath */
253248
254 g_test_add_func ("/extensions/colorful_tabs/hostname_colour", test_colour_for_hostname);249 g_test_add_func ("/extensions/colorful_tabs/hostname_colour", test_colour_for_hostname);
255250
=== modified file 'extensions/cookie-manager/cookie-manager.c'
--- extensions/cookie-manager/cookie-manager.c 2013-07-29 21:05:02 +0000
+++ extensions/cookie-manager/cookie-manager.c 2016-09-20 20:57:01 +0000
@@ -12,7 +12,7 @@
12#include "config.h"12#include "config.h"
13#include <midori/midori.h>13#include <midori/midori.h>
14#include "katze/katze.h"14#include "katze/katze.h"
15#include <libsoup/soup-cookie-jar-sqlite.h>15#include <libsoup/soup-cookie-jar-db.h>
1616
17#include "cookie-manager.h"17#include "cookie-manager.h"
18#include "cookie-manager-page.h"18#include "cookie-manager-page.h"
@@ -280,15 +280,9 @@
280 COOKIE_MANAGER_COL_NAME, GTK_SORT_ASCENDING);280 COOKIE_MANAGER_COL_NAME, GTK_SORT_ASCENDING);
281281
282 /* setup soup */282 /* setup soup */
283#ifdef HAVE_WEBKIT2
284 gchar *filename = midori_paths_get_config_filename_for_writing ("cookies.db");283 gchar *filename = midori_paths_get_config_filename_for_writing ("cookies.db");
285 priv->jar = soup_cookie_jar_sqlite_new (filename, FALSE);284 priv->jar = soup_cookie_jar_db_new (filename, FALSE);
286 g_free(filename);285 g_free(filename);
287#else
288 SoupSession *session = webkit_get_default_session();
289 priv->jar = SOUP_COOKIE_JAR(soup_session_get_feature(session, soup_cookie_jar_get_type()));
290 g_object_ref(priv->jar);
291#endif
292 g_signal_connect(priv->jar, "changed", G_CALLBACK(cookie_manager_jar_changed_cb), self);286 g_signal_connect(priv->jar, "changed", G_CALLBACK(cookie_manager_jar_changed_cb), self);
293287
294 cookie_manager_refresh_store(self);288 cookie_manager_refresh_store(self);
295289
=== modified file 'extensions/external-download-manager.vala'
--- extensions/external-download-manager.vala 2015-08-20 06:18:50 +0000
+++ extensions/external-download-manager.vala 2016-09-20 20:57:01 +0000
@@ -36,16 +36,8 @@
36 if (download_type == Midori.DownloadType.SAVE) {36 if (download_type == Midori.DownloadType.SAVE) {
37 var dlReq = new DownloadRequest ();37 var dlReq = new DownloadRequest ();
3838
39 #if HAVE_WEBKIT2
40 dlReq.uri = download.request.get_uri ();39 dlReq.uri = download.request.get_uri ();
41 weak Soup.MessageHeaders headers = download.request.get_http_headers ();40 weak Soup.MessageHeaders headers = download.request.get_http_headers ();
42 #else
43 dlReq.uri = download.get_uri ();
44 var request = download.get_network_request ();
45 var message = request.get_message ();
46 weak Soup.MessageHeaders headers = message.request_headers;
47 #endif
48
49 dlReq.auth = headers.get ("Authorization");41 dlReq.auth = headers.get ("Authorization");
50 dlReq.referer = headers.get ("Referer");42 dlReq.referer = headers.get ("Referer");
51 dlReq.cookie_header = this.cookie_jar.get_cookies (new Soup.URI (dlReq.uri), true);43 dlReq.cookie_header = this.cookie_jar.get_cookies (new Soup.URI (dlReq.uri), true);
@@ -101,11 +93,7 @@
101 }93 }
10294
103 construct {95 construct {
104 #if HAVE_WEBKIT2
105 var session= new Session ();96 var session= new Session ();
106 #else
107 var session = WebKit.get_default_session ();
108 #endif
109 this.cookie_jar = session.get_feature (typeof (Soup.CookieJar)) as Soup.CookieJar;97 this.cookie_jar = session.get_feature (typeof (Soup.CookieJar)) as Soup.CookieJar;
110 }98 }
111 }99 }
112100
=== modified file 'extensions/feed-panel/feed-panel.c'
--- extensions/feed-panel/feed-panel.c 2013-10-25 21:49:56 +0000
+++ extensions/feed-panel/feed-panel.c 2016-09-20 20:57:01 +0000
@@ -589,31 +589,6 @@
589 return MIDORI_EVENT_CONTEXT_MENU (event);589 return MIDORI_EVENT_CONTEXT_MENU (event);
590}590}
591591
592#ifndef HAVE_WEBKIT2
593static gboolean
594webview_navigation_request_cb (WebKitWebView* web_view,
595 WebKitWebFrame* frame,
596 WebKitNetworkRequest* request,
597 WebKitWebNavigationAction* navigation_action,
598 WebKitWebPolicyDecision* policy_decision,
599 FeedPanel* panel)
600{
601 if (webkit_web_navigation_action_get_reason (navigation_action) ==
602 WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED)
603 {
604 MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
605 const gchar* uri = webkit_network_request_get_uri (request);
606 GtkWidget* view = midori_browser_add_uri (browser, uri);
607 midori_browser_set_current_tab (browser, view);
608 webkit_web_policy_decision_ignore (policy_decision);
609
610 return TRUE;
611 }
612
613 return FALSE;
614}
615#endif
616
617static const gchar*592static const gchar*
618feed_panel_get_label (MidoriViewable* viewable)593feed_panel_get_label (MidoriViewable* viewable)
619{594{
@@ -800,12 +775,8 @@
800 NULL);775 NULL);
801 gtk_widget_show (treeview);776 gtk_widget_show (treeview);
802777
803#if GTK_CHECK_VERSION(3,0,0)
804 font_desc = (PangoFontDescription*)gtk_style_context_get_font (778 font_desc = (PangoFontDescription*)gtk_style_context_get_font (
805 gtk_widget_get_style_context (treeview), GTK_STATE_FLAG_NORMAL);779 gtk_widget_get_style_context (treeview), GTK_STATE_FLAG_NORMAL);
806#else
807 font_desc = treeview->style->font_desc;
808#endif
809 family = pango_font_description_get_family (font_desc);780 family = pango_font_description_get_family (font_desc);
810 size = pango_font_description_get_size (font_desc) / PANGO_SCALE;781 size = pango_font_description_get_size (font_desc) / PANGO_SCALE;
811 settings = midori_web_settings_new ();782 settings = midori_web_settings_new ();
@@ -814,10 +785,6 @@
814 webview = midori_view_new_with_item (NULL, settings);785 webview = midori_view_new_with_item (NULL, settings);
815 gtk_widget_set_size_request (webview, -1, 50);786 gtk_widget_set_size_request (webview, -1, 50);
816 g_object_connect (midori_tab_get_web_view (MIDORI_TAB (webview)),787 g_object_connect (midori_tab_get_web_view (MIDORI_TAB (webview)),
817 #ifndef HAVE_WEBKIT2
818 "signal::navigation-policy-decision-requested",
819 webview_navigation_request_cb, panel,
820 #endif
821 "signal::button-press-event",788 "signal::button-press-event",
822 webview_button_press_event_cb, NULL,789 webview_button_press_event_cb, NULL,
823 "signal::button-release-event",790 "signal::button-release-event",
824791
=== modified file 'extensions/feed-panel/katze-net.c'
--- extensions/feed-panel/katze-net.c 2013-08-02 17:42:29 +0000
+++ extensions/feed-panel/katze-net.c 2016-09-20 20:57:01 +0000
@@ -66,85 +66,6 @@
66 KatzeNetRequest* request;66 KatzeNetRequest* request;
67} KatzeNetPriv;67} KatzeNetPriv;
6868
69#ifndef HAVE_WEBKIT2
70static void
71katze_net_priv_free (KatzeNetPriv* priv)
72{
73 KatzeNetRequest* request = priv->request;
74 g_free (request->uri);
75 g_free (request->mime_type);
76 g_free (request->data);
77 g_slice_free (KatzeNetRequest, request);
78 g_slice_free (KatzeNetPriv, priv);
79}
80
81static void
82katze_net_got_body_cb (SoupMessage* msg,
83 KatzeNetPriv* priv);
84
85static void
86katze_net_got_headers_cb (SoupMessage* msg,
87 KatzeNetPriv* priv)
88{
89 KatzeNetRequest* request = priv->request;
90
91 switch (msg->status_code)
92 {
93 case 200:
94 request->status = KATZE_NET_VERIFIED;
95 break;
96 case 301:
97 request->status = KATZE_NET_MOVED;
98 break;
99 default:
100 request->status = KATZE_NET_NOT_FOUND;
101 }
102
103 if (!priv->status_cb (request, priv->user_data))
104 {
105 g_signal_handlers_disconnect_by_func (msg, katze_net_got_headers_cb, priv);
106 g_signal_handlers_disconnect_by_func (msg, katze_net_got_body_cb, priv);
107 soup_session_cancel_message (webkit_get_default_session (), msg, 1);
108 }
109}
110
111static void
112katze_net_got_body_cb (SoupMessage* msg,
113 KatzeNetPriv* priv)
114{
115 KatzeNetRequest* request = priv->request;
116
117 if (msg->response_body->length > 0)
118 {
119 request->data = g_memdup (msg->response_body->data,
120 msg->response_body->length);
121 request->length = msg->response_body->length;
122 }
123
124 priv->transfer_cb (request, priv->user_data);
125}
126
127static void
128katze_net_finished_cb (SoupMessage* msg,
129 KatzeNetPriv* priv)
130{
131 katze_net_priv_free (priv);
132}
133
134static gboolean
135katze_net_default_cb (KatzeNetPriv* priv)
136{
137 KatzeNetRequest* request;
138
139 request = priv->request;
140 request->status = KATZE_NET_NOT_FOUND;
141 if (priv->status_cb)
142 priv->status_cb (request, priv->user_data);
143 katze_net_priv_free (priv);
144 return FALSE;
145}
146#endif
147
148/**69/**
149 * katze_net_load_uri:70 * katze_net_load_uri:
150 * @net: a #KatzeNet, or %NULL71 * @net: a #KatzeNet, or %NULL
@@ -172,43 +93,5 @@
172 KatzeNetTransferCb transfer_cb,93 KatzeNetTransferCb transfer_cb,
173 gpointer user_data)94 gpointer user_data)
174{95{
175#ifndef HAVE_WEBKIT2
176 KatzeNetRequest* request;
177 KatzeNetPriv* priv;
178 SoupMessage* msg;
179
180 g_return_if_fail (uri != NULL);
181
182 if (!status_cb && !transfer_cb)
183 return;
184
185 request = g_slice_new (KatzeNetRequest);
186 request->uri = g_strdup (uri);
187 request->mime_type = NULL;
188 request->data = NULL;
189
190 priv = g_slice_new (KatzeNetPriv);
191 priv->status_cb = status_cb;
192 priv->transfer_cb = transfer_cb;
193 priv->user_data = user_data;
194 priv->request = request;
195
196 if (midori_uri_is_http (uri))
197 {
198 msg = soup_message_new ("GET", uri);
199 if (status_cb)
200 g_signal_connect (msg, "got-headers",
201 G_CALLBACK (katze_net_got_headers_cb), priv);
202 if (transfer_cb)
203 g_signal_connect (msg, "got-body",
204 G_CALLBACK (katze_net_got_body_cb), priv);
205 g_signal_connect (msg, "finished",
206 G_CALLBACK (katze_net_finished_cb), priv);
207 soup_session_queue_message (webkit_get_default_session (), msg, NULL, NULL);
208 return;
209 }
210
211 g_idle_add ((GSourceFunc)katze_net_default_cb, priv);
212#endif
213}96}
21497
21598
=== modified file 'extensions/notes.vala'
--- extensions/notes.vala 2015-03-18 21:18:11 +0000
+++ extensions/notes.vala 2016-09-20 20:57:01 +0000
@@ -385,11 +385,6 @@
385 }385 }
386386
387 void add_menu_items (Midori.Tab tab, WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) {387 void add_menu_items (Midori.Tab tab, WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) {
388#if !HAVE_WEBKIT2
389 if ((hit_test_result.context & WebKit.HitTestResultContext.SELECTION) == 0)
390 return;
391#endif
392
393 var view = tab as Midori.View;388 var view = tab as Midori.View;
394 var action = new Gtk.Action ("Notes", _("Copy selection as note"), null, null);389 var action = new Gtk.Action ("Notes", _("Copy selection as note"), null, null);
395 action.activate.connect ((action)=> {390 action.activate.connect ((action)=> {
396391
=== modified file 'extensions/open-with.vala'
--- extensions/open-with.vala 2016-02-17 20:26:51 +0000
+++ extensions/open-with.vala 2016-09-20 20:57:01 +0000
@@ -663,33 +663,7 @@
663663
664 /* Returns %TRUE if the attempt to download and open failed immediately, %FALSE otherwise */664 /* Returns %TRUE if the attempt to download and open failed immediately, %FALSE otherwise */
665 bool open_with_type (string uri, string content_type, Gtk.Widget widget, NextStep next_step) {665 bool open_with_type (string uri, string content_type, Gtk.Widget widget, NextStep next_step) {
666 #if HAVE_WEBKIT2
667 return open_now (uri, content_type, widget, next_step);666 return open_now (uri, content_type, widget, next_step);
668 #else
669 if (!Midori.URI.is_http (uri))
670 return open_now (uri, content_type, widget, next_step);
671 /* Don't download websites */
672 if (content_type == "application/octet-stream")
673 return open_now (uri, content_type, widget, next_step);
674
675 var download = new WebKit.Download (new WebKit.NetworkRequest (uri));
676 download.destination_uri = Midori.Download.prepare_destination_uri (download, null);
677 if (!Midori.Download.has_enough_space (download, download.destination_uri))
678 return false;
679
680 download.notify["status"].connect ((pspec) => {
681 if (download.status == WebKit.DownloadStatus.FINISHED) {
682 open_now (download.destination_uri, content_type, widget, next_step);
683 }
684 else if (download.status == WebKit.DownloadStatus.ERROR)
685 Midori.show_message_dialog (Gtk.MessageType.ERROR,
686 _("Download error"),
687 _("Cannot open '%s' because the download failed."
688 ).printf (download.destination_uri), false);
689 });
690 download.start ();
691 return true;
692 #endif
693 }667 }
694668
695 /* If @next_step is %NextStep.TRY_OPEN, tries to pick a handler automatically.669 /* If @next_step is %NextStep.TRY_OPEN, tries to pick a handler automatically.
@@ -730,7 +704,6 @@
730 });704 });
731 menu.add (action);705 menu.add (action);
732 }706 }
733#if !HAVE_WEBKIT2
734 if ((hit_test_result.context & WebKit.HitTestResultContext.IMAGE) != 0) {707 if ((hit_test_result.context & WebKit.HitTestResultContext.IMAGE) != 0) {
735 string uri = hit_test_result.image_uri;708 string uri = hit_test_result.image_uri;
736 var action = new Gtk.Action ("OpenImageInViewer", _("Open in Image _Viewer"), null, null);709 var action = new Gtk.Action ("OpenImageInViewer", _("Open in Image _Viewer"), null, null);
@@ -739,7 +712,6 @@
739 });712 });
740 menu.add (action);713 menu.add (action);
741 }714 }
742#endif
743 }715 }
744716
745 void show_preferences (Katze.Preferences preferences) {717 void show_preferences (Katze.Preferences preferences) {
746718
=== modified file 'extensions/transfers.vala'
--- extensions/transfers.vala 2016-04-02 08:15:11 +0000
+++ extensions/transfers.vala 2016-09-20 20:57:01 +0000
@@ -36,23 +36,11 @@
36 internal double progress { get {36 internal double progress { get {
37 return Midori.Download.get_progress (download);37 return Midori.Download.get_progress (download);
38 } }38 } }
39#if HAVE_WEBKIT2
40 public bool succeeded { get; protected set; default = false; }39 public bool succeeded { get; protected set; default = false; }
41 public bool finished { get; protected set; default = false; }40 public bool finished { get; protected set; default = false; }
42 internal string destination { get {41 internal string destination { get {
43 return download.destination;42 return download.destination;
44 } }43 } }
45#else
46 internal bool succeeded { get {
47 return download.status == WebKit.DownloadStatus.FINISHED;
48 } }
49 internal bool finished { get {
50 return Midori.Download.is_finished (download);
51 } }
52 internal string destination { get {
53 return download.destination_uri;
54 } }
55#endif
5644
57 internal Transfer (WebKit.Download download) {45 internal Transfer (WebKit.Download download) {
58 poll_source = Timeout.add(1000/10, () => {46 poll_source = Timeout.add(1000/10, () => {
@@ -60,7 +48,6 @@
60 return true;48 return true;
61 });49 });
62 this.download = download;50 this.download = download;
63 #if HAVE_WEBKIT2
64 download.finished.connect (() => {51 download.finished.connect (() => {
65 succeeded = finished = true;52 succeeded = finished = true;
66 changed ();53 changed ();
@@ -74,15 +61,6 @@
74 Source.remove (poll_source);61 Source.remove (poll_source);
75 poll_source = 0;62 poll_source = 0;
76 });63 });
77 #else
78 download.notify["status"].connect (() => {
79 changed ();
80 if (download.status == WebKit.DownloadStatus.FINISHED || download.status == WebKit.DownloadStatus.ERROR) {
81 Source.remove (poll_source);
82 poll_source = 0;
83 }
84 });
85 #endif
86 }64 }
87 }65 }
8866
8967
=== modified file 'katze/katze-item.c'
--- katze/katze-item.c 2015-08-10 02:44:13 +0000
+++ katze/katze-item.c 2016-09-20 20:57:01 +0000
@@ -459,34 +459,11 @@
459static void459static void
460katze_item_image_destroyed_cb (GtkWidget* image,460katze_item_image_destroyed_cb (GtkWidget* image,
461 KatzeItem* item);461 KatzeItem* item);
462#ifndef HAVE_WEBKIT2
463static void
464katze_item_icon_loaded_cb (WebKitFaviconDatabase* database,
465 const gchar* frame_uri,
466 GtkWidget* image)
467{
468 KatzeItem* item = g_object_get_data (G_OBJECT (image), "KatzeItem");
469 GdkPixbuf* pixbuf;
470 if (!g_strcmp0 (frame_uri, item->uri)
471 && (pixbuf = midori_paths_get_icon (frame_uri, image)))
472 {
473 gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
474 g_object_unref (pixbuf);
475 /* This signal fires extremely often (WebKit bug?)
476 we must throttle it (disconnect) once we have an icon */
477 katze_item_image_destroyed_cb (image, g_object_ref (item));
478 }
479}
480#endif
481462
482static void463static void
483katze_item_image_destroyed_cb (GtkWidget* image,464katze_item_image_destroyed_cb (GtkWidget* image,
484 KatzeItem* item)465 KatzeItem* item)
485{466{
486#ifndef HAVE_WEBKIT2
487 g_signal_handlers_disconnect_by_func (webkit_get_favicon_database (),
488 katze_item_icon_loaded_cb, image);
489#endif
490 g_object_unref (item);467 g_object_unref (item);
491}468}
492469
@@ -521,10 +498,6 @@
521 g_object_set_data (G_OBJECT (image), "KatzeItem", g_object_ref (item));498 g_object_set_data (G_OBJECT (image), "KatzeItem", g_object_ref (item));
522 g_signal_connect (image, "destroy",499 g_signal_connect (image, "destroy",
523 G_CALLBACK (katze_item_image_destroyed_cb), item);500 G_CALLBACK (katze_item_image_destroyed_cb), item);
524#ifndef HAVE_WEBKIT2
525 g_signal_connect (webkit_get_favicon_database (), "icon-loaded",
526 G_CALLBACK (katze_item_icon_loaded_cb), image);
527#endif
528 return image;501 return image;
529}502}
530503
531504
=== modified file 'katze/katze.h'
--- katze/katze.h 2013-10-22 22:38:26 +0000
+++ katze/katze.h 2016-09-20 20:57:01 +0000
@@ -18,11 +18,6 @@
18#include "katze-array.h"18#include "katze-array.h"
19#include "katze-arrayaction.h"19#include "katze-arrayaction.h"
20#include "katze-preferences.h"20#include "katze-preferences.h"
2121#include <webkit2/webkit2.h>
22#ifndef HAVE_WEBKIT2
23 #include <webkit/webkit.h>
24#else
25 #include <webkit2/webkit2.h>
26#endif
2722
28#endif /* __KATZE_H__ */23#endif /* __KATZE_H__ */
2924
=== modified file 'katze/midori-paths.vala'
--- katze/midori-paths.vala 2016-01-15 19:18:17 +0000
+++ katze/midori-paths.vala 2016-09-20 20:57:01 +0000
@@ -134,11 +134,9 @@
134 tmp_dir = get_runtime_dir ();134 tmp_dir = get_runtime_dir ();
135 }135 }
136 else {136 else {
137#if HAVE_WEBKIT2_3_91
138 /* Allow WebKit to spawn more than one rendering process */137 /* Allow WebKit to spawn more than one rendering process */
139 if (!("wk2:no-multi-render-process" in (Environment.get_variable ("MIDORI_DEBUG") ?? "")))138 if (!("wk2:no-multi-render-process" in (Environment.get_variable ("MIDORI_DEBUG") ?? "")))
140 WebKit.WebContext.get_default ().set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES);139 WebKit.WebContext.get_default ().set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES);
141#endif
142 string? real_config = config != null && !Path.is_absolute (config)140 string? real_config = config != null && !Path.is_absolute (config)
143 ? Path.build_filename (Environment.get_current_dir (), config) : config;141 ? Path.build_filename (Environment.get_current_dir (), config) : config;
144 config_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S,142 config_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S,
@@ -148,11 +146,10 @@
148 user_data_dir = Environment.get_user_data_dir ();146 user_data_dir = Environment.get_user_data_dir ();
149 tmp_dir = get_runtime_dir ();147 tmp_dir = get_runtime_dir ();
150 }148 }
151#if HAVE_WEBKIT2
152 if (cache_dir != null) {149 if (cache_dir != null) {
153 /* Cache and extension dir MUST be set no later than here to work */150 /* Cache and extension dir MUST be set no later than here to work */
154 WebKit.WebContext.get_default ().set_web_extensions_directory (151 WebKit.WebContext.get_default ().set_web_extensions_directory (
155 Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext"));152 get_lib_path (PACKAGE_NAME));
156 WebKit.WebContext.get_default ().set_disk_cache_directory (153 WebKit.WebContext.get_default ().set_disk_cache_directory (
157 Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "web"));154 Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "web"));
158 }155 }
@@ -162,32 +159,25 @@
162 cookie_manager.set_persistent_storage (Path.build_filename (config_dir, "cookies.db"),159 cookie_manager.set_persistent_storage (Path.build_filename (config_dir, "cookies.db"),
163 WebKit.CookiePersistentStorage.SQLITE);160 WebKit.CookiePersistentStorage.SQLITE);
164 }161 }
165#endif
166 if (user_data_dir != null) {162 if (user_data_dir != null) {
167 string folder = Path.build_filename (user_data_dir, "webkit", "icondatabase");163 string folder = Path.build_filename (user_data_dir, "webkit", "icondatabase");
168#if HAVE_WEBKIT2
169 WebKit.WebContext.get_default ().set_favicon_database_directory (folder);164 WebKit.WebContext.get_default ().set_favicon_database_directory (folder);
170#else
171 WebKit.get_favicon_database ().set_path (folder);
172#endif
173 }165 }
174 else166 else
175 {167 {
176#if HAVE_WEBKIT2
177 /* with wk2 set_favicon_database_directory can only be called once and actually168 /* with wk2 set_favicon_database_directory can only be called once and actually
178 initializes and enables the favicon database, so we do not call it in this case */169 initializes and enables the favicon database, so we do not call it in this case */
179#else
180 /* wk1 documentation claims that the favicon database is not enabled unless
181 a call to favicon_database.set_path is made, but in fact it must be explicitly
182 disabled by setting to null (verified as of webkitgtk 2.3.1) */
183 WebKit.get_favicon_database ().set_path (null);
184#endif
185 }170 }
186171
187 #if !HAVE_WIN32172 #if !HAVE_WIN32
188 Gtk.IconTheme.get_default ().append_search_path (exec_path);173 Gtk.IconTheme.get_default ().append_search_path (exec_path);
189 #endif174 #endif
190175
176 if (("wk2:ignore-tls" in (Environment.get_variable ("MIDORI_DEBUG") ?? "")))
177 WebKit.WebContext.get_default ().set_tls_errors_policy (WebKit.TLSErrorsPolicy.IGNORE);
178 else
179 WebKit.WebContext.get_default ().set_tls_errors_policy (WebKit.TLSErrorsPolicy.FAIL);
180
191 if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {181 if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {
192 stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n",182 stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n",
193 config_dir, cache_dir, user_data_dir, tmp_dir);183 config_dir, cache_dir, user_data_dir, tmp_dir);
@@ -451,11 +441,7 @@
451 public static void clear_icons () {441 public static void clear_icons () {
452 assert (cache_dir != null);442 assert (cache_dir != null);
453 assert (user_data_dir != null);443 assert (user_data_dir != null);
454#if HAVE_WEBKIT2
455 WebKit.WebContext.get_default ().get_favicon_database ().clear ();444 WebKit.WebContext.get_default ().get_favicon_database ().clear ();
456#else
457 WebKit.get_favicon_database ().clear ();
458#endif
459 /* FIXME: Exclude search engine icons */445 /* FIXME: Exclude search engine icons */
460 remove_path (Path.build_filename (user_data_dir, "webkit", "icondatabase"));446 remove_path (Path.build_filename (user_data_dir, "webkit", "icondatabase"));
461 }447 }
@@ -475,14 +461,7 @@
475 Gtk.IconSize.MENU, out icon_width, out icon_height);461 Gtk.IconSize.MENU, out icon_width, out icon_height);
476 else462 else
477 icon_width = icon_height = 0 /* maximum size */;463 icon_width = icon_height = 0 /* maximum size */;
478#if HAVE_WEBKIT2
479 /* There is no sync API for WebKit2 */464 /* There is no sync API for WebKit2 */
480#else
481 Gdk.Pixbuf? pixbuf = WebKit.get_favicon_database ()
482 .try_get_favicon_pixbuf (uri, icon_width, icon_height);
483 if (pixbuf != null)
484 return pixbuf;
485#endif
486 if (widget != null)465 if (widget != null)
487 return widget.render_icon (Gtk.STOCK_FILE, Gtk.IconSize.MENU, null);466 return widget.render_icon (Gtk.STOCK_FILE, Gtk.IconSize.MENU, null);
488 return null;467 return null;
489468
=== modified file 'katze/midori-uri.vala'
--- katze/midori-uri.vala 2015-04-12 13:30:03 +0000
+++ katze/midori-uri.vala 2016-09-20 20:57:01 +0000
@@ -248,16 +248,10 @@
248 * Since: 0.5.8248 * Since: 0.5.8
249 **/249 **/
250 public static async GLib.Icon? get_icon (string uri, Cancellable? cancellable=null) throws Error {250 public static async GLib.Icon? get_icon (string uri, Cancellable? cancellable=null) throws Error {
251#if HAVE_WEBKIT2
252 var database = WebKit.WebContext.get_default ().get_favicon_database ();251 var database = WebKit.WebContext.get_default ().get_favicon_database ();
253 var surface = yield database.get_favicon (uri, cancellable);252 var surface = yield database.get_favicon (uri, cancellable);
254 var image = (Cairo.ImageSurface)surface;253 var image = (Cairo.ImageSurface)surface;
255 var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());254 var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());
256#else
257 var database = WebKit.get_favicon_database ();
258 // We must not pass a Cancellable due to a crasher bug
259 var pixbuf = yield database.get_favicon_pixbuf (uri, 0, 0, null);
260#endif
261 return pixbuf as GLib.Icon;255 return pixbuf as GLib.Icon;
262 }256 }
263257
264258
=== modified file 'midori/main.c'
--- midori/main.c 2016-03-21 19:19:52 +0000
+++ midori/main.c 2016-09-20 20:57:01 +0000
@@ -39,6 +39,7 @@
39 g_free (uri);39 g_free (uri);
40}40}
4141
42<<<<<<< TREE
42#ifndef HAVE_WEBKIT243#ifndef HAVE_WEBKIT2
43static void44static void
44snapshot_load_finished_cb (GtkWidget* web_view,45snapshot_load_finished_cb (GtkWidget* web_view,
@@ -96,6 +97,8 @@
96 fclose (logfile);97 fclose (logfile);
97}98}
9899
100=======
101>>>>>>> MERGE-SOURCE
99int102int
100main (int argc,103main (int argc,
101 char** argv)104 char** argv)
@@ -321,10 +324,6 @@
321 else324 else
322 gtk_widget_set_size_request (web_view, 800, 600);325 gtk_widget_set_size_request (web_view, 800, 600);
323 gtk_widget_show_all (offscreen);326 gtk_widget_show_all (offscreen);
324 #ifndef HAVE_WEBKIT2
325 g_signal_connect (web_view, "load-finished",
326 G_CALLBACK (snapshot_load_finished_cb), filename);
327 #endif
328 uri = sokoke_magic_uri (snapshot, FALSE, TRUE);327 uri = sokoke_magic_uri (snapshot, FALSE, TRUE);
329 webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);328 webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);
330 g_free (uri);329 g_free (uri);
@@ -343,19 +342,11 @@
343 GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);342 GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
344 GtkWidget* vbox = gtk_vbox_new (FALSE, 0);343 GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
345 GtkWidget* entry = gtk_entry_new ();344 GtkWidget* entry = gtk_entry_new ();
346#ifndef HAVE_WEBKIT2
347 GtkWidget* scrolled = gtk_scrolled_window_new (NULL, NULL);
348#endif
349 GtkWidget* web_view = webkit_web_view_new ();345 GtkWidget* web_view = webkit_web_view_new ();
350 katze_window_set_sensible_default_size (GTK_WINDOW (window));346 katze_window_set_sensible_default_size (GTK_WINDOW (window));
351347
352 gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);348 gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
353#ifndef HAVE_WEBKIT2
354 gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
355 gtk_container_add (GTK_CONTAINER (scrolled), web_view);
356#else
357 gtk_box_pack_start (GTK_BOX (vbox), web_view, TRUE, TRUE, 0);349 gtk_box_pack_start (GTK_BOX (vbox), web_view, TRUE, TRUE, 0);
358#endif
359 gtk_container_add (GTK_CONTAINER (window), vbox);350 gtk_container_add (GTK_CONTAINER (window), vbox);
360 gtk_entry_set_text (GTK_ENTRY (entry), uris && *uris ? *uris : "http://www.example.com");351 gtk_entry_set_text (GTK_ENTRY (entry), uris && *uris ? *uris : "http://www.example.com");
361 plain_entry_activate_cb (entry, web_view);352 plain_entry_activate_cb (entry, web_view);
@@ -381,9 +372,6 @@
381372
382 MidoriBrowser* browser = midori_browser_new ();373 MidoriBrowser* browser = midori_browser_new ();
383 MidoriWebSettings* settings = midori_browser_get_settings (browser);374 MidoriWebSettings* settings = midori_browser_get_settings (browser);
384#ifndef HAVE_WEBKIT2
385 g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1);
386#endif
387 midori_load_soup_session (settings);375 midori_load_soup_session (settings);
388376
389 gchar* msg = NULL;377 gchar* msg = NULL;
390378
=== modified file 'midori/midori-browser.c'
--- midori/midori-browser.c 2016-01-23 19:21:31 +0000
+++ midori/midori-browser.c 2016-09-20 20:57:01 +0000
@@ -153,11 +153,9 @@
153static void153static void
154midori_browser_finalize (GObject* object);154midori_browser_finalize (GObject* object);
155155
156#ifdef HAVE_WEBKIT2
157void download_created_destination_cb (WebKitDownload *download,156void download_created_destination_cb (WebKitDownload *download,
158 gchar *destination,157 gchar *destination,
159 gpointer user_data);158 gpointer user_data);
160#endif
161159
162static void160static void
163midori_browser_set_property (GObject* object,161midori_browser_set_property (GObject* object,
@@ -1319,54 +1317,11 @@
1319 if (!midori_download_has_enough_space (download, uri, FALSE))1317 if (!midori_download_has_enough_space (download, uri, FALSE))
1320 return FALSE;1318 return FALSE;
13211319
1322#ifdef HAVE_WEBKIT2
1323 webkit_download_set_destination (download, uri);1320 webkit_download_set_destination (download, uri);
1324#else
1325 webkit_download_set_destination_uri (download, uri);
1326#endif
1327 g_signal_emit (browser, signals[ADD_DOWNLOAD], 0, download);1321 g_signal_emit (browser, signals[ADD_DOWNLOAD], 0, download);
1328 return TRUE;1322 return TRUE;
1329}1323}
13301324
1331#ifndef HAVE_WEBKIT2
1332static void
1333midori_browser_save_resources (GList* resources,
1334 const gchar* folder)
1335{
1336 GList* list;
1337 katze_mkdir_with_parents (folder, 0700);
1338
1339 for (list = resources; list; list = g_list_next (list))
1340 {
1341 WebKitWebResource* resource = WEBKIT_WEB_RESOURCE (list->data);
1342 GString* data = webkit_web_resource_get_data (resource);
1343
1344 /* Resource could be adblocked, skip it in that case */
1345 if (!g_strcmp0 (webkit_web_resource_get_uri (resource), "about:blank"))
1346 continue;
1347
1348 gchar* sub_filename = midori_download_get_filename_suggestion_for_uri (
1349 webkit_web_resource_get_mime_type (resource),
1350 webkit_web_resource_get_uri (resource));
1351 gchar* sub_path = g_build_filename (folder, sub_filename, NULL);
1352 sub_path = midori_download_get_unique_filename (sub_path);
1353 if (data)
1354 {
1355 GError* error = NULL;
1356 if (!g_file_set_contents (sub_path, data->str, data->len, &error))
1357 {
1358 g_warning ("Failed to save %s: %s", sub_filename, error->message);
1359 g_error_free (error);
1360 }
1361 }
1362 else
1363 g_warning ("Skipping empty resource %s", sub_filename);
1364 g_free (sub_filename);
1365 g_free (sub_path);
1366 }
1367}
1368#endif
1369
1370void1325void
1371midori_browser_save_uri (MidoriBrowser* browser,1326midori_browser_save_uri (MidoriBrowser* browser,
1372 MidoriView* view,1327 MidoriView* view,
@@ -1395,50 +1350,6 @@
1395 g_free (dirname);1350 g_free (dirname);
1396 }1351 }
13971352
1398#ifndef HAVE_WEBKIT2
1399 GList* resources = midori_view_get_resources (view);
1400 gboolean file_only = TRUE;
1401 GtkWidget* checkbox = NULL;
1402
1403 if (resources != NULL && g_list_nth_data (resources, 1) != NULL)
1404 {
1405 file_only = FALSE;
1406 checkbox = gtk_check_button_new_with_mnemonic (_("Save associated _resources"));
1407 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
1408 gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), checkbox);
1409 }
1410
1411 if (!file_only && !g_str_equal (title, uri))
1412 filename = midori_download_clean_filename (title);
1413 else
1414 {
1415 gchar* mime_type = katze_object_get_object (view, "mime-type");
1416 filename = midori_download_get_filename_suggestion_for_uri (mime_type, uri);
1417 g_free (mime_type);
1418 }
1419 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
1420 g_free (filename);
1421
1422 if (midori_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
1423 {
1424 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
1425 if (checkbox != NULL)
1426 file_only = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
1427 if (!file_only)
1428 {
1429 gchar* fullname = g_strconcat (filename, ".html", NULL);
1430 midori_view_save_source (view, uri, fullname, FALSE);
1431 g_free (fullname);
1432 midori_browser_save_resources (resources, filename);
1433 }
1434 else
1435 midori_view_save_source (view, uri, filename, FALSE);
1436 katze_assign (last_dir,
1437 gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)));
1438 }
1439 g_list_foreach (resources, (GFunc)g_object_unref, NULL);
1440 g_list_free (resources);
1441#else
1442 filename = midori_download_clean_filename (title);1353 filename = midori_download_clean_filename (title);
1443 gchar* suggested_filename = g_strconcat (filename, ".mht", NULL);1354 gchar* suggested_filename = g_strconcat (filename, ".mht", NULL);
1444 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename);1355 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename);
@@ -1456,7 +1367,6 @@
1456 katze_assign (last_dir,1367 katze_assign (last_dir,
1457 gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)));1368 gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)));
1458 }1369 }
1459#endif
1460 gtk_widget_destroy (dialog);1370 gtk_widget_destroy (dialog);
1461}1371}
14621372
@@ -1493,28 +1403,6 @@
1493midori_browser_view_copy_to_item_history (GtkWidget* view,1403midori_browser_view_copy_to_item_history (GtkWidget* view,
1494 KatzeItem* item)1404 KatzeItem* item)
1495{1405{
1496#ifndef HAVE_WEBKIT2
1497 WebKitWebView* copy_from;
1498 WebKitWebBackForwardList* list_from;
1499 guint length_from;
1500 gint i;
1501 GPtrArray* history;
1502
1503 copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
1504 list_from = webkit_web_view_get_back_forward_list (copy_from);
1505 length_from = webkit_web_back_forward_list_get_back_length (list_from);
1506 history = g_ptr_array_new ();
1507
1508 for (i = -length_from; i <= -1 ; i++)
1509 {
1510 WebKitWebHistoryItem* hist_item = webkit_web_back_forward_list_get_nth_item (list_from, i);
1511 if (hist_item == NULL)
1512 break;
1513 g_object_ref ((gpointer) hist_item);
1514 g_ptr_array_add (history, (gpointer) hist_item);
1515 }
1516 g_object_set_data (G_OBJECT (item), "tab-history", (gpointer) history);
1517#endif
1518}1406}
15191407
1520static void1408static void
@@ -1579,63 +1467,14 @@
1579 GtkWidget* view_from,1467 GtkWidget* view_from,
1580 gboolean omit_last)1468 gboolean omit_last)
1581{1469{
1582#ifndef HAVE_WEBKIT2
1583 WebKitWebView* copy_from;
1584 WebKitWebBackForwardList* list_from;
1585 WebKitWebView* copy_to;
1586 WebKitWebBackForwardList* list_to;
1587 guint length_from;
1588 gint i;
1589
1590 copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_from)));
1591 list_from = webkit_web_view_get_back_forward_list (copy_from);
1592 copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_to)));
1593 list_to = webkit_web_view_get_back_forward_list (copy_to);
1594 length_from = webkit_web_back_forward_list_get_back_length (list_from);
1595
1596 for (i = -length_from; i <= (omit_last ? -1 : 0); i++)
1597 {
1598 WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item (list_from, i);
1599 if (item == NULL)
1600 break;
1601 webkit_web_back_forward_list_add_item (list_to, item);
1602 }
1603#endif
1604}1470}
16051471
1606
1607static void1472static void
1608midori_browser_view_copy_from_item_history (GtkWidget* view,1473midori_browser_view_copy_from_item_history (GtkWidget* view,
1609 KatzeItem* item)1474 KatzeItem* item)
1610{1475{
1611#ifndef HAVE_WEBKIT2
1612 WebKitWebView* copy_to;
1613 WebKitWebBackForwardList* list_to;
1614 guint i;
1615 GPtrArray* list_from;
1616
1617 copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
1618 list_to = webkit_web_view_get_back_forward_list (copy_to);
1619
1620 if (item == NULL)
1621 return;
1622 list_from = g_object_get_data (G_OBJECT (item), "tab-history");
1623 if (list_from == NULL)
1624 return;
1625
1626 for (i = 0; i < list_from->len; i++)
1627 {
1628 WebKitWebHistoryItem* hist_item = (WebKitWebHistoryItem*) g_ptr_array_index (list_from, i);
1629 if (hist_item == NULL)
1630 break;
1631 webkit_web_back_forward_list_add_item (list_to, hist_item);
1632 }
1633 g_ptr_array_unref (list_from);
1634#endif
1635}1476}
16361477
1637
1638
1639static gboolean1478static gboolean
1640midori_browser_notify_new_tab_timeout_cb (MidoriBrowser *browser)1479midori_browser_notify_new_tab_timeout_cb (MidoriBrowser *browser)
1641{1480{
@@ -1785,7 +1624,6 @@
1785 }1624 }
1786}1625}
17871626
1788#ifdef HAVE_WEBKIT2
1789static void1627static void
1790midori_browser_close_tab_idle (GObject* resource,1628midori_browser_close_tab_idle (GObject* resource,
1791 GAsyncResult* result,1629 GAsyncResult* result,
@@ -1795,16 +1633,8 @@
1795 result, NULL, NULL);1633 result, NULL, NULL);
1796 if (data != NULL)1634 if (data != NULL)
1797 return;1635 return;
1798#else
1799static gboolean
1800midori_browser_close_tab_idle (gpointer view)
1801{
1802#endif
1803 MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));1636 MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
1804 midori_browser_close_tab (browser, GTK_WIDGET (view));1637 midori_browser_close_tab (browser, GTK_WIDGET (view));
1805#ifndef HAVE_WEBKIT2
1806 return G_SOURCE_REMOVE;
1807#endif
1808}1638}
18091639
1810static gboolean1640static gboolean
@@ -1820,11 +1650,7 @@
1820 {1650 {
1821 handled = FALSE;1651 handled = FALSE;
1822 }1652 }
1823 #ifdef HAVE_WEBKIT2
1824 else if (!webkit_download_get_destination (download))1653 else if (!webkit_download_get_destination (download))
1825 #else
1826 else if (!webkit_download_get_destination_uri (download))
1827 #endif
1828 {1654 {
1829 if (type == MIDORI_DOWNLOAD_SAVE_AS)1655 if (type == MIDORI_DOWNLOAD_SAVE_AS)
1830 {1656 {
@@ -1833,12 +1659,8 @@
18331659
1834 if (!dialog)1660 if (!dialog)
1835 {1661 {
1836 #ifdef HAVE_WEBKIT2
1837 const gchar* download_uri = webkit_uri_response_get_uri (1662 const gchar* download_uri = webkit_uri_response_get_uri (
1838 webkit_download_get_response (download));1663 webkit_download_get_response (download));
1839 #else
1840 const gchar* download_uri = webkit_download_get_uri (download);
1841 #endif
1842 gchar* folder;1664 gchar* folder;
1843 dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Save file"),1665 dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Save file"),
1844 GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);1666 GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
@@ -1883,24 +1705,14 @@
1883 midori_browser_prepare_download (browser, download, destination_uri);1705 midori_browser_prepare_download (browser, download, destination_uri);
1884 g_free (destination_uri);1706 g_free (destination_uri);
1885 }1707 }
1886 #ifndef HAVE_WEBKIT2
1887 webkit_download_start (download);
1888 #endif
1889 }1708 }
18901709
1891 /* Close empty tabs due to download links with a target */1710 /* Close empty tabs due to download links with a target */
1892 if (midori_view_is_blank (MIDORI_VIEW (view)))1711 if (midori_view_is_blank (MIDORI_VIEW (view)))
1893 {1712 {
1894 GtkWidget* web_view = midori_view_get_web_view (MIDORI_VIEW (view));1713 GtkWidget* web_view = midori_view_get_web_view (MIDORI_VIEW (view));
1895 #ifdef HAVE_WEBKIT2
1896 WebKitWebResource* resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (web_view));1714 WebKitWebResource* resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (web_view));
1897 webkit_web_resource_get_data (resource, NULL, midori_browser_close_tab_idle, view);1715 webkit_web_resource_get_data (resource, NULL, midori_browser_close_tab_idle, view);
1898 #else
1899 WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
1900 WebKitWebDataSource* datasource = webkit_web_frame_get_data_source (web_frame);
1901 if (webkit_web_data_source_get_data (datasource) == NULL)
1902 g_idle_add (midori_browser_close_tab_idle, view);
1903 #endif
1904 }1716 }
1905 return handled;1717 return handled;
1906}1718}
@@ -2145,35 +1957,6 @@
2145 return TRUE;1957 return TRUE;
2146 }1958 }
21471959
2148#ifndef HAVE_WEBKIT2
2149 GtkWidget* focus = gtk_window_get_focus (GTK_WINDOW (widget));
2150 if (focus == NULL)
2151 gtk_widget_grab_focus (midori_browser_get_current_tab (MIDORI_BROWSER (widget)));
2152 else if (G_OBJECT_TYPE (focus) == WEBKIT_TYPE_WEB_VIEW
2153 && event->keyval == GDK_KEY_space
2154 && (!(event->state & GDK_SHIFT_MASK))
2155 && !webkit_web_view_can_cut_clipboard (WEBKIT_WEB_VIEW (focus))
2156 && !webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (focus)))
2157 {
2158 /* Space at the bottom of the page: Go to next page */
2159 MidoriView* view = midori_view_get_for_widget (focus);
2160 GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (focus));
2161 GtkAdjustment* vadjust = gtk_scrolled_window_get_vadjustment (scrolled);
2162 if (gtk_adjustment_get_value (vadjust)
2163 == (gtk_adjustment_get_upper (vadjust) - gtk_adjustment_get_page_size (vadjust)))
2164 {
2165 /* Duplicate here because the URI pointer might change */
2166 gchar* uri = g_strdup (midori_view_get_next_page (view));
2167 if (uri != NULL)
2168 {
2169 midori_view_set_uri (view, uri);
2170 g_free (uri);
2171 return TRUE;
2172 }
2173 }
2174 }
2175#endif
2176
2177 if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))1960 if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
2178 if (sokoke_window_activate_key (window, event))1961 if (sokoke_window_activate_key (window, event))
2179 return TRUE;1962 return TRUE;
@@ -2991,11 +2774,7 @@
2991{2774{
2992 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2775 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
2993 if (WEBKIT_IS_WEB_VIEW (widget))2776 if (WEBKIT_IS_WEB_VIEW (widget))
2994#ifdef HAVE_WEBKIT2
2995 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_UNDO);2777 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_UNDO);
2996#else
2997 webkit_web_view_undo (WEBKIT_WEB_VIEW (widget));
2998#endif
2999}2778}
30002779
3001static void2780static void
@@ -3004,11 +2783,7 @@
3004{2783{
3005 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2784 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
3006 if (WEBKIT_IS_WEB_VIEW (widget))2785 if (WEBKIT_IS_WEB_VIEW (widget))
3007#ifdef HAVE_WEBKIT2
3008 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_REDO);2786 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_REDO);
3009#else
3010 webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));
3011#endif
3012}2787}
30132788
3014static void2789static void
@@ -3018,10 +2793,8 @@
3018 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2793 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
3019 if (G_LIKELY (widget) && g_signal_lookup ("cut-clipboard", G_OBJECT_TYPE (widget)))2794 if (G_LIKELY (widget) && g_signal_lookup ("cut-clipboard", G_OBJECT_TYPE (widget)))
3020 g_signal_emit_by_name (widget, "cut-clipboard");2795 g_signal_emit_by_name (widget, "cut-clipboard");
3021#ifdef HAVE_WEBKIT2
3022 else if (WEBKIT_IS_WEB_VIEW (widget))2796 else if (WEBKIT_IS_WEB_VIEW (widget))
3023 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_CUT);2797 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_CUT);
3024#endif
3025}2798}
30262799
3027static void2800static void
@@ -3031,10 +2804,8 @@
3031 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2804 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
3032 if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget)))2805 if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget)))
3033 g_signal_emit_by_name (widget, "copy-clipboard");2806 g_signal_emit_by_name (widget, "copy-clipboard");
3034#ifdef HAVE_WEBKIT2
3035 else if (WEBKIT_IS_WEB_VIEW (widget))2807 else if (WEBKIT_IS_WEB_VIEW (widget))
3036 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_COPY);2808 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_COPY);
3037#endif
3038}2809}
30392810
3040static void2811static void
@@ -3044,10 +2815,8 @@
3044 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2815 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
3045 if (G_LIKELY (widget) && g_signal_lookup ("paste-clipboard", G_OBJECT_TYPE (widget)))2816 if (G_LIKELY (widget) && g_signal_lookup ("paste-clipboard", G_OBJECT_TYPE (widget)))
3046 g_signal_emit_by_name (widget, "paste-clipboard");2817 g_signal_emit_by_name (widget, "paste-clipboard");
3047#ifdef HAVE_WEBKIT2
3048 else if (WEBKIT_IS_WEB_VIEW (widget))2818 else if (WEBKIT_IS_WEB_VIEW (widget))
3049 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_PASTE);2819 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_PASTE);
3050#endif
3051}2820}
30522821
3053static void2822static void
@@ -3059,10 +2828,6 @@
3059 {2828 {
3060 if (GTK_IS_EDITABLE (widget))2829 if (GTK_IS_EDITABLE (widget))
3061 gtk_editable_delete_selection (GTK_EDITABLE (widget));2830 gtk_editable_delete_selection (GTK_EDITABLE (widget));
3062#ifndef HAVE_WEBKIT2
3063 else if (WEBKIT_IS_WEB_VIEW (widget))
3064 webkit_web_view_delete_selection (WEBKIT_WEB_VIEW (widget));
3065#endif
3066 else if (GTK_IS_TEXT_VIEW (widget))2831 else if (GTK_IS_TEXT_VIEW (widget))
3067 gtk_text_buffer_delete_selection (2832 gtk_text_buffer_delete_selection (
3068 gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)), TRUE, FALSE);2833 gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)), TRUE, FALSE);
@@ -3078,10 +2843,8 @@
3078 {2843 {
3079 if (GTK_IS_EDITABLE (widget))2844 if (GTK_IS_EDITABLE (widget))
3080 gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);2845 gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
3081#ifdef HAVE_WEBKIT2
3082 else if (WEBKIT_IS_WEB_VIEW (widget))2846 else if (WEBKIT_IS_WEB_VIEW (widget))
3083 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_SELECT_ALL);2847 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_SELECT_ALL);
3084#endif
3085 else if (g_signal_lookup ("select-all", G_OBJECT_TYPE (widget)))2848 else if (g_signal_lookup ("select-all", G_OBJECT_TYPE (widget)))
3086 {2849 {
3087 if (GTK_IS_TEXT_VIEW (widget))2850 if (GTK_IS_TEXT_VIEW (widget))
@@ -3595,11 +3358,7 @@
3595 encoding = "ISO-8859-1";3358 encoding = "ISO-8859-1";
3596 else3359 else
3597 g_assert_not_reached ();3360 g_assert_not_reached ();
3598 #ifdef HAVE_WEBKIT2
3599 webkit_web_view_set_custom_charset (web_view, encoding);3361 webkit_web_view_set_custom_charset (web_view, encoding);
3600 #else
3601 webkit_web_view_set_custom_encoding (web_view, encoding);
3602 #endif
3603}3362}
36043363
3605static void3364static void
@@ -3607,39 +3366,7 @@
3607 MidoriBrowser* browser,3366 MidoriBrowser* browser,
3608 gboolean use_dom)3367 gboolean use_dom)
3609{3368{
3610 #ifdef HAVE_WEBKIT2
3611 /* TODO: midori_view_save_source isn't async and not WebKit2-friendly */3369 /* TODO: midori_view_save_source isn't async and not WebKit2-friendly */
3612 #else
3613 GtkWidget* view = midori_browser_get_current_tab (browser);
3614 gchar* filename = midori_view_save_source (MIDORI_VIEW (view), NULL, NULL, use_dom);
3615 gchar* text_editor;
3616 GAppInfo* info;
3617 g_object_get (browser->settings, "text-editor", &text_editor, NULL);
3618 if (text_editor && *text_editor)
3619 info = g_app_info_create_from_commandline (text_editor, NULL, 0, NULL);
3620 else
3621 info = g_app_info_get_default_for_type ("text/plain", FALSE);
3622 GFile* file = g_file_new_for_path (filename);
3623 GList* files = g_list_append (NULL, file);
3624 GError* error = NULL;
3625 GdkDisplay* display = gtk_widget_get_display (view);
3626 #if GTK_CHECK_VERSION (3, 0, 0)
3627 GdkAppLaunchContext* ctx = gdk_display_get_app_launch_context (display);
3628 #else
3629 GdkAppLaunchContext* ctx = gdk_app_launch_context_new ();
3630 gdk_app_launch_context_set_display (ctx, display);
3631 #endif
3632 if (!g_app_info_launch (info, files, G_APP_LAUNCH_CONTEXT (ctx), &error))
3633 {
3634 g_printerr ("Failed to open editor: %s", error->message);
3635 g_error_free (error);
3636 }
3637 g_object_unref (info);
3638 g_list_free (files);
3639 g_object_unref (file);
3640 g_free (filename);
3641 g_free (text_editor);
3642 #endif
3643}3370}
36443371
3645static void3372static void
@@ -3736,20 +3463,6 @@
3736_action_scroll_somewhere_activate (GtkAction* action,3463_action_scroll_somewhere_activate (GtkAction* action,
3737 MidoriBrowser* browser)3464 MidoriBrowser* browser)
3738{3465{
3739#ifndef HAVE_WEBKIT2
3740 GtkWidget* view = midori_browser_get_current_tab (browser);
3741 WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
3742 const gchar* name = gtk_action_get_name (action);
3743
3744 if (g_str_equal (name, "ScrollLeft"))
3745 webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, -1);
3746 else if (g_str_equal (name, "ScrollDown"))
3747 webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_DISPLAY_LINES, 1);
3748 else if (g_str_equal (name, "ScrollUp"))
3749 webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_DISPLAY_LINES, -1);
3750 else if (g_str_equal (name, "ScrollRight"))
3751 webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, 1);
3752#endif
3753}3466}
37543467
3755static void3468static void
@@ -3833,15 +3546,9 @@
3833 if (middle_click)3546 if (middle_click)
3834 {3547 {
3835 WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));3548 WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
3836 #ifdef HAVE_WEBKIT2
3837 WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);3549 WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);
3838 WebKitBackForwardListItem* item = webkit_back_forward_list_get_back_item (list);3550 WebKitBackForwardListItem* item = webkit_back_forward_list_get_back_item (list);
3839 const gchar* back_uri = webkit_back_forward_list_item_get_uri (item);3551 const gchar* back_uri = webkit_back_forward_list_item_get_uri (item);
3840 #else
3841 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);
3842 WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_forward_item (list);
3843 const gchar* back_uri = webkit_web_history_item_get_uri (item);
3844 #endif
38453552
3846 GtkWidget* new_view = midori_browser_add_uri (browser, back_uri);3553 GtkWidget* new_view = midori_browser_add_uri (browser, back_uri);
3847 midori_browser_set_current_tab_smartly (browser, new_view);3554 midori_browser_set_current_tab_smartly (browser, new_view);
@@ -3856,15 +3563,9 @@
3856 if (middle_click)3563 if (middle_click)
3857 {3564 {
3858 WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));3565 WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
3859 #ifdef HAVE_WEBKIT2
3860 WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);3566 WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);
3861 WebKitBackForwardListItem* item = webkit_back_forward_list_get_forward_item (list);3567 WebKitBackForwardListItem* item = webkit_back_forward_list_get_forward_item (list);
3862 const gchar* forward_uri = webkit_back_forward_list_item_get_uri (item);3568 const gchar* forward_uri = webkit_back_forward_list_item_get_uri (item);
3863 #else
3864 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);
3865 WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_forward_item (list);
3866 const gchar* forward_uri = webkit_web_history_item_get_uri (item);
3867 #endif
38683569
3869 GtkWidget* new_view = midori_browser_add_uri (browser, forward_uri);3570 GtkWidget* new_view = midori_browser_add_uri (browser, forward_uri);
3870 midori_browser_set_current_tab_smartly (browser, new_view);3571 midori_browser_set_current_tab_smartly (browser, new_view);
@@ -3963,41 +3664,10 @@
3963 midori_browser_get_current_uri (browser));3664 midori_browser_get_current_uri (browser));
3964}3665}
39653666
3966#ifndef HAVE_WEBKIT2
3967static void
3968midori_browser_item_icon_loaded_cb (WebKitFaviconDatabase* database,
3969 const gchar* frame_uri,
3970 KatzeItem* item)
3971{
3972 gchar* uri = g_object_get_data (G_OBJECT (item), "browser-queue-icon");
3973 if (strcmp (frame_uri, uri))
3974 return;
3975
3976 gchar* icon_uri = webkit_favicon_database_get_favicon_uri (
3977 webkit_get_favicon_database (), frame_uri);
3978 if (icon_uri != NULL)
3979 {
3980 g_free (icon_uri);
3981 katze_item_set_icon (item, frame_uri);
3982 /* This signal fires extremely often (WebKit bug?)
3983 we must throttle it (disconnect) once we have an icon */
3984 g_signal_handlers_disconnect_by_func (webkit_get_favicon_database (),
3985 midori_browser_item_icon_loaded_cb, item);
3986 }
3987}
3988#endif
3989
3990static void3667static void
3991midori_browser_queue_item_for_icon (KatzeItem* item,3668midori_browser_queue_item_for_icon (KatzeItem* item,
3992 const gchar* uri)3669 const gchar* uri)
3993{3670{
3994#ifndef HAVE_WEBKIT2
3995 if (katze_item_get_icon (item) != NULL)
3996 return;
3997 g_object_set_data_full (G_OBJECT (item), "browser-queue-icon", g_strdup (uri), g_free);
3998 g_signal_connect (webkit_get_favicon_database (), "icon-loaded",
3999 G_CALLBACK (midori_browser_item_icon_loaded_cb), item);
4000#endif
4001}3671}
40023672
4003static void3673static void
@@ -6171,7 +5841,6 @@
6171 gint icon_size = 16;5841 gint icon_size = 16;
6172 gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)),5842 gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)),
6173 GTK_ICON_SIZE_MENU, &icon_size, NULL);5843 GTK_ICON_SIZE_MENU, &icon_size, NULL);
6174 gtk_widget_set_size_request (throbber_box, icon_size, icon_size);
6175 gtk_container_add (GTK_CONTAINER (throbber_box), browser->throbber);5844 gtk_container_add (GTK_CONTAINER (throbber_box), browser->throbber);
6176 gtk_widget_show (throbber_box);5845 gtk_widget_show (throbber_box);
6177 gtk_container_add (GTK_CONTAINER (menuitem), throbber_box);5846 gtk_container_add (GTK_CONTAINER (menuitem), throbber_box);
@@ -6389,17 +6058,6 @@
6389 gtk_toolbar_style);6058 gtk_toolbar_style);
6390}6059}
63916060
6392#ifndef HAVE_WEBKIT2
6393static void
6394midori_browser_toolbar_popup_context_menu_history_cb (GtkMenuItem* menu_item,
6395 MidoriBrowser* browser)
6396{
6397 gint steps = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "steps"));
6398 MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));
6399 midori_view_go_back_or_forward (view, steps);
6400}
6401#endif
6402
6403static void6061static void
6404midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser,6062midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser,
6405 GtkWidget* widget,6063 GtkWidget* widget,
@@ -6407,61 +6065,6 @@
6407 gint x,6065 gint x,
6408 gint y)6066 gint y)
6409{6067{
6410#ifndef HAVE_WEBKIT2
6411 const gint step = back ? -1 : 1;
6412 gint steps = step;
6413 GtkWidget* menu;
6414 WebKitWebBackForwardList* list;
6415 WebKitWebHistoryItem* current_item;
6416 WebKitWebHistoryItem* history_item;
6417 WebKitWebHistoryItem* (*history_next)(WebKitWebBackForwardList*);
6418 void (*history_action)(WebKitWebBackForwardList*);
6419
6420 list = webkit_web_view_get_back_forward_list (
6421 WEBKIT_WEB_VIEW (midori_view_get_web_view (
6422 MIDORI_VIEW (midori_browser_get_current_tab (browser)))));
6423
6424 if (!list)
6425 return;
6426
6427 menu = gtk_menu_new ();
6428
6429 history_action = back ?
6430 webkit_web_back_forward_list_go_back :
6431 webkit_web_back_forward_list_go_forward;
6432 history_next = back ?
6433 webkit_web_back_forward_list_get_back_item :
6434 webkit_web_back_forward_list_get_forward_item;
6435 current_item = webkit_web_back_forward_list_get_current_item (list);
6436
6437 for (; (history_item = history_next (list)); history_action (list), steps += step)
6438 {
6439 const gchar* uri = webkit_web_history_item_get_uri (history_item);
6440 GtkWidget* menu_item = gtk_image_menu_item_new_with_label (
6441 webkit_web_history_item_get_title (history_item));
6442 GdkPixbuf* pixbuf;
6443 if ((pixbuf = midori_paths_get_icon (uri, widget)))
6444 {
6445 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
6446 gtk_image_new_from_pixbuf (pixbuf));
6447 g_object_unref (pixbuf);
6448 }
6449 g_object_set_data (G_OBJECT (menu_item), "uri", (gpointer)uri);
6450 g_object_set_data (G_OBJECT (menu_item), "steps", GINT_TO_POINTER (steps));
6451 gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
6452 g_signal_connect (G_OBJECT (menu_item), "activate",
6453 G_CALLBACK (midori_browser_toolbar_popup_context_menu_history_cb),
6454 browser);
6455 if (steps == (10 - 1))
6456 break;
6457 }
6458
6459 webkit_web_back_forward_list_go_to_item (list, current_item);
6460 gtk_widget_show_all (menu);
6461
6462 katze_widget_popup (widget, GTK_MENU (menu), NULL,
6463 KATZE_MENU_POSITION_LEFT);
6464#endif
6465}6068}
64666069
6467static void6070static void
@@ -7031,11 +6634,6 @@
7031 g_return_if_fail (MIDORI_IS_BROWSER (browser));6634 g_return_if_fail (MIDORI_IS_BROWSER (browser));
7032 g_return_if_fail (GTK_IS_WIDGET (view));6635 g_return_if_fail (GTK_IS_WIDGET (view));
70336636
7034#ifndef HAVE_WEBKIT2
7035 if (!g_object_get_data (G_OBJECT (webkit_get_default_session ()),
7036 "midori-session-initialized"))
7037 g_critical ("midori_load_soup_session was not called!");
7038#endif
7039 g_signal_emit (browser, signals[ADD_TAB], 0, view);6637 g_signal_emit (browser, signals[ADD_TAB], 0, view);
7040}6638}
70416639
70426640
=== modified file 'midori/midori-browser.h'
--- midori/midori-browser.h 2015-05-24 00:19:21 +0000
+++ midori/midori-browser.h 2016-09-20 20:57:01 +0000
@@ -40,11 +40,7 @@
40 /* Signals */40 /* Signals */
41 void41 void
42 (*window_object_cleared) (MidoriBrowser* browser,42 (*window_object_cleared) (MidoriBrowser* browser,
43#ifndef HAVE_WEBKIT2
44 WebKitWebFrame* web_frame,
45#else
46 void* web_frame,43 void* web_frame,
47#endif
48 JSContextRef* context,44 JSContextRef* context,
49 JSObjectRef* window_object);45 JSObjectRef* window_object);
50 void46 void
5147
=== modified file 'midori/midori-contextaction.vala'
--- midori/midori-contextaction.vala 2015-06-06 12:20:44 +0000
+++ midori/midori-contextaction.vala 2016-09-20 20:57:01 +0000
@@ -70,7 +70,6 @@
70 warning ("Action %s not known to ContextAction", name);70 warning ("Action %s not known to ContextAction", name);
71 }71 }
7272
73#if HAVE_WEBKIT2
74 public WebKit.ContextMenu create_webkit_context_menu (WebKit.ContextMenu? default_menu) {73 public WebKit.ContextMenu create_webkit_context_menu (WebKit.ContextMenu? default_menu) {
75 var menu = default_menu ?? new WebKit.ContextMenu ();74 var menu = default_menu ?? new WebKit.ContextMenu ();
76 foreach (var action in children) {75 foreach (var action in children) {
@@ -90,7 +89,6 @@
90 }89 }
91 return menu;90 return menu;
92 }91 }
93#endif
9492
95 Gtk.ToolButton toolitem;93 Gtk.ToolButton toolitem;
96 public override unowned Gtk.Widget create_tool_item () {94 public override unowned Gtk.Widget create_tool_item () {
9795
=== modified file 'midori/midori-download.vala'
--- midori/midori-download.vala 2016-01-15 19:18:17 +0000
+++ midori/midori-download.vala 2016-09-20 20:57:01 +0000
@@ -16,20 +16,9 @@
16namespace Midori {16namespace Midori {
17 namespace Download {17 namespace Download {
18 public static bool is_finished (WebKit.Download download) {18 public static bool is_finished (WebKit.Download download) {
19#if !HAVE_WEBKIT2
20 switch (download.status) {
21 case WebKit.DownloadStatus.FINISHED:
22 case WebKit.DownloadStatus.CANCELLED:
23 case WebKit.DownloadStatus.ERROR:
24 return true;
25 default:
26 return false;
27 }
28#else
29 if (download.estimated_progress == 1)19 if (download.estimated_progress == 1)
30 return true;20 return true;
31 return false;21 return false;
32#endif
33 }22 }
3423
35 public static int get_type (WebKit.Download download) {24 public static int get_type (WebKit.Download download) {
@@ -40,90 +29,17 @@
40 download.set_data<int> ("midori-download-type", type);29 download.set_data<int> ("midori-download-type", type);
41 }30 }
4231
43#if HAVE_WEBKIT2
44 public static string get_filename (WebKit.Download download) {32 public static string get_filename (WebKit.Download download) {
45 return download.get_data<string> ("midori-download-filename");33 return download.get_data<string> ("midori-download-filename");
46 }34 }
47 public static void set_filename (WebKit.Download download, string name) {35 public static void set_filename (WebKit.Download download, string name) {
48 download.set_data<string> ("midori-download-filename", name);36 download.set_data<string> ("midori-download-filename", name);
49 }37 }
50#endif
51 public static double get_progress (WebKit.Download download) {38 public static double get_progress (WebKit.Download download) {
52#if !HAVE_WEBKIT2
53 /* Avoid a bug in WebKit */
54 if (download.status == WebKit.DownloadStatus.CREATED)
55 return 0.0;
56 return download.progress;
57#else
58 return download.estimated_progress;39 return download.estimated_progress;
59#endif
60 }40 }
6141
62 public static string calculate_tooltip (WebKit.Download download) {42 public static string calculate_tooltip (WebKit.Download download) {
63#if !HAVE_WEBKIT2
64 string filename = Midori.Download.get_basename_for_display (download.destination_uri);
65 /* i18n: Download tooltip (size): 4KB of 43MB */
66 string size = _("%s of %s").printf (
67 format_size (download.current_size),
68 format_size (download.total_size));
69
70 /* Finished, no speed or remaining time */
71 if (is_finished (download) || download.status == WebKit.DownloadStatus.CREATED)
72 return "%s\n%s".printf (filename, size);
73
74 uint64 total_size = download.total_size, current_size = download.current_size;
75 double elapsed = download.get_elapsed_time (),
76 diff = elapsed / current_size,
77 estimated = (total_size - current_size) * diff;
78 int hour = 3600, minute = 60;
79 int hours = (int)(estimated / hour),
80 minutes = (int)((estimated - (hours * hour)) / minute),
81 seconds = (int)((estimated - (hours * hour) - (minutes * minute)));
82 string hours_ = ngettext ("%d hour", "%d hours", hours).printf (hours);
83 string minutes_ = ngettext ("%d minute", "%d minutes", minutes).printf (minutes);
84 string seconds_ = ngettext ("%d second", "%d seconds", seconds).printf (seconds);
85 double last_time = download.get_data<int> ("last-time");
86
87 string eta = "";
88 if (estimated > 0) {
89 if (hours > 0)
90 eta = hours_ + ", " + minutes_;
91 else if (minutes >= 10)
92 eta = minutes_;
93 else if (minutes < 10 && minutes > 0)
94 eta = minutes_ + ", " + seconds_;
95 else if (seconds > 0)
96 eta = seconds_;
97 if (eta != "")
98 /* i18n: Download tooltip (estimated time) : - 1 hour, 5 minutes remaning */
99 eta = _(" - %s remaining").printf (eta);
100 }
101
102 string speed = "";
103 uint64? last_size = download.get_data<uint64?> ("last-size");
104 if (last_size != null && elapsed != last_time) {
105 if (current_size != last_size) {
106 speed = format_size ((uint64)(
107 (current_size - last_size) / (elapsed - last_time)));
108 download.set_data ("last-speed", speed.dup ());
109 }
110 else {
111 speed = download.get_data ("last-speed");
112 }
113 }
114 else
115 /* i18n: Unknown number of bytes, used for transfer rate like ?B/s */
116 speed = _("?B");
117 /* i18n: Download tooltip (transfer rate): (130KB/s) */
118 speed = _(" (%s/s)").printf (speed);
119
120 if (elapsed - last_time > 0.0) {
121 download.set_data<int> ("last-time", (int)elapsed);
122 download.set_data<uint64?> ("last-size", current_size);
123 }
124
125 return "%s\n%s %s%s".printf (filename, size, speed, eta);
126#else
127 string filename = Midori.Download.get_basename_for_display (download.destination);43 string filename = Midori.Download.get_basename_for_display (download.destination);
12844
129 string size = "%s".printf (format_size (download.get_received_data_length ()));45 string size = "%s".printf (format_size (download.get_received_data_length ()));
@@ -134,17 +50,12 @@
134 if (is_finished (download))50 if (is_finished (download))
135 return "%s\n %s".printf (filename, size);51 return "%s\n %s".printf (filename, size);
136 return "%s\n %s - %s".printf (filename, speed, progress);52 return "%s\n %s - %s".printf (filename, speed, progress);
137#endif
138 }53 }
13954
140 public static string get_content_type (WebKit.Download download, string? mime_type) {55 public static string get_content_type (WebKit.Download download, string? mime_type) {
141#if HAVE_WEBKIT2
142 string? content_type = ContentType.guess (download.response.suggested_filename == null ?56 string? content_type = ContentType.guess (download.response.suggested_filename == null ?
143 download.destination : download.response.suggested_filename,57 download.destination : download.response.suggested_filename,
144 null, null);58 null, null);
145#else
146 string? content_type = ContentType.guess (download.suggested_filename, null, null);
147#endif
148 if (content_type == null) {59 if (content_type == null) {
149 content_type = ContentType.from_mime_type (mime_type);60 content_type = ContentType.from_mime_type (mime_type);
150 if (content_type == null)61 if (content_type == null)
@@ -157,24 +68,14 @@
157 int status = download.get_data<int> ("checksum-status");68 int status = download.get_data<int> ("checksum-status");
158 if (status == 0) {69 if (status == 0) {
159 /* Link Fingerprint */70 /* Link Fingerprint */
160 #if HAVE_WEBKIT2
161 string? original_uri = download.get_request ().uri;71 string? original_uri = download.get_request ().uri;
162 #else
163 string? original_uri = download.network_request.get_data<string> ("midori-original-uri");
164 if (original_uri == null)
165 original_uri = download.get_uri ();
166 #endif
167 string? fingerprint;72 string? fingerprint;
168 ChecksumType checksum_type = URI.get_fingerprint (original_uri, out fingerprint, null);73 ChecksumType checksum_type = URI.get_fingerprint (original_uri, out fingerprint, null);
169 /* By default, no wrong checksum */74 /* By default, no wrong checksum */
170 status = 2;75 status = 2;
171 if (fingerprint != null) {76 if (fingerprint != null) {
172 try {77 try {
173 #if HAVE_WEBKIT2
174 string filename = Filename.from_uri (download.destination);78 string filename = Filename.from_uri (download.destination);
175 #else
176 string filename = Filename.from_uri (download.destination_uri);
177 #endif
178 string contents;79 string contents;
179 size_t length;80 size_t length;
180 bool y = FileUtils.get_contents (filename, out contents, out length);81 bool y = FileUtils.get_contents (filename, out contents, out length);
@@ -194,62 +95,16 @@
194 }95 }
19596
196 public static bool action_clear (WebKit.Download download, Gtk.Widget widget) throws Error {97 public static bool action_clear (WebKit.Download download, Gtk.Widget widget) throws Error {
197#if !HAVE_WEBKIT2
198 switch (download.status) {
199 case WebKit.DownloadStatus.CREATED:
200 case WebKit.DownloadStatus.STARTED:
201 download.cancel ();
202 break;
203 case WebKit.DownloadStatus.FINISHED:
204 if (open (download, widget))
205 return true;
206 break;
207 case WebKit.DownloadStatus.CANCELLED:
208 return true;
209 default:
210 critical ("action_clear: %d", download.status);
211 warn_if_reached ();
212 break;
213 }
214 #else
215
216 if (download.estimated_progress < 1) {
217 download.cancel ();
218 } else {
219 if (open (download, widget))
220 return true;
221 }
222#endif
223 return false;98 return false;
224 }99 }
225100
226 public static string action_stock_id (WebKit.Download download) {101 public static string action_stock_id (WebKit.Download download) {
227#if !HAVE_WEBKIT2
228 switch (download.status) {
229 case WebKit.DownloadStatus.CREATED:
230 case WebKit.DownloadStatus.STARTED:
231 return Gtk.Stock.CANCEL;
232 case WebKit.DownloadStatus.FINISHED:
233 if (has_wrong_checksum (download))
234 return Gtk.Stock.DIALOG_WARNING;
235 return Gtk.Stock.OPEN;
236 case WebKit.DownloadStatus.CANCELLED:
237 return Gtk.Stock.CLEAR;
238 case WebKit.DownloadStatus.ERROR:
239 return Gtk.Stock.DIALOG_ERROR;
240 default:
241 critical ("action_stock_id: %d", download.status);
242 warn_if_reached ();
243 return Gtk.Stock.MISSING_IMAGE;
244 }
245#else
246 if (download.estimated_progress == 1)102 if (download.estimated_progress == 1)
247 if (has_wrong_checksum (download))103 if (has_wrong_checksum (download))
248 return Gtk.Stock.DIALOG_WARNING;104 return Gtk.Stock.DIALOG_WARNING;
249 else105 else
250 return Gtk.Stock.OPEN;106 return Gtk.Stock.OPEN;
251 return Gtk.Stock.CANCEL;107 return Gtk.Stock.CANCEL;
252#endif
253 }108 }
254109
255 /* returns whether an application was successfully launched to handle the file */110 /* returns whether an application was successfully launched to handle the file */
@@ -265,11 +120,7 @@
265 Tab? tab = null;120 Tab? tab = null;
266 browser.get ("tab", &tab);121 browser.get ("tab", &tab);
267 if (tab != null)122 if (tab != null)
268 #if HAVE_WEBKIT2
269 return tab.open_uri (download.destination);123 return tab.open_uri (download.destination);
270 #else
271 return tab.open_uri (download.destination_uri);
272 #endif
273 }124 }
274 return false;125 return false;
275 }126 }
@@ -297,16 +148,10 @@
297 }148 }
298149
299 public string get_suggested_filename (WebKit.Download download) {150 public string get_suggested_filename (WebKit.Download download) {
300#if !HAVE_WEBKIT2
301 /* https://bugs.webkit.org/show_bug.cgi?id=83161
302 https://d19vezwu8eufl6.cloudfront.net/nlp/slides%2F03-01-FormalizingNB.pdf */
303 return clean_filename (download.get_suggested_filename ());
304#else
305 string name = get_filename (download);151 string name = get_filename (download);
306 if (name == null)152 if (name == null)
307 return "";153 return "";
308 return name;154 return name;
309#endif
310 }155 }
311156
312 /**157 /**
@@ -397,42 +242,6 @@
397 * @destination_uri, considering space on disk and permissions242 * @destination_uri, considering space on disk and permissions
398 */243 */
399 public static bool has_enough_space (WebKit.Download download, string destination_uri, bool quiet=false) {244 public static bool has_enough_space (WebKit.Download download, string destination_uri, bool quiet=false) {
400#if !HAVE_WEBKIT2
401 var folder = File.new_for_uri (destination_uri).get_parent ();
402 bool can_write;
403 uint64 free_space;
404 try {
405 var info = folder.query_filesystem_info ("filesystem::free");
406 free_space = info.get_attribute_uint64 ("filesystem::free");
407 info = folder.query_info ("access::can-write", 0);
408 can_write = info.get_attribute_boolean ("access::can-write");
409 }
410 catch (Error error) {
411 can_write = false;
412 free_space = 0;
413 }
414
415 if (free_space < download.total_size || !can_write) {
416 string message;
417 string detailed_message;
418 if (!can_write) {
419 message = _("The file \"%s\" can't be saved in this folder.").printf (
420 Midori.Download.get_basename_for_display (destination_uri));
421 detailed_message = _("You don't have permission to write in this location.");
422 }
423 else if (free_space < download.total_size) {
424 message = _("There is not enough free space to download \"%s\".").printf (
425 Midori.Download.get_basename_for_display (destination_uri));
426 detailed_message = _("The file needs %s but only %s are left.").printf (
427 format_size (download.total_size), format_size (free_space));
428 }
429 else
430 assert_not_reached ();
431 if (!quiet)
432 Sokoke.message_dialog (Gtk.MessageType.ERROR, message, detailed_message, false);
433 return false;
434 }
435#endif
436 return true;245 return true;
437 }246 }
438 }247 }
439248
=== modified file 'midori/midori-frontend.c'
--- midori/midori-frontend.c 2016-01-23 19:21:31 +0000
+++ midori/midori-frontend.c 2016-09-20 20:57:01 +0000
@@ -175,9 +175,6 @@
175 guint i;175 guint i;
176176
177 midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, config);177 midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, config);
178#ifndef HAVE_WEBKIT2
179 g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1);
180#endif
181178
182 /* Mask the timezone, which can be read by Javascript */179 /* Mask the timezone, which can be read by Javascript */
183 g_setenv ("TZ", "UTC", TRUE);180 g_setenv ("TZ", "UTC", TRUE);
184181
=== modified file 'midori/midori-locationaction.c'
--- midori/midori-locationaction.c 2015-08-10 23:42:56 +0000
+++ midori/midori-locationaction.c 2016-09-20 20:57:01 +0000
@@ -22,6 +22,7 @@
22#include "config.h"22#include "config.h"
23#include <string.h>23#include <string.h>
24#include <glib/gi18n.h>24#include <glib/gi18n.h>
25#include <gdk/gdk.h>
25#include <gdk/gdkkeysyms.h>26#include <gdk/gdkkeysyms.h>
2627
27#include <sqlite3.h>28#include <sqlite3.h>
@@ -46,6 +47,10 @@
46 gint completion_index;47 gint completion_index;
47 GtkWidget* entry;48 GtkWidget* entry;
48 KatzeArray* history;49 KatzeArray* history;
50 #if GTK_CHECK_VERSION (3, 18, 0)
51 GdkDevice* device;
52 guint32 time;
53 #endif
49};54};
5055
51struct _MidoriLocationActionClass56struct _MidoriLocationActionClass
@@ -738,6 +743,8 @@
738 g_signal_connect (popup, "destroy",743 g_signal_connect (popup, "destroy",
739 G_CALLBACK (gtk_widget_destroyed), &action->popup);744 G_CALLBACK (gtk_widget_destroyed), &action->popup);
740 gtk_widget_show_all (popup_frame);745 gtk_widget_show_all (popup_frame);
746
747 gtk_widget_realize (action->popup);
741 }748 }
742749
743 if (!gtk_widget_get_visible (action->popup))750 if (!gtk_widget_get_visible (action->popup))
@@ -746,6 +753,21 @@
746 gtk_window_set_screen (GTK_WINDOW (action->popup),753 gtk_window_set_screen (GTK_WINDOW (action->popup),
747 gtk_widget_get_screen (action->entry));754 gtk_widget_get_screen (action->entry));
748 gtk_window_set_transient_for (GTK_WINDOW (action->popup), GTK_WINDOW (toplevel));755 gtk_window_set_transient_for (GTK_WINDOW (action->popup), GTK_WINDOW (toplevel));
756 gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
757 GTK_WINDOW (action->popup));
758
759 #if GTK_CHECK_VERSION (3, 18, 0)
760 GdkDevice* device = action->device;
761
762 if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
763 device = gdk_device_get_associated_device (device);
764
765 gdk_device_grab (device, gtk_widget_get_window (action->popup),
766 GDK_OWNERSHIP_WINDOW, TRUE,
767 GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
768 NULL, action->time);
769 #endif
770
749 #if GTK_CHECK_VERSION (3, 4, 0)771 #if GTK_CHECK_VERSION (3, 4, 0)
750 gtk_window_set_attached_to (GTK_WINDOW (action->popup), action->entry);772 gtk_window_set_attached_to (GTK_WINDOW (action->popup), action->entry);
751 #endif773 #endif
@@ -767,6 +789,10 @@
767 g_signal_connect (entry, "destroy",789 g_signal_connect (entry, "destroy",
768 G_CALLBACK (gtk_widget_destroyed), &action->entry);790 G_CALLBACK (gtk_widget_destroyed), &action->entry);
769 }791 }
792 #if GTK_CHECK_VERSION (3, 18, 0)
793 action->device = gtk_get_current_event_device ();
794 action->time = gtk_get_current_event_time ();
795 #endif
770 g_idle_add (midori_location_action_popup_timeout_cb, action);796 g_idle_add (midori_location_action_popup_timeout_cb, action);
771}797}
772798
@@ -1294,33 +1320,6 @@
1294 #include <gcr/gcr.h>1320 #include <gcr/gcr.h>
1295#endif1321#endif
12961322
1297#ifndef HAVE_WEBKIT2
1298static GHashTable* message_map = NULL;
1299void
1300midori_map_add_message (SoupMessage* message)
1301{
1302 SoupURI* uri = soup_message_get_uri (message);
1303 if (message_map == NULL)
1304 message_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
1305 g_return_if_fail (uri && uri->host);
1306 g_hash_table_insert (message_map, g_strdup (uri->host), g_object_ref (message));
1307}
1308
1309SoupMessage*
1310midori_map_get_message (SoupMessage* message)
1311{
1312 SoupURI* uri = soup_message_get_uri (message);
1313 SoupMessage* full;
1314 g_return_val_if_fail (uri && uri->host, message);
1315 if (message_map == NULL)
1316 message_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
1317 full = g_hash_table_lookup (message_map, uri->host);
1318 if (full != NULL)
1319 return full;
1320 return message;
1321}
1322#endif
1323
1324#ifdef HAVE_GCR1323#ifdef HAVE_GCR
1325typedef enum {1324typedef enum {
1326 MIDORI_CERT_TRUST,1325 MIDORI_CERT_TRUST,
@@ -1458,14 +1457,7 @@
14581457
1459 MidoriBrowser* browser = midori_browser_get_for_widget (widget);1458 MidoriBrowser* browser = midori_browser_get_for_widget (widget);
1460 MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));1459 MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));
1461 #ifdef HAVE_WEBKIT2
1462 void* request = NULL;1460 void* request = NULL;
1463 #else
1464 WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
1465 WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (web_view);
1466 WebKitWebDataSource* source = webkit_web_frame_get_data_source (web_frame);
1467 WebKitNetworkRequest* request = webkit_web_data_source_get_request (source);
1468 #endif
1469 midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname);1461 midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname);
1470 if (tls_cert == NULL)1462 if (tls_cert == NULL)
1471 {1463 {
@@ -1482,12 +1474,10 @@
1482 der_cert->data, der_cert->len);1474 der_cert->data, der_cert->len);
1483 g_byte_array_unref (der_cert);1475 g_byte_array_unref (der_cert);
14841476
1485 #if GTK_CHECK_VERSION (3, 0, 0)
1486 GtkWidget* details;1477 GtkWidget* details;
1487 details = (GtkWidget*)gcr_certificate_details_widget_new (gcr_cert);1478 details = (GtkWidget*)gcr_certificate_details_widget_new (gcr_cert);
1488 gtk_widget_show (details);1479 gtk_widget_show (details);
1489 gtk_container_add (GTK_CONTAINER (box), details);1480 gtk_container_add (GTK_CONTAINER (box), details);
1490 #endif
14911481
1492 #if GTK_CHECK_VERSION (3, 12, 0)1482 #if GTK_CHECK_VERSION (3, 12, 0)
1493 GtkWidget* button;1483 GtkWidget* button;
@@ -1527,10 +1517,6 @@
1527 g_object_set_data_full (G_OBJECT (dialog), "gcr-cert", gcr_cert, (GDestroyNotify)g_object_unref);1517 g_object_set_data_full (G_OBJECT (dialog), "gcr-cert", gcr_cert, (GDestroyNotify)g_object_unref);
1528 #endif1518 #endif
15291519
1530 /* With GTK+2 the scrolled contents can't communicate a natural size to the window */
1531 #if !GTK_CHECK_VERSION (3, 0, 0)
1532 gtk_window_set_default_size (GTK_WINDOW (dialog), 250, 200);
1533 #endif
1534 if (!g_tls_certificate_get_issuer (tls_cert))1520 if (!g_tls_certificate_get_issuer (tls_cert))
1535 gtk_box_pack_start (box, gtk_label_new (_("Self-signed")), FALSE, FALSE, 0);1521 gtk_box_pack_start (box, gtk_label_new (_("Self-signed")), FALSE, FALSE, 0);
15361522
15371523
=== modified file 'midori/midori-preferences.c'
--- midori/midori-preferences.c 2015-07-06 21:26:46 +0000
+++ midori/midori-preferences.c 2016-09-20 20:57:01 +0000
@@ -371,20 +371,6 @@
371 INDENTED_ADD (button);371 INDENTED_ADD (button);
372 button = katze_property_proxy (settings, "enable-webgl", NULL);372 button = katze_property_proxy (settings, "enable-webgl", NULL);
373 gtk_button_set_label (GTK_BUTTON (button), _("Enable WebGL support"));373 gtk_button_set_label (GTK_BUTTON (button), _("Enable WebGL support"));
374 #ifndef HAVE_WEBKIT2
375 if (parent && MIDORI_IS_BROWSER (parent))
376 {
377 GtkWidget* tab = midori_browser_get_current_tab (MIDORI_BROWSER (parent));
378 WebKitWebView* web_view = midori_tab_get_web_view (MIDORI_TAB (tab));
379 WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
380 JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
381 gchar* supports_web_gl = sokoke_js_script_eval (js_context,
382 "!!window.WebGLRenderingContext", NULL);
383 if (g_strcmp0 (supports_web_gl, "true"))
384 gtk_widget_hide (button);
385 g_free (supports_web_gl);
386 }
387 #endif
388 SPANNED_ADD (button);374 SPANNED_ADD (button);
389 button = katze_property_proxy (settings, "zoom-text-and-images", NULL);375 button = katze_property_proxy (settings, "zoom-text-and-images", NULL);
390 gtk_button_set_label (GTK_BUTTON (button), _("Zoom Text and Images"));376 gtk_button_set_label (GTK_BUTTON (button), _("Zoom Text and Images"));
@@ -522,21 +508,6 @@
522 g_signal_connect_object (settings, "notify::proxy-type",508 g_signal_connect_object (settings, "notify::proxy-type",
523 G_CALLBACK (midori_preferences_notify_proxy_type_cb), label, 0);509 G_CALLBACK (midori_preferences_notify_proxy_type_cb), label, 0);
524 midori_preferences_notify_proxy_type_cb (settings, NULL, label);510 midori_preferences_notify_proxy_type_cb (settings, NULL, label);
525#ifndef HAVE_WEBKIT2
526 if (soup_session_get_feature (webkit_get_default_session (), SOUP_TYPE_CACHE))
527 {
528 label = gtk_label_new (_("Web Cache"));
529 gtk_widget_set_tooltip_text (label, _("The maximum size of cached pages on disk"));
530 INDENTED_ADD (label);
531 button = katze_property_proxy (settings, "maximum-cache-size", NULL);
532 gtk_spin_button_set_range (GTK_SPIN_BUTTON (button), 0, G_MAXINT);
533 gtk_widget_set_tooltip_text (button, _("The maximum size of cached pages on disk"));
534 SPANNED_ADD (button);
535 label = gtk_label_new (_("MB"));
536 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
537 SPANNED_ADD (label);
538 }
539#endif
540 /* i18n: This refers to an application, not the 'user agent' string */511 /* i18n: This refers to an application, not the 'user agent' string */
541 label = gtk_label_new (_("Identify as"));512 label = gtk_label_new (_("Identify as"));
542 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);513 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
543514
=== modified file 'midori/midori-privatedata.c'
--- midori/midori-privatedata.c 2015-07-06 21:26:46 +0000
+++ midori/midori-privatedata.c 2016-09-20 20:57:01 +0000
@@ -281,28 +281,9 @@
281static void281static void
282midori_clear_web_cookies_cb (void)282midori_clear_web_cookies_cb (void)
283{283{
284#ifdef HAVE_WEBKIT2
285 WebKitWebContext* context = webkit_web_context_get_default ();284 WebKitWebContext* context = webkit_web_context_get_default ();
286 WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context);285 WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context);
287 webkit_cookie_manager_delete_all_cookies (cookie_manager);286 webkit_cookie_manager_delete_all_cookies (cookie_manager);
288 /* FIXME: site data policy */
289#else
290 SoupSession* session = webkit_get_default_session ();
291 MidoriWebSettings* settings = g_object_get_data (G_OBJECT (session), "midori-settings");
292 SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
293 GSList* cookies = soup_cookie_jar_all_cookies (SOUP_COOKIE_JAR (jar));
294
295 /* HTTP Cookies/ Web Cookies */
296 for (; cookies != NULL; cookies = g_slist_next (cookies))
297 {
298 const gchar* domain = ((SoupCookie*)cookies->data)->domain;
299 if (midori_web_settings_get_site_data_policy (settings, domain)
300 == MIDORI_SITE_DATA_PRESERVE)
301 continue;
302 soup_cookie_jar_delete_cookie ((SoupCookieJar*)jar, cookies->data);
303 }
304 soup_cookies_free (cookies);
305#endif
306287
307 /* Local shared objects/ Flash cookies */288 /* Local shared objects/ Flash cookies */
308 if (midori_web_settings_has_plugin_support ())289 if (midori_web_settings_has_plugin_support ())
@@ -324,17 +305,7 @@
324 #endif305 #endif
325 }306 }
326307
327#ifdef HAVE_WEBKIT2
328 /* TODO: clear databases and offline app caches */308 /* TODO: clear databases and offline app caches */
329#else
330 /* HTML5 databases */
331 webkit_remove_all_web_databases ();
332
333 /* HTML5 offline application caches */
334 /* Changing the size implies clearing the cache */
335 webkit_application_cache_set_maximum_size (
336 webkit_application_cache_get_maximum_size () - 1);
337#endif
338}309}
339310
340static void311static void
@@ -358,17 +329,7 @@
358static void329static void
359midori_clear_web_cache_cb (void)330midori_clear_web_cache_cb (void)
360{331{
361#ifdef HAVE_WEBKIT2
362 webkit_web_context_clear_cache (webkit_web_context_get_default ());332 webkit_web_context_clear_cache (webkit_web_context_get_default ());
363#else
364 SoupSession* session = webkit_get_default_session ();
365 SoupSessionFeature* feature = soup_session_get_feature (session, SOUP_TYPE_CACHE);
366 gchar* cache = g_build_filename (midori_paths_get_cache_dir (), "web", NULL);
367 soup_cache_clear (SOUP_CACHE (feature));
368 soup_cache_flush (SOUP_CACHE (feature));
369 midori_paths_remove_path (cache);
370 g_free (cache);
371#endif
372}333}
373334
374void335void
375336
=== modified file 'midori/midori-searchaction.c'
--- midori/midori-searchaction.c 2015-07-06 21:26:46 +0000
+++ midori/midori-searchaction.c 2016-09-20 20:57:01 +0000
@@ -914,125 +914,8 @@
914midori_search_action_get_engine_for_form (WebKitWebView* web_view,914midori_search_action_get_engine_for_form (WebKitWebView* web_view,
915 PangoEllipsizeMode ellipsize)915 PangoEllipsizeMode ellipsize)
916{916{
917#ifndef HAVE_WEBKIT2917 // TODO: Implement
918 WebKitWebFrame* focused_frame;
919 WebKitDOMDocument* doc;
920 WebKitDOMHTMLFormElement* active_form;
921 WebKitDOMHTMLCollection* form_nodes;
922 WebKitDOMElement* active_element;
923 gchar* token_element;
924 const gchar* title;
925 GString* uri_str;
926 gulong form_len;
927 const gchar* action;
928 guint i;
929 KatzeItem* item;
930 gchar** parts;
931
932 focused_frame = webkit_web_view_get_focused_frame (web_view);
933 if (focused_frame == NULL)
934 return NULL;
935 #if WEBKIT_CHECK_VERSION (1, 9, 5)
936 doc = webkit_web_frame_get_dom_document (focused_frame);
937 #else
938 if (focused_frame != webkit_web_view_get_main_frame (web_view))
939 return NULL;
940 doc = webkit_web_view_get_dom_document (web_view);
941 #endif
942
943 active_element = webkit_dom_html_document_get_active_element ((WebKitDOMHTMLDocument*)doc);
944 if (!WEBKIT_DOM_IS_HTML_INPUT_ELEMENT (active_element))
945 return NULL;
946
947 active_form = webkit_dom_html_input_element_get_form ((WebKitDOMHTMLInputElement*)active_element);
948 if (!active_form)
949 return NULL;
950
951 token_element = webkit_dom_element_get_attribute (active_element, "name");
952
953 form_nodes = webkit_dom_html_form_element_get_elements (active_form);
954 form_len = webkit_dom_html_form_element_get_length (active_form);
955
956 /* action NULL or "": relative path */
957 if ((action = webkit_dom_html_form_element_get_action (active_form)) && *action)
958 uri_str = g_string_new (action);
959 else
960 {
961 gchar* hostname = midori_uri_parse_hostname (webkit_web_view_get_uri (web_view), NULL);
962 uri_str = g_string_new ("http://");
963 g_string_append (uri_str, hostname);
964 g_free (hostname);
965 }
966 g_string_append_c (uri_str, '?');
967
968 for (i = 0; i < form_len; i++)
969 {
970 WebKitDOMNode* form_node = webkit_dom_html_collection_item (form_nodes, i);
971 WebKitDOMElement* form_element = (WebKitDOMElement*) form_node;
972 gchar* name = webkit_dom_element_get_attribute (form_element, "name");
973
974 if (name && *name)
975 {
976 if (!g_strcmp0 (token_element, name))
977 g_string_append_printf (uri_str, "%s=%s&", name, "\%s");
978 else
979 {
980 gchar* value;
981 if (!g_strcmp0 (webkit_dom_element_get_tag_name (form_element), "SELECT"))
982 {
983 WebKitDOMHTMLSelectElement* select_element = (WebKitDOMHTMLSelectElement*) form_element;
984 gulong pos = webkit_dom_html_select_element_get_selected_index (select_element);
985 WebKitDOMNode* selected_node = webkit_dom_html_select_element_item (select_element, pos);
986 WebKitDOMElement* selected_element = (WebKitDOMElement*) selected_node;
987
988 value = webkit_dom_element_get_attribute (selected_element, "value");
989 }
990 else
991 value = webkit_dom_element_get_attribute (form_element, "value");
992
993 g_string_append_printf (uri_str, "%s=%s&", name, value);
994 g_free (value);
995 }
996 g_free (name);
997 }
998 }
999
1000 if (!(title = webkit_web_view_get_title (web_view)))
1001 title = webkit_web_view_get_uri (web_view);
1002
1003 item = katze_item_new ();
1004 item->uri = g_string_free (uri_str, FALSE);
1005 item->token = midori_search_action_token_for_uri (webkit_web_view_get_uri (web_view));
1006
1007 if (strstr (title, " - "))
1008 parts = g_strsplit (title, " - ", 2);
1009 else if (strstr (title, ": "))
1010 parts = g_strsplit (title, ": ", 2);
1011 else
1012 parts = NULL;
1013 if (parts != NULL)
1014 {
1015 /* See midori_view_set_title: title can be first or last */
1016 if (ellipsize == PANGO_ELLIPSIZE_END)
1017 {
1018 katze_item_set_name (item, parts[0]);
1019 katze_item_set_text (item, parts[1]);
1020 }
1021 else
1022 {
1023 katze_item_set_name (item, parts[1]);
1024 katze_item_set_text (item, parts[2]);
1025 }
1026 g_strfreev (parts);
1027 }
1028 else
1029 katze_item_set_name (item, title);
1030
1031 g_free (token_element);
1032 return item;
1033 #else
1034 return NULL;918 return NULL;
1035 #endif
1036}919}
1037920
1038void921void
1039922
=== modified file 'midori/midori-session.c'
--- midori/midori-session.c 2015-03-23 11:33:24 +0000
+++ midori/midori-session.c 2016-09-20 20:57:01 +0000
@@ -17,300 +17,34 @@
17#include "sokoke.h"17#include "sokoke.h"
1818
19#include <glib/gi18n-lib.h>19#include <glib/gi18n-lib.h>
20#include <libsoup/soup-cookie-jar-sqlite.h>20#include <libsoup/soup-cookie-jar-db.h>
21#include <libsoup/soup-gnome-features.h>21#define LIBSOUP_USE_UNSTABLE_REQUEST_API
2222#include <libsoup/soup-cache.h>
23 #define LIBSOUP_USE_UNSTABLE_REQUEST_API23
24 #include <libsoup/soup-cache.h>
25
26#ifndef HAVE_WEBKIT2
27static void
28midori_soup_session_set_proxy_uri (SoupSession* session,
29 const gchar* uri)
30{
31 SoupURI* proxy_uri;
32
33 /* soup_uri_new expects a non-NULL string with a protocol */
34 gchar* scheme = uri ? g_uri_parse_scheme (uri): NULL;
35 if (scheme)
36 {
37 proxy_uri = soup_uri_new (uri);
38 g_free (scheme);
39 }
40 else if (uri && *uri)
41 {
42 gchar* fixed_uri = g_strconcat ("http://", uri, NULL);
43 proxy_uri = soup_uri_new (fixed_uri);
44 g_free (fixed_uri);
45 }
46 else
47 proxy_uri = NULL;
48 g_object_set (session, "proxy-uri", proxy_uri, NULL);
49 if (proxy_uri)
50 soup_uri_free (proxy_uri);
51}
52
53static void
54soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
55 GParamSpec* pspec,
56 SoupSession* session)
57{
58 gboolean uses_proxy = TRUE;
59 MidoriProxy proxy_type = katze_object_get_enum (settings, "proxy-type");
60 if (proxy_type == MIDORI_PROXY_AUTOMATIC)
61 {
62 soup_session_add_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME);
63
64 GProxyResolver* resolver = g_proxy_resolver_get_default ();
65 gchar** proxies = g_proxy_resolver_lookup (resolver, "none", NULL, NULL);
66
67 if (!proxies || !g_strcmp0 (proxies[0], "direct://"))
68 uses_proxy = FALSE;
69 g_strfreev (proxies);
70 }
71 else if (proxy_type == MIDORI_PROXY_HTTP)
72 {
73 soup_session_remove_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME);
74 gchar* proxy = katze_object_get_string (settings, "http-proxy");
75 GString* http_proxy = g_string_new (proxy);
76 g_string_append_printf (http_proxy, ":%d", katze_object_get_int (settings, "http-proxy-port"));
77 midori_soup_session_set_proxy_uri (session, http_proxy->str);
78 g_string_free (http_proxy, TRUE);
79 g_free (proxy);
80 }
81 else
82 {
83 uses_proxy = FALSE;
84 soup_session_remove_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME);
85 midori_soup_session_set_proxy_uri (session, NULL);
86 }
87
88 /* If a proxy server looks to be active, we disable prefetching, otherwise
89 libSoup may be prefetching outside the proxy server beyond our control.
90 */
91
92 if (uses_proxy)
93 g_object_set (settings, "enable-dns-prefetching", FALSE, NULL);
94}
95#endif
96
97#if WEBKIT_CHECK_VERSION (1, 1, 21)
98static void24static void
99soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings,25soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings,
100 GParamSpec* pspec,26 GParamSpec* pspec,
101 gpointer user_data)27 gpointer user_data)
102{28{
103 gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only");29 gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only");
104#ifdef HAVE_WEBKIT2
105 WebKitWebContext* context = webkit_web_context_get_default ();30 WebKitWebContext* context = webkit_web_context_get_default ();
106 WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context);31 WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context);
107 webkit_cookie_manager_set_accept_policy (cookie_manager,32 webkit_cookie_manager_set_accept_policy (cookie_manager,
108 yes ? WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY33 yes ? WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY
109 : WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);34 : WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
110#else35}
111 SoupSession* session = webkit_get_default_session ();
112 gpointer jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
113 g_object_set (jar, "accept-policy",
114 yes ? SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
115 : SOUP_COOKIE_JAR_ACCEPT_ALWAYS, NULL);
116#endif
117}
118#endif
119
120#if !defined (HAVE_WEBKIT2)
121/* Implemented in MidoriLocationAction */
122void
123midori_map_add_message (SoupMessage* message);
124
125static void
126midori_soup_session_request_started_cb (SoupSession* session,
127 SoupMessage* message,
128 SoupSocket* socket,
129 gpointer user_data)
130{
131 midori_map_add_message (message);
132}
133#endif
134
135#ifndef HAVE_WEBKIT2
136const gchar*
137midori_web_settings_get_accept_language (MidoriWebSettings* settings);
138
139static void
140midori_soup_session_settings_accept_language_cb (SoupSession* session,
141 SoupMessage* msg,
142 MidoriWebSettings* settings)
143{
144 const gchar* accept = midori_web_settings_get_accept_language (settings);
145 soup_message_headers_append (msg->request_headers, "Accept-Language", accept);
146
147 if (katze_object_get_boolean (settings, "strip-referer"))
148 {
149 const gchar* referer
150 = soup_message_headers_get_one (msg->request_headers, "Referer");
151 SoupURI* destination = soup_message_get_uri (msg);
152 SoupURI* stripped_uri;
153 if (referer && destination && !strstr (referer, destination->host)
154 && (stripped_uri = soup_uri_new (referer)))
155 {
156 gchar* stripped_referer;
157 soup_uri_set_path (stripped_uri, "");
158 soup_uri_set_query (stripped_uri, NULL);
159 stripped_referer = soup_uri_to_string (stripped_uri, FALSE);
160 soup_uri_free (stripped_uri);
161 if (strcmp (stripped_referer, referer))
162 {
163 if (midori_debug ("referer"))
164 g_message ("Referer '%s' stripped to '%s'", referer, stripped_referer);
165 soup_message_headers_replace (msg->request_headers, "Referer",
166 stripped_referer);
167 }
168 g_free (stripped_referer);
169 }
170
171 /* With HTTP, Host is optional. Strip to outsmart some filter proxies */
172 if (destination && destination->scheme == SOUP_URI_SCHEME_HTTP)
173 soup_message_headers_remove (msg->request_headers, "Host");
174 }
175}
176#endif
17736
178gboolean37gboolean
179midori_load_soup_session (gpointer settings)38midori_load_soup_session (gpointer settings)
180{39{
181 #if WEBKIT_CHECK_VERSION (1, 1, 21)
182 g_signal_connect (settings, "notify::first-party-cookies-only",40 g_signal_connect (settings, "notify::first-party-cookies-only",
183 G_CALLBACK (soup_session_settings_notify_first_party_cb), NULL);41 G_CALLBACK (soup_session_settings_notify_first_party_cb), NULL);
184 #endif
185
186#ifndef HAVE_WEBKIT2
187 SoupSession* session = webkit_get_default_session ();
188
189 #ifndef G_OS_WIN32
190 g_object_set (session,
191 "ssl-use-system-ca-file", TRUE,
192 "ssl-strict", FALSE,
193 NULL);
194 #else /* G_OS_WIN32 */
195 /* We cannot use "ssl-use-system-ca-file" on Windows
196 * some GTLS backend pieces are missing currently.
197 * Instead we specify the bundle we ship ourselves */
198 gchar* certificate_file = midori_paths_get_res_filename ("ca-bundle.crt");
199 g_object_set (session,
200 "ssl-ca-file", certificate_file,
201 "ssl-strict", FALSE,
202 NULL);
203 g_free (certificate_file);
204 #endif
205
206 g_object_set_data (G_OBJECT (session), "midori-settings", settings);
207 soup_session_settings_notify_http_proxy_cb (settings, NULL, session);
208 g_signal_connect (settings, "notify::http-proxy",
209 G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
210 g_signal_connect (settings, "notify::proxy-type",
211 G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
212
213 g_signal_connect (session, "request-started",
214 G_CALLBACK (midori_soup_session_request_started_cb), session);
215 g_signal_connect (session, "request-queued",
216 G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
217
218 soup_session_add_feature (session, SOUP_SESSION_FEATURE (midori_hsts_new ()));
219
220 if (midori_debug ("headers"))
221 {
222 SoupLogger* logger = soup_logger_new (SOUP_LOGGER_LOG_HEADERS, -1);
223 soup_logger_attach (logger, session);
224 g_object_unref (logger);
225 }
226 else if (midori_debug ("body"))
227 {
228 SoupLogger* logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
229 soup_logger_attach (logger, session);
230 g_object_unref (logger);
231 }
232
233 g_object_set_data (G_OBJECT (session), "midori-session-initialized", (void*)1);
234#endif
235 return FALSE;42 return FALSE;
236}43}
23744
238#ifndef HAVE_WEBKIT2
239static void
240midori_session_cookie_jar_changed_cb (SoupCookieJar* jar,
241 SoupCookie* old_cookie,
242 SoupCookie* new_cookie,
243 MidoriWebSettings* settings)
244{
245
246 if (midori_debug ("cookies"))
247 {
248 gchar* old = old_cookie ? soup_cookie_to_cookie_header (old_cookie) : NULL;
249 gchar* new = new_cookie ? soup_cookie_to_cookie_header (new_cookie) : NULL;
250 g_print ("cookie changed from %s to %s\n", old, new);
251 g_free (old);
252 g_free (new);
253 }
254
255 /* Don't allow revival of expiring cookies */
256 if (new_cookie && old_cookie && old_cookie->expires)
257 soup_cookie_set_expires (new_cookie, old_cookie->expires);
258
259 if (new_cookie && new_cookie->expires)
260 {
261 time_t expires = soup_date_to_time_t (new_cookie->expires);
262 gint age = katze_object_get_int (settings, "maximum-cookie-age");
263 /* An age of 0 to SoupCookie means already-expired
264 A user choosing 0 days probably expects 1 hour.
265 */
266 int seconds = age > 0 ? age * SOUP_COOKIE_MAX_AGE_ONE_DAY : SOUP_COOKIE_MAX_AGE_ONE_HOUR;
267 SoupDate* max_date = soup_date_new_from_now (seconds);
268 if (expires > soup_date_to_time_t (max_date))
269 {
270 if (midori_debug ("cookies"))
271 {
272 gchar* new_date = soup_date_to_string (max_date, SOUP_DATE_COOKIE);
273 g_print ("^^ enforcing expiry: %s\n", new_date);
274 g_free (new_date);
275 }
276 soup_cookie_set_expires (new_cookie, max_date);
277 }
278 soup_date_free (max_date);
279 }
280}
281#endif
282
283gboolean45gboolean
284midori_load_soup_session_full (gpointer settings)46midori_load_soup_session_full (gpointer settings)
285{47{
286 #ifndef HAVE_WEBKIT2
287 SoupSession* session = webkit_get_default_session ();
288 SoupCookieJar* jar;
289 gchar* config_file;
290 SoupSessionFeature* feature;
291
292 midori_load_soup_session (settings);
293
294 config_file = midori_paths_get_config_filename_for_writing ("logins");
295 feature = g_object_new (KATZE_TYPE_HTTP_AUTH, "filename", config_file, NULL);
296 soup_session_add_feature (session, feature);
297 g_object_unref (feature);
298
299 katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.db"));
300 jar = soup_cookie_jar_sqlite_new (config_file, FALSE);
301 soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar));
302 g_signal_connect (jar, "changed",
303 G_CALLBACK (midori_session_cookie_jar_changed_cb), settings);
304 g_object_unref (jar);
305
306 katze_assign (config_file, g_build_filename (midori_paths_get_cache_dir (), "web", NULL));
307 feature = SOUP_SESSION_FEATURE (soup_cache_new (config_file, 0));
308 soup_session_add_feature (session, feature);
309 soup_cache_set_max_size (SOUP_CACHE (feature),
310 katze_object_get_int (settings, "maximum-cache-size") * 1024 * 1024);
311 soup_cache_load (SOUP_CACHE (feature));
312 g_free (config_file);
313 #endif
314 return FALSE;48 return FALSE;
315}49}
31650
31751
=== modified file 'midori/midori-settings.vala'
--- midori/midori-settings.vala 2013-11-24 21:50:38 +0000
+++ midori/midori-settings.vala 2016-09-20 20:57:01 +0000
@@ -19,23 +19,6 @@
19 FULLSCREEN19 FULLSCREEN
20 }20 }
21 /* Since: 0.1.3 */21 /* Since: 0.1.3 */
22#if !HAVE_WEBKIT2
23 public class Settings : WebKit.WebSettings {
24 /* Since: 0.5.0 */
25 public bool enable_javascript { get {
26 return enable_scripts;
27 } set {
28 enable_scripts = value;
29 } }
30 /* Since: 0.5.1 */
31 public string default_charset { owned get {
32 return default_encoding;
33 } set {
34 default_encoding = value;
35 } }
36 /* Since: 0.1.3 */
37 public bool zoom_text_and_images { get; set; default = true; }
38#else
39 public class Settings : WebKit.Settings {22 public class Settings : WebKit.Settings {
40 public bool zoom_text_and_images { get {23 public bool zoom_text_and_images { get {
41 return !zoom_text_only;24 return !zoom_text_only;
@@ -47,7 +30,6 @@
47 } set {30 } set {
48 WebKit.WebContext.get_default ().set_spell_checking_enabled (value);31 WebKit.WebContext.get_default ().set_spell_checking_enabled (value);
49 } }32 } }
50#endif
51 public bool remember_last_window_size { get; set; default = true; }33 public bool remember_last_window_size { get; set; default = true; }
52 public int last_window_width { get; set; default = 0; }34 public int last_window_width { get; set; default = 0; }
53 public int last_window_height { get; set; default = 0; }35 public int last_window_height { get; set; default = 0; }
@@ -62,6 +44,9 @@
62 /* Since: 0.1.3 */44 /* Since: 0.1.3 */
63 public WindowState last_window_state { get; set; default = WindowState.NORMAL; }45 public WindowState last_window_state { get; set; default = WindowState.NORMAL; }
6446
47 GLib.HashTable<string, WebKit.UserStyleSheet> user_stylesheets;
48 public WebKit.UserContentManager user_content_manager { get; private set; default = new WebKit.UserContentManager(); }
49
65 /* Since: 0.4.8 */50 /* Since: 0.4.8 */
66 public uint inactivity_reset { get; set; default = 0; }51 public uint inactivity_reset { get; set; default = 0; }
6752
@@ -90,21 +75,7 @@
90 public string? block_uris { get {75 public string? block_uris { get {
91 return block_uris_regex != null ? block_uris_regex.get_pattern () : null;76 return block_uris_regex != null ? block_uris_regex.get_pattern () : null;
92 } set {77 } set {
93#if !HAVE_WEBKIT278 // TODO: Implement
94 if (value == null || value == "")
95 return;
96 if (block_uris_regex == null)
97 WebKit.get_default_session ().request_queued.connect ((msg) => {
98 if (block_uris_regex.match (msg.uri.to_string (false)))
99 msg.uri = new Soup.URI ("http://.invalid");
100 });
101 try {
102 block_uris_regex = new GLib.Regex (value);
103 }
104 catch (Error error) {
105 critical ("block-uris: %s", error.message);
106 }
107#endif
108 } }79 } }
10980
110 /**81 /**
@@ -189,5 +160,37 @@
189 || property == "user-stylesheet-uri"160 || property == "user-stylesheet-uri"
190 || property.has_suffix ("-width");161 || property.has_suffix ("-width");
191 }162 }
163
164 /* Adds a stylesheet to midori settings. Since: 0.5.12 */
165 public void add_style (string rule_id, string style)
166 {
167 if (user_stylesheets == null)
168 user_stylesheets = new GLib.HashTable<string, WebKit.UserStyleSheet>(str_hash, str_equal);
169
170 var ss = new WebKit.UserStyleSheet(style,
171 WebKit.UserContentInjectedFrames.ALL_FRAMES,
172 WebKit.UserStyleLevel.USER,
173 null, null);
174 user_stylesheets[rule_id]=ss;
175 user_content_manager.add_style_sheet (ss);
176 }
177
178 /* Removes a stylesheet from midori settings. Since: 0.5.12 */
179 public void remove_style (string rule_id)
180 {
181 if (user_stylesheets != null)
182 {
183 if (user_stylesheets.contains (rule_id))
184 {
185 user_stylesheets.remove (rule_id);
186
187 /* the API is rather silly: we have to remove all sheets and re-add all others */
188 user_content_manager.remove_all_style_sheets ();
189 user_stylesheets.foreach((key, ss) => {
190 user_content_manager.add_style_sheet (ss);
191 });
192 }
193 }
194 }
192 }195 }
193}196}
194197
=== modified file 'midori/midori-speeddial.vala'
--- midori/midori-speeddial.vala 2015-06-11 22:33:48 +0000
+++ midori/midori-speeddial.vala 2016-09-20 20:57:01 +0000
@@ -32,10 +32,6 @@
32 string filename;32 string filename;
33 string? html = null;33 string? html = null;
34 List<Spec> thumb_queue = null;34 List<Spec> thumb_queue = null;
35#if !HAVE_WEBKIT2
36 WebKit.WebView thumb_view = null;
37 Spec? spec = null;
38#endif
3935
40 public GLib.KeyFile keyfile;36 public GLib.KeyFile keyfile;
41 public bool close_buttons_left { get; set; default = false; }37 public bool close_buttons_left { get; set; default = false; }
@@ -340,86 +336,7 @@
340 refresh ();336 refresh ();
341 }337 }
342338
343#if !HAVE_WEBKIT2
344 void load_status (GLib.Object thumb_view_, ParamSpec pspec) {
345 if (thumb_view.load_status != WebKit.LoadStatus.FINISHED
346 && thumb_view.load_status != WebKit.LoadStatus.FAILED)
347 return;
348 thumb_view.notify["load-status"].disconnect (load_status);
349 /* Schedule an idle to give the offscreen time to draw */
350 Idle.add (save_thumbnail);
351 }
352#endif
353
354#if !HAVE_WEBKIT2
355 bool save_thumbnail () {
356 return_val_if_fail (spec != null, false);
357
358 var offscreen = (thumb_view.parent as Gtk.OffscreenWindow);
359 var pixbuf = offscreen.get_pixbuf ();
360 int image_width = pixbuf.get_width (), image_height = pixbuf.get_height ();
361 int thumb_width = 240, thumb_height = 160;
362 float image_ratio = image_width / image_height;
363 float thumb_ratio = thumb_width / thumb_height;
364 int x_offset, y_offset, computed_width, computed_height;
365 if (image_ratio > thumb_ratio) {
366 computed_width = (int)(image_height * thumb_ratio);
367 computed_height = image_height;
368 x_offset = (image_width - computed_width) / 2;
369 y_offset = 0;
370 }
371 else {
372 computed_width = image_width;
373 computed_height = (int)(image_width / thumb_ratio);
374 x_offset = 0;
375 y_offset = 0;
376 }
377 var sub = pixbuf;
378 if (y_offset + computed_height <= image_height)
379 sub = new Gdk.Pixbuf.subpixbuf (pixbuf, x_offset, y_offset, computed_width, computed_height);
380 var scaled = sub.scale_simple (thumb_width, thumb_height, Gdk.InterpType.TILES);
381 add_with_id (spec.dial_id, spec.uri, thumb_view.get_title () ?? spec.uri, scaled);
382
383 thumb_queue.remove (spec);
384 if (thumb_queue.length () > 0) {
385 spec = thumb_queue.nth_data (0);
386 thumb_view.notify["load-status"].connect (load_status);
387 thumb_view.load_uri (spec.uri);
388 }
389 return false;
390 }
391#endif
392
393 void get_thumb (string dial_id, string uri) {339 void get_thumb (string dial_id, string uri) {
394#if !HAVE_WEBKIT2
395 if (thumb_view == null) {
396 thumb_view = new WebKit.WebView ();
397 thumb_view.settings.set (
398 "enable-scripts", false,
399 "enable-plugins", false,
400 "auto-load-images", true,
401 "enable-html5-database", false,
402 "enable-html5-local-storage", false,
403 "enable-java-applet", false);
404 var offscreen = new Gtk.OffscreenWindow ();
405 offscreen.add (thumb_view);
406 thumb_view.set_size_request (800, 600);
407 offscreen.show_all ();
408 }
409
410 /* Don't load thumbnails already queued */
411 foreach (var spec_ in thumb_queue)
412 if (spec_.dial_id == dial_id)
413 return;
414
415 thumb_queue.append (new Spec (dial_id, uri));
416 if (thumb_queue.length () > 1)
417 return;
418
419 spec = thumb_queue.nth_data (0);
420 thumb_view.notify["load-status"].connect (load_status);
421 thumb_view.load_uri (spec.uri);
422#endif
423 }340 }
424 }341 }
425}342}
426343
=== modified file 'midori/midori-tab.vala'
--- midori/midori-tab.vala 2015-04-19 14:06:12 +0000
+++ midori/midori-tab.vala 2016-09-20 20:57:01 +0000
@@ -44,6 +44,7 @@
4444
45 public class Tab : Gtk.VBox {45 public class Tab : Gtk.VBox {
46 public Tab related { get; set construct; }46 public Tab related { get; set construct; }
47 public WebKit.UserContentManager user_content_manager { private get; set construct; }
47 public WebKit.WebView web_view { get; private set; }48 public WebKit.WebView web_view { get; private set; }
4849
49 private string current_uri = "about:blank";50 private string current_uri = "about:blank";
@@ -133,30 +134,13 @@
133 orientation = Gtk.Orientation.VERTICAL;134 orientation = Gtk.Orientation.VERTICAL;
134 #endif135 #endif
135136
136#if HAVE_WEBKIT2_3_91137 if (related != null)
137 web_view = related != null ?138 web_view = (WebKit.WebView)GLib.Object.new(typeof (WebKit.WebView), "user-content-manager", user_content_manager, "related-view", related.web_view);
138 new WebKit.WebView.with_related_view (related.web_view) : new WebKit.WebView ();139 else
139#else140 web_view = (WebKit.WebView)GLib.Object.new(typeof (WebKit.WebView), "user-content-manager", user_content_manager);
140 web_view = new WebKit.WebView ();
141#endif
142 /* Load something to avoid a bug where WebKit might not set a main frame */
143 web_view.load_uri ("");
144 }141 }
145142
146 public void inject_stylesheet (string stylesheet) {143 public void inject_stylesheet (string stylesheet) {
147#if !HAVE_WEBKIT2
148 var dom = web_view.get_dom_document ();
149 return_if_fail (dom.head != null);
150 try {
151 var style = dom.create_element ("style");
152 style.set_attribute ("type", "text/css");
153 style.append_child (dom.create_text_node (stylesheet));
154 dom.head.append_child (style);
155 }
156 catch (Error error) {
157 critical (_("Failed to inject stylesheet: %s"), error.message);
158 }
159#endif
160 }144 }
161145
162 /* Since: 0.5.1146 /* Since: 0.5.1
@@ -219,10 +203,6 @@
219 return false;203 return false;
220 if (view_source)204 if (view_source)
221 return false;205 return false;
222#if !HAVE_WEBKIT2
223 if (web_view.get_main_frame ().get_data_source ().get_data () == null)
224 return false;
225#endif
226 return true;206 return true;
227 }207 }
228208
@@ -239,13 +219,9 @@
239 }219 }
240220
241 public void unmark_text_matches () {221 public void unmark_text_matches () {
242#if !HAVE_WEBKIT2
243 web_view.unmark_text_matches ();
244#endif
245 }222 }
246223
247 public bool find (string text, bool case_sensitive, bool forward) {224 public bool find (string text, bool case_sensitive, bool forward) {
248#if HAVE_WEBKIT2
249 var controller = web_view.get_find_controller ();225 var controller = web_view.get_find_controller ();
250 uint options = WebKit.FindOptions.WRAP_AROUND;226 uint options = WebKit.FindOptions.WRAP_AROUND;
251 if (!case_sensitive)227 if (!case_sensitive)
@@ -255,13 +231,6 @@
255 controller.search (text, options, 0);231 controller.search (text, options, 0);
256 // FIXME: mark matches, count matches, not found232 // FIXME: mark matches, count matches, not found
257 return true;233 return true;
258#else
259 bool found = false;
260 found = web_view.search_text (text, case_sensitive, forward, true);
261 web_view.mark_text_matches (text, case_sensitive, 0);
262 web_view.set_highlight_text_matches (true);
263 return found;
264#endif
265 }234 }
266235
267 /*236 /*
@@ -270,7 +239,6 @@
270 Since: 0.5.8239 Since: 0.5.8
271 */240 */
272 public async void update_actions (Gtk.ActionGroup actions) {241 public async void update_actions (Gtk.ActionGroup actions) {
273#if HAVE_WEBKIT2
274 try {242 try {
275 actions.get_action ("Undo").sensitive = yield web_view.can_execute_editing_command ("Undo", null);243 actions.get_action ("Undo").sensitive = yield web_view.can_execute_editing_command ("Undo", null);
276 actions.get_action ("Redo").sensitive = yield web_view.can_execute_editing_command ("Redo", null);244 actions.get_action ("Redo").sensitive = yield web_view.can_execute_editing_command ("Redo", null);
@@ -282,15 +250,6 @@
282 } catch (Error error) {250 } catch (Error error) {
283 critical ("Failed to update actions: %s", error.message);251 critical ("Failed to update actions: %s", error.message);
284 }252 }
285#else
286 actions.get_action ("Undo").sensitive = web_view.can_undo ();
287 actions.get_action ("Redo").sensitive = web_view.can_redo ();
288 actions.get_action ("Cut").sensitive = web_view.can_cut_clipboard ();
289 actions.get_action ("Copy").sensitive = web_view.can_copy_clipboard ();
290 actions.get_action ("Paste").sensitive = web_view.can_paste_clipboard ();
291 actions.get_action ("Delete").sensitive = web_view.can_cut_clipboard ();
292 actions.get_action ("SelectAll").sensitive = true;
293#endif
294 }253 }
295 }254 }
296}255}
297256
=== modified file 'midori/midori-view.c'
--- midori/midori-view.c 2016-02-28 00:07:54 +0000
+++ midori/midori-view.c 2016-09-20 20:57:01 +0000
@@ -27,11 +27,6 @@
27 #include <gcr/gcr.h>27 #include <gcr/gcr.h>
28#endif28#endif
2929
30#if !defined (HAVE_WEBKIT2)
31SoupMessage*
32midori_map_get_message (SoupMessage* message);
33#endif
34
35#include <string.h>30#include <string.h>
36#include <stdlib.h>31#include <stdlib.h>
37#include <glib/gi18n.h>32#include <glib/gi18n.h>
@@ -61,7 +56,6 @@
61_midori_view_set_settings (MidoriView* view,56_midori_view_set_settings (MidoriView* view,
62 MidoriWebSettings* settings);57 MidoriWebSettings* settings);
6358
64#ifdef HAVE_WEBKIT2
65static void59static void
66midori_view_uri_scheme_res (WebKitURISchemeRequest* request,60midori_view_uri_scheme_res (WebKitURISchemeRequest* request,
67 gpointer user_data);61 gpointer user_data);
@@ -74,7 +68,6 @@
74midori_view_download_query_action (MidoriView* view,68midori_view_download_query_action (MidoriView* view,
75 WebKitDownload* download,69 WebKitDownload* download,
76 const gchar * suggested_filename );70 const gchar * suggested_filename );
77#endif
7871
79static gboolean72static gboolean
80midori_view_display_error (MidoriView* view,73midori_view_display_error (MidoriView* view,
@@ -85,11 +78,7 @@
85 const gchar* description,78 const gchar* description,
86 const gchar* suggestions,79 const gchar* suggestions,
87 const gchar* try_again,80 const gchar* try_again,
88#ifndef HAVE_WEBKIT2
89 WebKitWebFrame* web_frame);
90#else
91 void* web_frame);81 void* web_frame);
92#endif
9382
94struct _MidoriView83struct _MidoriView
95{84{
@@ -496,7 +485,6 @@
496_midori_web_view_load_icon (MidoriView* view)485_midori_web_view_load_icon (MidoriView* view)
497{486{
498 GdkPixbuf* pixbuf = NULL;487 GdkPixbuf* pixbuf = NULL;
499 #ifdef HAVE_WEBKIT2
500 cairo_surface_t* surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (view->web_view));488 cairo_surface_t* surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (view->web_view));
501 if (surface != NULL489 if (surface != NULL
502 && (pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,490 && (pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,
@@ -505,11 +493,6 @@
505 {493 {
506 midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);494 midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);
507 }495 }
508 #else
509 if ((pixbuf = webkit_web_view_try_get_favicon_pixbuf (
510 WEBKIT_WEB_VIEW (view->web_view), 0, 0)))
511 midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);
512 #endif
513}496}
514497
515static void498static void
@@ -537,45 +520,20 @@
537 GTlsCertificateFlags* tls_flags,520 GTlsCertificateFlags* tls_flags,
538 gchar** hostname)521 gchar** hostname)
539{522{
540 #ifdef HAVE_WEBKIT2
541 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);523 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
542 *hostname = midori_uri_parse_hostname (webkit_web_view_get_uri (web_view), NULL);524 *hostname = midori_uri_parse_hostname (webkit_web_view_get_uri (web_view), NULL);
543 gboolean success = webkit_web_view_get_tls_info (web_view, tls_cert, tls_flags);525 gboolean success = webkit_web_view_get_tls_info (web_view, tls_cert, tls_flags);
544 if (*tls_cert != NULL)526 if (*tls_cert != NULL)
545 g_object_ref (*tls_cert);527 g_object_ref (*tls_cert);
546 return success && *tls_flags == 0;528 return success && *tls_flags == 0;
547 #else
548 SoupMessage* message = midori_map_get_message (webkit_network_request_get_message (request));
549 if (message != NULL)
550 {
551 SoupURI* uri = soup_message_get_uri (message);
552 *hostname = uri ? g_strdup (uri->host) : NULL;
553 g_object_get (message, "tls-certificate", tls_cert, "tls-errors", tls_flags, NULL);
554 if (soup_message_get_flags (message) & SOUP_MESSAGE_CERTIFICATE_TRUSTED)
555 return TRUE;
556 return *tls_flags == 0;
557 }
558 *tls_cert = NULL;
559 *tls_flags = 0;
560 *hostname = NULL;
561 return FALSE;
562 #endif
563}529}
564530
565static gboolean531static gboolean
566midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view,532midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view,
567 #ifdef HAVE_WEBKIT2
568 WebKitPolicyDecision* decision,533 WebKitPolicyDecision* decision,
569 WebKitPolicyDecisionType decision_type,534 WebKitPolicyDecisionType decision_type,
570 #else
571 WebKitWebFrame* web_frame,
572 WebKitNetworkRequest* request,
573 WebKitWebNavigationAction* action,
574 WebKitWebPolicyDecision* decision,
575 #endif
576 MidoriView* view)535 MidoriView* view)
577{536{
578 #ifdef HAVE_WEBKIT2
579 if (decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE)537 if (decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE)
580 {538 {
581 WebKitURIResponse* response = webkit_response_policy_decision_get_response (539 WebKitURIResponse* response = webkit_response_policy_decision_get_response (
@@ -610,9 +568,6 @@
610568
611 WebKitURIRequest * request = webkit_navigation_policy_decision_get_request (WEBKIT_NAVIGATION_POLICY_DECISION (decision));569 WebKitURIRequest * request = webkit_navigation_policy_decision_get_request (WEBKIT_NAVIGATION_POLICY_DECISION (decision));
612 const gchar* uri = webkit_uri_request_get_uri (request);570 const gchar* uri = webkit_uri_request_get_uri (request);
613 #else
614 const gchar* uri = webkit_network_request_get_uri (request);
615 #endif
616 if (g_str_has_prefix (uri, "geo:") && strstr (uri, ","))571 if (g_str_has_prefix (uri, "geo:") && strstr (uri, ","))
617 {572 {
618 gchar* new_uri = sokoke_magic_uri (uri, TRUE, FALSE);573 gchar* new_uri = sokoke_magic_uri (uri, TRUE, FALSE);
@@ -624,42 +579,34 @@
624 {579 {
625 /* For security reasons, main content served as data: is limited to images580 /* For security reasons, main content served as data: is limited to images
626 http://lcamtuf.coredump.cx/switch/ */581 http://lcamtuf.coredump.cx/switch/ */
627 #ifdef HAVE_WEBKIT2
628 webkit_policy_decision_ignore (decision);582 webkit_policy_decision_ignore (decision);
629 #else
630 webkit_web_policy_decision_ignore (decision);
631 #endif
632 return TRUE;583 return TRUE;
633 }584 }
634 #ifdef HAVE_GCR585 else if (midori_tab_get_special (MIDORI_TAB (view)) && !strncmp (uri, "https", 5))
635 else if (/* midori_tab_get_special (MIDORI_TAB (view)) && */ !strncmp (uri, "https", 5))
636 {586 {
637 /* We show an error page if the certificate is invalid.587 /* We show an error page if the certificate is invalid.
638 If a "special", unverified page loads a form, it must be that page.588 If a "special", unverified page loads a form, it must be that page.
639 if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED)589 if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED)
640 FIXME: Verify more stricly that this cannot be eg. a simple Reload */590 FIXME: Verify more stricly that this cannot be eg. a simple Reload */
641 #ifdef HAVE_WEBKIT2
642 if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION)591 if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION)
643 #else
644 if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_RELOAD)
645 #endif
646 {592 {
647 GTlsCertificate* tls_cert;593 gchar* hostname = midori_uri_parse_hostname (uri, NULL);
648 GTlsCertificateFlags tls_flags;594 g_return_val_if_fail (hostname != NULL, FALSE);
649 gchar* hostname;595 GTlsCertificate* cert = g_object_get_data (G_OBJECT (view->web_view), "tls-cert");
650 if (!midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname)596 g_return_val_if_fail (cert != NULL, FALSE);
651 && tls_cert != NULL)597 webkit_web_context_allow_tls_certificate_for_host (webkit_web_context_get_default (),
598 cert, hostname);
599 if (cert != NULL)
652 {600 {
653 GcrCertificate* gcr_cert;601 GByteArray* der;
654 GByteArray* der_cert;602 g_object_get (cert, "certificate", &der, NULL);
655603 GcrCertificate* gcr = gcr_simple_certificate_new (der->data, der->len);
656 g_object_get (tls_cert, "certificate", &der_cert, NULL);604 g_return_val_if_fail (gcr != NULL, FALSE);
657 gcr_cert = gcr_simple_certificate_new (der_cert->data, der_cert->len);605 // FIXME: g_object_unref (der);
658 g_byte_array_unref (der_cert);606 if (hostname && !gcr_trust_is_certificate_pinned (gcr, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
659 if (hostname && !gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
660 {607 {
661 GError* error = NULL;608 GError* error = NULL;
662 gcr_trust_add_pinned_certificate (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, &error);609 gcr_trust_add_pinned_certificate (gcr, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, &error);
663 if (error != NULL)610 if (error != NULL)
664 {611 {
665 gchar* slots = g_strjoinv (" , ", (gchar**)gcr_pkcs11_get_trust_lookup_uris ());612 gchar* slots = g_strjoinv (" , ", (gchar**)gcr_pkcs11_get_trust_lookup_uris ());
@@ -675,14 +622,11 @@
675 g_error_free (error);622 g_error_free (error);
676 }623 }
677 }624 }
678 g_object_unref (gcr_cert);625 g_object_unref (gcr);
679 }626 }
680 if (tls_cert != NULL)
681 g_object_unref (tls_cert);
682 g_free (hostname);627 g_free (hostname);
683 }628 }
684 }629 }
685 #endif
686630
687 if (katze_item_get_meta_integer (view->item, "delay") == MIDORI_DELAY_PENDING_UNDELAY)631 if (katze_item_get_meta_integer (view->item, "delay") == MIDORI_DELAY_PENDING_UNDELAY)
688 {632 {
@@ -690,39 +634,11 @@
690 katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED);634 katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED);
691 }635 }
692636
693 #ifndef HAVE_WEBKIT2
694 /* Remove link labels */
695 JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
696 gchar* result = sokoke_js_script_eval (js_context,
697 "(function (links) {"
698 "if (links != undefined && links.length > 0) {"
699 " for (var i = links.length - 1; i >= 0; i--) {"
700 " var parent = links[i].parentNode;"
701 " parent.removeChild(links[i]); } } }) ("
702 "document.getElementsByClassName ('midoriHKD87346'));",
703 NULL);
704 g_free (result);
705 result = sokoke_js_script_eval (js_context,
706 "(function (links) {"
707 "if (links != undefined && links.length > 0) {"
708 " for (var i = links.length - 1; i >= 0; i--) {"
709 " var parent = links[i].parentNode;"
710 " parent.removeChild(links[i]); } } }) ("
711 "document.getElementsByClassName ('midori_access_key_fc04de'));",
712 NULL);
713 g_free (result);
714 view->find_links = -1;
715 #endif
716
717 gboolean handled = FALSE;637 gboolean handled = FALSE;
718 g_signal_emit_by_name (view, "navigation-requested", uri, &handled);638 g_signal_emit_by_name (view, "navigation-requested", uri, &handled);
719 if (handled)639 if (handled)
720 {640 {
721 #ifdef HAVE_WEBKIT2
722 webkit_policy_decision_ignore (decision);641 webkit_policy_decision_ignore (decision);
723 #else
724 webkit_web_policy_decision_ignore (decision);
725 #endif
726 return TRUE;642 return TRUE;
727 }643 }
728644
@@ -764,54 +680,6 @@
764 g_object_set (view, "title", NULL, NULL);680 g_object_set (view, "title", NULL, NULL);
765 midori_view_unset_icon (view);681 midori_view_unset_icon (view);
766682
767 if (!strncmp (uri, "https", 5))
768 {
769 #ifdef HAVE_WEBKIT2
770 void* request = NULL;
771 #else
772 WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
773 WebKitWebDataSource* source = webkit_web_frame_get_data_source (web_frame);
774 WebKitNetworkRequest* request = webkit_web_data_source_get_request (source);
775 #endif
776 GTlsCertificate* tls_cert;
777 GTlsCertificateFlags tls_flags;
778 gchar* hostname;
779 if (midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname))
780 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_TRUSTED);
781 #ifdef HAVE_GCR
782 else if (!midori_tab_get_special (MIDORI_TAB (view)) && tls_cert != NULL)
783 {
784 GcrCertificate* gcr_cert;
785 GByteArray* der_cert;
786
787 g_object_get (tls_cert, "certificate", &der_cert, NULL);
788 gcr_cert = gcr_simple_certificate_new (der_cert->data, der_cert->len);
789 g_byte_array_unref (der_cert);
790 if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
791 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_TRUSTED);
792 else
793 {
794 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN);
795 midori_tab_stop_loading (MIDORI_TAB (view));
796 midori_view_display_error (view, NULL, NULL, NULL, _("Security unknown"),
797 midori_location_action_tls_flags_to_string (tls_flags), NULL,
798 _("Trust this website"),
799 NULL);
800 }
801 g_object_unref (gcr_cert);
802 }
803 #endif
804 else
805 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN);
806 #ifdef HAVE_GCR
807 if (tls_cert != NULL)
808 g_object_unref (tls_cert);
809 g_free (hostname);
810 #endif
811 }
812 else
813 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_NONE);
814
815 view->find_links = -1;683 view->find_links = -1;
816 684
817 midori_view_update_load_status (view, MIDORI_LOAD_COMMITTED);685 midori_view_update_load_status (view, MIDORI_LOAD_COMMITTED);
@@ -828,7 +696,6 @@
828 midori_tab_set_progress (MIDORI_TAB (view), progress);696 midori_tab_set_progress (MIDORI_TAB (view), progress);
829}697}
830698
831#ifdef HAVE_WEBKIT2
832static void699static void
833midori_view_uri_scheme_res (WebKitURISchemeRequest* request,700midori_view_uri_scheme_res (WebKitURISchemeRequest* request,
834 gpointer user_data)701 gpointer user_data)
@@ -836,17 +703,6 @@
836 const gchar* uri = webkit_uri_scheme_request_get_uri (request);703 const gchar* uri = webkit_uri_scheme_request_get_uri (request);
837 WebKitWebView* web_view = webkit_uri_scheme_request_get_web_view (request);704 WebKitWebView* web_view = webkit_uri_scheme_request_get_web_view (request);
838 MidoriView* view = midori_view_get_for_widget (GTK_WIDGET (web_view));705 MidoriView* view = midori_view_get_for_widget (GTK_WIDGET (web_view));
839#else
840static void
841midori_view_web_view_resource_request_cb (WebKitWebView* web_view,
842 WebKitWebFrame* web_frame,
843 WebKitWebResource* web_resource,
844 WebKitNetworkRequest* request,
845 WebKitNetworkResponse* response,
846 MidoriView* view)
847{
848 const gchar* uri = webkit_network_request_get_uri (request);
849#endif
850706
851 /* Only apply custom URIs to special pages for security purposes */707 /* Only apply custom URIs to special pages for security purposes */
852 if (!midori_tab_get_special (MIDORI_TAB (view)))708 if (!midori_tab_get_special (MIDORI_TAB (view)))
@@ -855,7 +711,6 @@
855 if (g_str_has_prefix (uri, "res://"))711 if (g_str_has_prefix (uri, "res://"))
856 {712 {
857 gchar* filepath = midori_paths_get_res_filename (&uri[6]);713 gchar* filepath = midori_paths_get_res_filename (&uri[6]);
858 #ifdef HAVE_WEBKIT2
859 gchar* contents;714 gchar* contents;
860 gsize length;715 gsize length;
861 if (g_file_get_contents (filepath, &contents, &length, NULL))716 if (g_file_get_contents (filepath, &contents, &length, NULL))
@@ -868,11 +723,6 @@
868 g_free (mime_type);723 g_free (mime_type);
869 g_free (content_type);724 g_free (content_type);
870 }725 }
871 #else
872 gchar* file_uri = g_filename_to_uri (filepath, NULL, NULL);
873 webkit_network_request_set_uri (request, file_uri);
874 g_free (file_uri);
875 #endif
876 g_free (filepath);726 g_free (filepath);
877 }727 }
878 else if (g_str_has_prefix (uri, "stock://"))728 else if (g_str_has_prefix (uri, "stock://"))
@@ -936,14 +786,9 @@
936 encoded = g_base64_encode ((guchar*)buffer, buffer_size);786 encoded = g_base64_encode ((guchar*)buffer, buffer_size);
937 data_uri = g_strconcat ("data:image/png;base64,", encoded, NULL);787 data_uri = g_strconcat ("data:image/png;base64,", encoded, NULL);
938 g_free (encoded);788 g_free (encoded);
939 #ifdef HAVE_WEBKIT2
940 GInputStream* stream = g_memory_input_stream_new_from_data (buffer, buffer_size, g_free);789 GInputStream* stream = g_memory_input_stream_new_from_data (buffer, buffer_size, g_free);
941 webkit_uri_scheme_request_finish (request, stream, -1, "image/png");790 webkit_uri_scheme_request_finish (request, stream, -1, "image/png");
942 g_object_unref (stream);791 g_object_unref (stream);
943 #else
944 g_free (buffer);
945 webkit_network_request_set_uri (request, data_uri);
946 #endif
947 g_free (data_uri);792 g_free (data_uri);
948 return;793 return;
949 }794 }
@@ -1032,7 +877,6 @@
1032 return infobar;877 return infobar;
1033}878}
1034879
1035#ifdef HAVE_WEBKIT2
1036static gboolean880static gboolean
1037midori_view_web_view_permission_request_cb (WebKitWebView* web_view,881midori_view_web_view_permission_request_cb (WebKitWebView* web_view,
1038 WebKitPermissionRequest* decision,882 WebKitPermissionRequest* decision,
@@ -1044,86 +888,6 @@
1044 } */888 } */
1045 return FALSE;889 return FALSE;
1046}890}
1047#else
1048static void
1049midori_view_database_response_cb (GtkWidget* infobar,
1050 gint response,
1051 WebKitWebDatabase* database)
1052{
1053 if (response != GTK_RESPONSE_ACCEPT)
1054 {
1055 WebKitSecurityOrigin* origin = webkit_web_database_get_security_origin (database);
1056 webkit_security_origin_set_web_database_quota (origin, 0);
1057 webkit_web_database_remove (database);
1058 }
1059 /* TODO: Remember the decision */
1060}
1061
1062static void
1063midori_view_web_view_database_quota_exceeded_cb (WebKitWebView* web_view,
1064 WebKitWebFrame* web_frame,
1065 WebKitWebDatabase* database,
1066 MidoriView* view)
1067{
1068 const gchar* uri = webkit_web_frame_get_uri (web_frame);
1069 MidoriSiteDataPolicy policy = midori_web_settings_get_site_data_policy (view->settings, uri);
1070
1071 switch (policy)
1072 {
1073 case MIDORI_SITE_DATA_BLOCK:
1074 {
1075 WebKitSecurityOrigin* origin = webkit_web_database_get_security_origin (database);
1076 webkit_security_origin_set_web_database_quota (origin, 0);
1077 webkit_web_database_remove (database);
1078 }
1079 case MIDORI_SITE_DATA_ACCEPT:
1080 case MIDORI_SITE_DATA_PRESERVE:
1081 return;
1082 case MIDORI_SITE_DATA_UNDETERMINED:
1083 {
1084 gchar* hostname = midori_uri_parse_hostname (uri, NULL);
1085 gchar* message = g_strdup_printf (_("%s wants to save an HTML5 database."),
1086 hostname && *hostname ? hostname : uri);
1087 midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION, message,
1088 G_CALLBACK (midori_view_database_response_cb), database,
1089 _("_Deny"), GTK_RESPONSE_REJECT, _("_Allow"), GTK_RESPONSE_ACCEPT,
1090 NULL);
1091 g_free (hostname);
1092 g_free (message);
1093 }
1094 }
1095}
1096
1097static void
1098midori_view_location_response_cb (GtkWidget* infobar,
1099 gint response,
1100 WebKitGeolocationPolicyDecision* decision)
1101{
1102 if (response == GTK_RESPONSE_ACCEPT)
1103 webkit_geolocation_policy_allow (decision);
1104 else
1105 webkit_geolocation_policy_deny (decision);
1106}
1107
1108static gboolean
1109midori_view_web_view_geolocation_decision_cb (WebKitWebView* web_view,
1110 WebKitWebFrame* web_frame,
1111 WebKitGeolocationPolicyDecision* decision,
1112 MidoriView* view)
1113{
1114 const gchar* uri = webkit_web_frame_get_uri (web_frame);
1115 gchar* hostname = midori_uri_parse_hostname (uri, NULL);
1116 gchar* message = g_strdup_printf (_("%s wants to know your location."),
1117 hostname && *hostname ? hostname : uri);
1118 midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION,
1119 message, G_CALLBACK (midori_view_location_response_cb), decision,
1120 _("_Deny"), GTK_RESPONSE_REJECT, _("_Allow"), GTK_RESPONSE_ACCEPT,
1121 NULL);
1122 g_free (hostname);
1123 g_free (message);
1124 return TRUE;
1125}
1126#endif
1127891
1128void892void
1129midori_view_set_html (MidoriView* view,893midori_view_set_html (MidoriView* view,
@@ -1137,23 +901,10 @@
1137 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);901 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
1138 if (!uri)902 if (!uri)
1139 uri = "about:blank";903 uri = "about:blank";
1140#ifndef HAVE_WEBKIT2
1141 WebKitWebFrame* main_frame = webkit_web_view_get_main_frame (web_view);
1142 if (!web_frame)
1143 web_frame = main_frame;
1144 if (web_frame == main_frame)
1145 {
1146 katze_item_set_uri (view->item, uri);
1147 midori_tab_set_special (MIDORI_TAB (view), TRUE);
1148 }
1149 webkit_web_frame_load_alternate_string (
1150 web_frame, data, uri, uri);
1151#else
1152 /* XXX: with webkit2 ensure child frames do not set tab URI/special/html */904 /* XXX: with webkit2 ensure child frames do not set tab URI/special/html */
1153 katze_item_set_uri (view->item, uri);905 katze_item_set_uri (view->item, uri);
1154 midori_tab_set_special (MIDORI_TAB (view), TRUE);906 midori_tab_set_special (MIDORI_TAB (view), TRUE);
1155 webkit_web_view_load_alternate_html (web_view, data, uri, uri);907 webkit_web_view_load_alternate_html (web_view, data, uri, uri);
1156#endif
1157}908}
1158909
1159static gboolean910static gboolean
@@ -1165,11 +916,7 @@
1165 const gchar* description,916 const gchar* description,
1166 const gchar* suggestions,917 const gchar* suggestions,
1167 const gchar* try_again,918 const gchar* try_again,
1168#ifndef HAVE_WEBKIT2
1169 WebKitWebFrame* web_frame)
1170#else
1171 void* web_frame)919 void* web_frame)
1172#endif
1173{920{
1174 gchar* path = midori_paths_get_res_filename ("error.html");921 gchar* path = midori_paths_get_res_filename ("error.html");
1175 gchar* template;922 gchar* template;
@@ -1182,11 +929,7 @@
1182 gchar* result;929 gchar* result;
1183 gboolean is_main_frame;930 gboolean is_main_frame;
1184931
1185 #ifdef HAVE_WEBKIT2
1186 is_main_frame = TRUE;932 is_main_frame = TRUE;
1187 #else
1188 is_main_frame = web_frame && (webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)) == web_frame);
1189 #endif
1190933
1191 #if !GTK_CHECK_VERSION (3, 0, 0)934 #if !GTK_CHECK_VERSION (3, 0, 0)
1192 /* g_object_get_valist: object class `GtkSettings' has no property named `gtk-button-images' */935 /* g_object_get_valist: object class `GtkSettings' has no property named `gtk-button-images' */
@@ -1234,11 +977,7 @@
1234977
1235static gboolean978static gboolean
1236webkit_web_view_load_error_cb (WebKitWebView* web_view,979webkit_web_view_load_error_cb (WebKitWebView* web_view,
1237#ifdef HAVE_WEBKIT2
1238 WebKitLoadEvent load_event,980 WebKitLoadEvent load_event,
1239#else
1240 WebKitWebFrame* web_frame,
1241#endif
1242 const gchar* uri,981 const gchar* uri,
1243 GError* error,982 GError* error,
1244 MidoriView* view)983 MidoriView* view)
@@ -1247,12 +986,8 @@
1247 didFailProvisionalLoadWithErrorForFrame early-returns if the frame isn't986 didFailProvisionalLoadWithErrorForFrame early-returns if the frame isn't
1248 main, so we know that the pertinent frame here is the view's main frame--so987 main, so we know that the pertinent frame here is the view's main frame--so
1249 it's safe for midori_view_display_error to assume it fills in a main frame*/988 it's safe for midori_view_display_error to assume it fills in a main frame*/
1250 #ifdef HAVE_WEBKIT2
1251 void* web_frame = NULL;989 void* web_frame = NULL;
1252 void* main_frame = NULL;990 void* main_frame = NULL;
1253 #else
1254 WebKitWebFrame* main_frame = webkit_web_view_get_main_frame (web_view);
1255 #endif
1256 gchar* title;991 gchar* title;
1257 gchar* message;992 gchar* message;
1258 gboolean result;993 gboolean result;
@@ -1332,95 +1067,54 @@
1332 }1067 }
1333}1068}
13341069
1070static gboolean
1071midori_view_web_view_tls_error_cb (WebKitWebView* web_view,
1072 const gchar* failing_uri,
1073 GTlsCertificate* cert,
1074 GTlsCertificateFlags errors,
1075 MidoriView* view)
1076{
1077 GByteArray* der = NULL;
1078 g_object_get (cert, "certificate", &der, NULL);
1079 g_return_val_if_fail (der != NULL, FALSE);
1080 GcrCertificate* gcr = gcr_simple_certificate_new (der->data, der->len);
1081 // FIXME: g_object_unref (der);
1082 g_return_val_if_fail (gcr != NULL, FALSE);
1083 gchar* hostname = midori_uri_parse_hostname (failing_uri, NULL);
1084 g_return_val_if_fail (hostname != NULL, FALSE);
1085 if (gcr_trust_is_certificate_pinned (gcr, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
1086 {
1087 webkit_web_context_allow_tls_certificate_for_host (webkit_web_context_get_default (),
1088 cert, hostname);
1089 webkit_web_view_load_uri (web_view, failing_uri);
1090 }
1091 else
1092 {
1093 midori_view_display_error (view, NULL, NULL, NULL, _("Security unknown"),
1094 midori_location_action_tls_flags_to_string (errors), NULL,
1095 _("Trust this website"), NULL);
1096 g_object_set_data_full (G_OBJECT (web_view), "cert", g_object_ref (cert), (GDestroyNotify)g_object_unref);
1097 // FIXME: g_object_set_data_full (G_OBJECT (web_view), "uri", g_strdup (failing_uri), (GDestroyNotify)g_free);
1098 midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_SECURITY);
1099 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN);
1100 }
1101 g_free (hostname);
1102 g_object_unref (gcr);
1103 return TRUE;
1104}
1105
1335static void1106static void
1336midori_view_load_finished (MidoriView* view)1107midori_view_load_finished (MidoriView* view)
1337{1108{
1109 if (midori_tab_get_load_error (MIDORI_TAB (view)) == MIDORI_LOAD_ERROR_SECURITY)
1110 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN);
1111 else if (!strncmp (midori_tab_get_uri (MIDORI_TAB (view)), "https", 5))
1112 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_TRUSTED);
1338 midori_view_apply_scroll_position (view);1113 midori_view_apply_scroll_position (view);
1339 #ifndef HAVE_WEBKIT2
1340
1341 {
1342 WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
1343 JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
1344 /* Icon: URI, News Feed: $URI|title, Search: :URI|title */
1345 gchar* value = sokoke_js_script_eval (js_context,
1346 "(function (l) { var f = new Array (); for (var i in l) "
1347 "{ var t = l[i].type; var r = l[i].rel; "
1348 "if (t && (t.indexOf ('rss') != -1 || t.indexOf ('atom') != -1)) "
1349 "f.push ('$' + l[i].href + '|' + l[i].title);"
1350 "else if (r == 'search' && t == 'application/opensearchdescription+xml') "
1351 "f.push (':' + l[i].href + '|' + l[i].title); } "
1352 "return f; })("
1353 "document.getElementsByTagName ('link'));", NULL);
1354
1355 /* FIXME: If URI or title contains , parsing will break */
1356 gchar** items = g_strsplit (value, ",", 0);
1357 gchar** current_item = items;
1358 gchar* default_uri = NULL;
1359
1360 if (view->news_feeds != NULL)
1361 katze_array_clear (view->news_feeds);
1362 else
1363 view->news_feeds = katze_array_new (KATZE_TYPE_ITEM);
1364
1365 while (current_item && *current_item)
1366 {
1367 const gchar* uri_and_title = *current_item;
1368 if (uri_and_title[0] == '$')
1369 {
1370 const gchar* title;
1371 gchar* uri;
1372 KatzeItem* item;
1373
1374 uri_and_title++;
1375 if (uri_and_title == NULL)
1376 continue;
1377 title = strchr (uri_and_title, '|');
1378 if (title == NULL)
1379 goto news_feeds_continue;
1380 title++;
1381
1382 uri = g_strndup (uri_and_title, title - 1 - uri_and_title);
1383 item = g_object_new (KATZE_TYPE_ITEM,
1384 "uri", uri, "name", title, NULL);
1385 katze_array_add_item (view->news_feeds, item);
1386 g_object_unref (item);
1387 if (!default_uri)
1388 default_uri = uri;
1389 else
1390 g_free (uri);
1391 }
1392 else if (uri_and_title[0] == ':')
1393 {
1394 const gchar* title;
1395
1396 uri_and_title++;
1397 if (uri_and_title == NULL)
1398 continue;
1399 title = strchr (uri_and_title, '|');
1400 if (title == NULL)
1401 goto news_feeds_continue;
1402 title++;
1403 /* TODO: Parse search engine XML
1404 midori_view_add_info_bar (view, GTK_MESSAGE_INFO, title,
1405 G_CALLBACK (midori_view_open_search_response_cb), view,
1406 _("_Save Search engine"), GTK_RESPONSE_ACCEPT, NULL); */
1407 }
1408
1409 news_feeds_continue:
1410 current_item++;
1411 }
1412 g_strfreev (items);
1413
1414 g_object_set_data_full (G_OBJECT (view), "news-feeds", default_uri, g_free);
1415 g_free (value);
1416 }
1417 #endif
1418
1419 midori_tab_set_progress (MIDORI_TAB (view), 1.0);1114 midori_tab_set_progress (MIDORI_TAB (view), 1.0);
1420 midori_view_update_load_status (view, MIDORI_LOAD_FINISHED);1115 midori_view_update_load_status (view, MIDORI_LOAD_FINISHED);
1421}1116}
14221117
1423#ifdef HAVE_WEBKIT2
1424static void1118static void
1425midori_view_web_view_crashed_cb (WebKitWebView* web_view,1119midori_view_web_view_crashed_cb (WebKitWebView* web_view,
1426 MidoriView* view)1120 MidoriView* view)
@@ -1430,6 +1124,7 @@
1430 gchar* message = g_strdup_printf (_("Something went wrong with '%s'."), uri);1124 gchar* message = g_strdup_printf (_("Something went wrong with '%s'."), uri);
1431 midori_view_display_error (view, uri, NULL, title,1125 midori_view_display_error (view, uri, NULL, title,
1432 message, "", NULL, _("Try again"), NULL);1126 message, "", NULL, _("Try again"), NULL);
1127 midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_CRASH);
1433 g_free (message);1128 g_free (message);
1434 g_free (title);1129 g_free (title);
1435}1130}
@@ -1461,50 +1156,16 @@
14611156
1462 g_object_thaw_notify (G_OBJECT (view));1157 g_object_thaw_notify (G_OBJECT (view));
1463}1158}
1464#else
1465static void
1466midori_view_web_view_notify_load_status_cb (WebKitWebView* web_view,
1467 GParamSpec* pspec,
1468 MidoriView* view)
1469{
1470 g_object_freeze_notify (G_OBJECT (view));
1471
1472 switch (webkit_web_view_get_load_status (web_view))
1473 {
1474 case WEBKIT_LOAD_PROVISIONAL:
1475 midori_view_load_started (view);
1476 break;
1477 case WEBKIT_LOAD_COMMITTED:
1478 midori_view_load_committed (view);
1479 break;
1480 case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
1481 /* Not implemented */
1482 break;
1483 case WEBKIT_LOAD_FINISHED:
1484 case WEBKIT_LOAD_FAILED:
1485 midori_view_load_finished (view);
1486 break;
1487 default:
1488 g_warn_if_reached ();
1489 }
1490
1491 g_object_thaw_notify (G_OBJECT (view));
1492}
1493#endif
14941159
1495static void1160static void
1496midori_web_view_notify_icon_uri_cb (WebKitWebView* web_view,1161midori_web_view_notify_icon_uri_cb (WebKitWebView* web_view,
1497 GParamSpec* pspec,1162 GParamSpec* pspec,
1498 MidoriView* view)1163 MidoriView* view)
1499{1164{
1500#ifdef HAVE_WEBKIT2
1501 const gchar* uri = webkit_web_view_get_uri (web_view);1165 const gchar* uri = webkit_web_view_get_uri (web_view);
1502 WebKitWebContext* context = webkit_web_context_get_default ();1166 WebKitWebContext* context = webkit_web_context_get_default ();
1503 WebKitFaviconDatabase* favicon_database = webkit_web_context_get_favicon_database (context);1167 WebKitFaviconDatabase* favicon_database = webkit_web_context_get_favicon_database (context);
1504 gchar* icon_uri = webkit_favicon_database_get_favicon_uri (favicon_database, uri);1168 gchar* icon_uri = webkit_favicon_database_get_favicon_uri (favicon_database, uri);
1505#else
1506 gchar* icon_uri = g_strdup (webkit_web_view_get_icon_uri (web_view));
1507#endif
1508 katze_assign (view->icon_uri, icon_uri);1169 katze_assign (view->icon_uri, icon_uri);
1509 _midori_web_view_load_icon (view);1170 _midori_web_view_load_icon (view);
1510}1171}
@@ -1519,17 +1180,6 @@
1519 g_object_notify (G_OBJECT (view), "title");1180 g_object_notify (G_OBJECT (view), "title");
1520}1181}
15211182
1522#ifndef HAVE_WEBKIT2
1523static void
1524webkit_web_view_statusbar_text_changed_cb (WebKitWebView* web_view,
1525 const gchar* text,
1526 MidoriView* view)
1527{
1528 midori_tab_set_statusbar_text (MIDORI_TAB (view), text);
1529}
1530#endif
1531
1532#if GTK_CHECK_VERSION(3, 2, 0)
1533static gboolean1183static gboolean
1534midori_view_overlay_frame_enter_notify_event_cb (GtkOverlay* overlay,1184midori_view_overlay_frame_enter_notify_event_cb (GtkOverlay* overlay,
1535 GdkEventCrossing* event,1185 GdkEventCrossing* event,
@@ -1541,7 +1191,6 @@
1541 ? GTK_ALIGN_END : GTK_ALIGN_START);1191 ? GTK_ALIGN_END : GTK_ALIGN_START);
1542 return FALSE;1192 return FALSE;
1543}1193}
1544#endif
15451194
1546static gboolean1195static gboolean
1547midori_view_web_view_leave_notify_event_cb (WebKitWebView* web_view,1196midori_view_web_view_leave_notify_event_cb (WebKitWebView* web_view,
@@ -1554,16 +1203,10 @@
15541203
1555static void1204static void
1556webkit_web_view_hovering_over_link_cb (WebKitWebView* web_view,1205webkit_web_view_hovering_over_link_cb (WebKitWebView* web_view,
1557 #ifdef HAVE_WEBKIT2
1558 WebKitHitTestResult* hit_test_result,1206 WebKitHitTestResult* hit_test_result,
1559 guint modifiers,1207 guint modifiers,
1560 #else
1561 const gchar* tooltip,
1562 const gchar* link_uri,
1563 #endif
1564 MidoriView* view)1208 MidoriView* view)
1565{1209{
1566 #ifdef HAVE_WEBKIT2
1567 katze_object_assign (view->hit_test, g_object_ref (hit_test_result));1210 katze_object_assign (view->hit_test, g_object_ref (hit_test_result));
1568 if (!webkit_hit_test_result_context_is_link (hit_test_result))1211 if (!webkit_hit_test_result_context_is_link (hit_test_result))
1569 {1212 {
@@ -1571,7 +1214,6 @@
1571 return;1214 return;
1572 }1215 }
1573 const gchar* link_uri = webkit_hit_test_result_get_link_uri (hit_test_result);1216 const gchar* link_uri = webkit_hit_test_result_get_link_uri (hit_test_result);
1574 #endif
15751217
1576 katze_assign (view->link_uri, g_strdup (link_uri));1218 katze_assign (view->link_uri, g_strdup (link_uri));
1577 if (link_uri && g_str_has_prefix (link_uri, "mailto:"))1219 if (link_uri && g_str_has_prefix (link_uri, "mailto:"))
@@ -1597,25 +1239,6 @@
1597 gint *y,1239 gint *y,
1598 GdkEventButton* event)1240 GdkEventButton* event)
1599{1241{
1600#ifndef HAVE_WEBKIT2
1601 g_return_if_fail (MIDORI_IS_VIEW (view));
1602
1603 if (gtk_widget_get_window (view->web_view))
1604 {
1605
1606 if (x != NULL)
1607 *x = event->x;
1608 if (y != NULL)
1609 *y = event->y;
1610
1611 katze_object_assign (view->hit_test,
1612 g_object_ref (
1613 webkit_web_view_get_hit_test_result (
1614 WEBKIT_WEB_VIEW (view->web_view), event)));
1615 katze_assign (view->link_uri,
1616 katze_object_get_string (view->hit_test, "link-uri"));
1617 }
1618#endif
1619}1242}
16201243
1621#define MIDORI_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK \1244#define MIDORI_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK \
@@ -1678,70 +1301,6 @@
1678 view->button_press_handled = TRUE;1301 view->button_press_handled = TRUE;
1679 return TRUE;1302 return TRUE;
1680 }1303 }
1681 #if GTK_CHECK_VERSION (3, 4, 0)
1682 if (katze_object_get_boolean (gtk_widget_get_settings (view->web_view), "gtk-enable-primary-paste"))
1683 #else
1684 if (midori_settings_get_middle_click_opens_selection (MIDORI_SETTINGS (view->settings)))
1685 #endif
1686 {
1687 #ifndef HAVE_WEBKIT2
1688 WebKitHitTestResult* result = webkit_web_view_get_hit_test_result (web_view, event);
1689 WebKitHitTestResultContext context = katze_object_get_int (result, "context");
1690 gboolean is_editable = context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
1691 g_object_unref (result);
1692 if (!is_editable)
1693 {
1694 gchar* uri;
1695 GtkClipboard* clipboard = gtk_clipboard_get_for_display (
1696 gtk_widget_get_display (GTK_WIDGET (view)),
1697 GDK_SELECTION_PRIMARY);
1698 if ((uri = gtk_clipboard_wait_for_text (clipboard)))
1699 {
1700 guint i = 0;
1701 while (uri[i++] != '\0')
1702 if (uri[i] == '\n' || uri[i] == '\r')
1703 uri[i] = ' ';
1704 g_strstrip (uri);
1705
1706 /* Hold Alt to search for the selected word */
1707 if (event->state & GDK_MOD1_MASK)
1708 {
1709 gchar* new_uri = sokoke_magic_uri (uri, TRUE, FALSE);
1710 if (!new_uri)
1711 {
1712 gchar* search = katze_object_get_string (
1713 view->settings, "location-entry-search");
1714 new_uri = midori_uri_for_search (search, uri);
1715 g_free (search);
1716 }
1717 katze_assign (uri, new_uri);
1718 }
1719 else if (midori_uri_is_location (uri))
1720 {
1721 if (MIDORI_MOD_NEW_TAB (event->state))
1722 {
1723 background = view->open_tabs_in_the_background;
1724 if (MIDORI_MOD_BACKGROUND (event->state))
1725 background = !background;
1726 g_signal_emit (view, signals[NEW_TAB], 0, uri, background);
1727 }
1728 else
1729 {
1730 midori_view_set_uri (MIDORI_VIEW (view), uri);
1731 gtk_widget_grab_focus (GTK_WIDGET (view));
1732 }
1733 g_free (uri);
1734 view->button_press_handled = TRUE;
1735 return TRUE;
1736 }
1737 else
1738 {
1739 g_free (uri);
1740 }
1741 }
1742 }
1743 #endif
1744 }
1745 if (MIDORI_MOD_SCROLL (event->state))1304 if (MIDORI_MOD_SCROLL (event->state))
1746 {1305 {
1747 midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0);1306 midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0);
@@ -1751,9 +1310,7 @@
1751 break;1310 break;
1752 case 3:1311 case 3:
1753 /* Older versions don't have the context-menu signal */1312 /* Older versions don't have the context-menu signal */
1754 #if WEBKIT_CHECK_VERSION (1, 10, 0)
1755 if (event->state & GDK_CONTROL_MASK)1313 if (event->state & GDK_CONTROL_MASK)
1756 #endif
1757 {1314 {
1758 /* Ctrl + Right-click suppresses javascript button handling */1315 /* Ctrl + Right-click suppresses javascript button handling */
1759 GtkWidget* menu = gtk_menu_new ();1316 GtkWidget* menu = gtk_menu_new ();
@@ -1814,150 +1371,6 @@
1814 GdkEventKey* event,1371 GdkEventKey* event,
1815 MidoriView* view)1372 MidoriView* view)
1816{1373{
1817#ifndef HAVE_WEBKIT2
1818 gint digit = g_ascii_digit_value (event->keyval);
1819 gunichar uc = gdk_keyval_to_unicode (event->keyval);
1820 gchar* result = NULL;
1821 WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (web_view);
1822 JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
1823
1824 if (view->find_links < 0)
1825 {
1826 /* Links are currently off, turn them on */
1827 midori_tab_inject_stylesheet (MIDORI_TAB (view), ".midoriHKD87346 {"
1828 " font-size:small !important; font-weight:bold !important;"
1829 " z-index:500; border-radius:0.3em; line-height:1 !important;"
1830 " background: white !important; color: black !important;"
1831 " border:1px solid gray; padding:0 0.1em !important;"
1832 " position:absolute; display:inline !important; }");
1833 midori_tab_inject_stylesheet (MIDORI_TAB (view), ".midori_access_key_fc04de {"
1834 " font-size:small !important; font-weight:bold !important;"
1835 " z-index:500; border-radius:0.3em; line-height:1 !important;"
1836 " background: black !important; color: white !important;"
1837 " border:1px solid gray; padding:0 0.1em 0.2em 0.1em !important;"
1838 " position:absolute; display:inline !important; }");
1839 result = sokoke_js_script_eval (js_context,
1840 " var label_count = 0;"
1841 " for (i in document.links) {"
1842 " if (document.links[i].href && document.links[i].insertBefore) {"
1843 " var child = document.createElement ('span');"
1844 " if (document.links[i].accessKey && isNaN (document.links[i].accessKey)) {"
1845 " child.setAttribute ('class', 'midori_access_key_fc04de');"
1846 " child.appendChild (document.createTextNode (document.links[i].accessKey));"
1847 " } else {"
1848 " child.setAttribute ('class', 'midoriHKD87346');"
1849 " child.appendChild (document.createTextNode (label_count));"
1850 " label_count++;"
1851 " }"
1852 " document.links[i].insertBefore (child); } }",
1853 NULL);
1854 view->find_links = 0; /* Links are now on */
1855 g_free (result);
1856 return;
1857 }
1858
1859 if (event->keyval == '.')
1860 {
1861 /* Pressed '.' with links on, so turn them off */
1862 result = sokoke_js_script_eval (js_context,
1863 "var links = document.getElementsByClassName ('midoriHKD87346');"
1864 "for (var i = links.length - 1; i >= 0; i--) {"
1865 " var parent = links[i].parentNode;"
1866 " parent.removeChild(links[i]); }",
1867 NULL);
1868 g_free (result);
1869 result = sokoke_js_script_eval (js_context,
1870 "var links = document.getElementsByClassName ('midori_access_key_fc04de');"
1871 "if (links != undefined && links.length > 0) {"
1872 " for (var i = links.length - 1; i >= 0; i--) {"
1873 " var parent = links[i].parentNode;"
1874 " parent.removeChild(links[i]); } }",
1875 NULL);
1876 g_free (result);
1877 view->find_links = -1;
1878 return;
1879 }
1880
1881 /* Links are already on at this point, so process the input character */
1882
1883 if (digit != -1 && event->keyval != GDK_KEY_Return && event->keyval != GDK_KEY_Escape)
1884 {
1885 /* Got a digit, add it to the link count/ number */
1886 if (view->find_links > 0)
1887 view->find_links *= 10;
1888 view->find_links += digit;
1889 return;
1890 }
1891
1892 if (event->keyval == GDK_KEY_Escape)
1893 {
1894 // Clear the link count/number
1895 view->find_links = 0;
1896 return;
1897 }
1898
1899 if (g_unichar_isalpha (uc))
1900 {
1901 /* letter pressed if we have a corresponding accessKey and grab URI */
1902 gchar* script = NULL;
1903 gchar* utf8 = NULL;
1904 gulong sz = g_unichar_to_utf8 (uc, NULL);
1905
1906 utf8 = g_malloc0 (sz);
1907 g_unichar_to_utf8 (uc, utf8);
1908 script = g_strdup_printf (
1909 "var l = 'undefined';"
1910 "for (i in document.links) {"
1911 " if ( document.links[i].href &&"
1912 " document.links[i].accessKey == \"%s\" )"
1913 " {"
1914 " l = document.links[i].href;"
1915 " break;"
1916 " }"
1917 "}"
1918 "if (l != 'undefined') { l; }"
1919 , utf8
1920 );
1921 g_free (utf8);
1922 result = sokoke_js_script_eval (js_context, script, NULL);
1923 g_free (script);
1924 }
1925 else if (event->keyval == GDK_KEY_Return)
1926 {
1927 /* Return pressed, grab URI if we have a link with the entered number */
1928 gchar* script = g_strdup_printf (
1929 "var links = document.getElementsByClassName ('midoriHKD87346');"
1930 "var i = %d; var return_key = %d;"
1931 "if (return_key) {"
1932 " if (typeof links[i] != 'undefined')"
1933 " links[i].parentNode.href; }",
1934 view->find_links, event->keyval == GDK_KEY_Return
1935 );
1936 result = sokoke_js_script_eval (js_context, script, NULL);
1937 g_free (script);
1938 }
1939
1940 /* Check the URI we grabbed to see if it's valid, if so go there */
1941 if (midori_uri_is_location (result))
1942 {
1943 if (MIDORI_MOD_NEW_TAB (event->state))
1944 {
1945 gboolean background = view->open_tabs_in_the_background;
1946 if (MIDORI_MOD_BACKGROUND (event->state))
1947 background = !background;
1948 g_signal_emit (view, signals[NEW_TAB], 0, result, background);
1949 }
1950 else
1951 midori_view_set_uri (view, result);
1952 view->find_links = -1; /* Turn off link mode */
1953 }
1954 else /* Invalid URI, start over... */
1955 view->find_links = 0;
1956
1957 if (result)
1958 g_free (result);
1959 return;
1960#endif
1961}1374}
19621375
1963static gboolean1376static gboolean
@@ -1992,21 +1405,12 @@
1992 if (character == (event->keyval | 0x01000000))1405 if (character == (event->keyval | 0x01000000))
1993 return FALSE;1406 return FALSE;
19941407
1995 #ifdef HAVE_WEBKIT2
1996 WebKitHitTestResultContext context = katze_object_get_int (view->hit_test, "context");1408 WebKitHitTestResultContext context = katze_object_get_int (view->hit_test, "context");
1997 if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE))1409 if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE))
1998 #else
1999 if (!webkit_web_view_can_cut_clipboard (web_view)
2000 && !webkit_web_view_can_paste_clipboard (web_view))
2001 #endif
2002 {1410 {
2003 gchar* text = character ? g_strdup_printf ("%c", character) : NULL;1411 gchar* text = character ? g_strdup_printf ("%c", character) : NULL;
2004 #if GTK_CHECK_VERSION(3, 2, 0)
2005 midori_findbar_search_text (MIDORI_FINDBAR (view->overlay_find),1412 midori_findbar_search_text (MIDORI_FINDBAR (view->overlay_find),
2006 (GtkWidget*)view, TRUE, katze_str_non_null (text));1413 (GtkWidget*)view, TRUE, katze_str_non_null (text));
2007 #else
2008 g_signal_emit_by_name (view, "search-text", TRUE, katze_str_non_null (text));
2009 #endif
2010 g_free (text);1414 g_free (text);
2011 return TRUE;1415 return TRUE;
2012 }1416 }
@@ -2058,19 +1462,10 @@
2058 MidoriDownloadType type,1462 MidoriDownloadType type,
2059 const gchar* uri)1463 const gchar* uri)
2060{1464{
2061#ifdef HAVE_WEBKIT2
2062 WebKitDownload* download = webkit_web_view_download_uri (WEBKIT_WEB_VIEW (view->web_view), uri);1465 WebKitDownload* download = webkit_web_view_download_uri (WEBKIT_WEB_VIEW (view->web_view), uri);
2063 WebKitWebContext * web_context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (view->web_view));1466 WebKitWebContext * web_context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (view->web_view));
2064 midori_download_set_type (download, type);1467 midori_download_set_type (download, type);
2065 g_signal_emit_by_name (web_context, "download-started", download, view);1468 g_signal_emit_by_name (web_context, "download-started", download, view);
2066#else
2067 WebKitNetworkRequest* request = webkit_network_request_new (uri);
2068 WebKitDownload* download = webkit_download_new (request);
2069 g_object_unref (request);
2070 midori_download_set_type (download, type);
2071 gboolean handled;
2072 g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
2073 #endif
2074}1469}
20751470
2076static void1471static void
@@ -2106,19 +1501,7 @@
2106GList*1501GList*
2107midori_view_get_resources (MidoriView* view)1502midori_view_get_resources (MidoriView* view)
2108{1503{
2109#ifndef HAVE_WEBKIT2
2110 g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
2111
2112 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
2113 WebKitWebFrame* frame = webkit_web_view_get_main_frame (web_view);
2114 WebKitWebDataSource* data_source = webkit_web_frame_get_data_source (frame);
2115 GList* resources = webkit_web_data_source_get_subresources (data_source);
2116 resources = g_list_prepend (resources, webkit_web_data_source_get_main_resource (data_source));
2117 g_list_foreach (resources, (GFunc)g_object_ref, NULL);
2118 return resources;
2119#else
2120 return NULL;1504 return NULL;
2121#endif
2122}1505}
21231506
2124static GString*1507static GString*
@@ -2128,19 +1511,6 @@
2128 GList* resources = midori_view_get_resources (view);1511 GList* resources = midori_view_get_resources (view);
2129 GString* result = NULL;1512 GString* result = NULL;
21301513
2131#ifndef HAVE_WEBKIT2
2132 GList* list;
2133 for (list = resources; list; list = g_list_next (list))
2134 {
2135 WebKitWebResource* resource = WEBKIT_WEB_RESOURCE (list->data);
2136 GString* data = webkit_web_resource_get_data (resource);
2137 if (!g_strcmp0 (webkit_web_resource_get_uri (resource), uri))
2138 {
2139 result = data;
2140 break;
2141 }
2142 }
2143#endif
2144 g_list_foreach (resources, (GFunc)g_object_unref, NULL);1514 g_list_foreach (resources, (GFunc)g_object_unref, NULL);
2145 g_list_free (resources);1515 g_list_free (resources);
2146 return result;1516 return result;
@@ -2225,20 +1595,6 @@
2225 g_free (uri);1595 g_free (uri);
2226}1596}
22271597
2228#ifndef HAVE_WEBKIT2
2229static void
2230midori_view_menu_open_email_activate_cb (GtkAction* action,
2231 gpointer user_data)
2232{
2233 MidoriView* view = user_data;
2234 gchar* data = (gchar*)g_object_get_data (G_OBJECT (action), "uri");
2235 gchar* uri = g_strconcat ("mailto:", data, NULL);
2236 gboolean handled = FALSE;
2237 g_signal_emit_by_name (view, "open-uri", uri, &handled);
2238 g_free (uri);
2239}
2240#endif
2241
2242static void1598static void
2243midori_view_menu_open_link_tab_activate_cb (GtkAction* action,1599midori_view_menu_open_link_tab_activate_cb (GtkAction* action,
2244 gpointer user_data)1600 gpointer user_data)
@@ -2262,30 +1618,6 @@
2262 !view->open_tabs_in_the_background);1618 !view->open_tabs_in_the_background);
2263}1619}
22641620
2265#ifndef HAVE_WEBKIT2
2266static void
2267midori_web_view_menu_search_web_activate_cb (GtkAction* action,
2268 gpointer user_data)
2269{
2270 MidoriView* view = user_data;
2271 const gchar* search = g_object_get_data (G_OBJECT (action), "search");
2272 if (search == NULL)
2273 search = midori_settings_get_location_entry_search (MIDORI_SETTINGS (view->settings));
2274 gchar* uri = midori_uri_for_search (search, view->selected_text);
2275
2276 if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)
2277 g_signal_emit (view, signals[NEW_WINDOW], 0, uri);
2278 /* FIXME: need a way to override behavior (middle click)
2279 else if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
2280 midori_view_set_uri (view, uri); */
2281 else
2282 g_signal_emit (view, signals[NEW_TAB], 0, uri,
2283 view->open_tabs_in_the_background);
2284
2285 g_free (uri);
2286}
2287#endif
2288
2289static void1621static void
2290midori_view_tab_label_menu_window_new_cb (GtkAction* action,1622midori_view_tab_label_menu_window_new_cb (GtkAction* action,
2291 gpointer user_data)1623 gpointer user_data)
@@ -2295,30 +1627,12 @@
2295 midori_view_get_display_uri (MIDORI_VIEW (view)));1627 midori_view_get_display_uri (MIDORI_VIEW (view)));
2296}1628}
22971629
2298#ifndef HAVE_WEBKIT2
2299static void
2300midori_web_view_open_frame_in_new_tab_cb (GtkAction* action,
2301 gpointer user_data)
2302{
2303 MidoriView* view = user_data;
2304 WebKitWebFrame* web_frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (view->web_view));
2305 g_signal_emit (view, signals[NEW_TAB], 0,
2306 webkit_web_frame_get_uri (web_frame), view->open_tabs_in_the_background);
2307}
2308#endif
2309
2310static void1630static void
2311midori_view_inspect_element_activate_cb (GtkAction* action,1631midori_view_inspect_element_activate_cb (GtkAction* action,
2312 gpointer user_data)1632 gpointer user_data)
2313{1633{
2314 MidoriView* view = user_data;1634 MidoriView* view = user_data;
2315 WebKitWebInspector* inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (view->web_view));1635 WebKitWebInspector* inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (view->web_view));
2316 #ifndef HAVE_WEBKIT2
2317 WebKitHitTestResult* hit_test_result = view->hit_test;
2318 gint x = katze_object_get_int (hit_test_result, "x");
2319 gint y = katze_object_get_int (hit_test_result, "y");
2320 webkit_web_inspector_inspect_coordinates (inspector, x, y);
2321 #endif
2322 webkit_web_inspector_show (inspector);1636 webkit_web_inspector_show (inspector);
2323}1637}
23241638
@@ -2443,76 +1757,6 @@
2443 midori_web_view_menu_video_save_activate_cb, view);1757 midori_web_view_menu_video_save_activate_cb, view);
2444 }1758 }
24451759
2446 #ifndef HAVE_WEBKIT2
2447 if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION)
2448 {
2449 if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
2450 midori_context_action_add (menu, NULL);
2451
2452 /* Ensure view->selected_text */
2453 midori_view_has_selection (view);
2454 if (midori_uri_is_valid (view->selected_text))
2455 {
2456 /* :// and @ together would mean login credentials */
2457 if (g_str_has_prefix (view->selected_text, "mailto:")
2458 || (strchr (view->selected_text, '@') != NULL
2459 && strstr (view->selected_text, "://") == NULL))
2460 {
2461 gchar* text = g_strdup_printf (_("Send a message to %s"), view->selected_text);
2462 GtkAction* action = (GtkAction*)midori_context_action_new_escaped ("SendMessage", text, NULL, GTK_STOCK_JUMP_TO);
2463 g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->selected_text), (GDestroyNotify)g_free);
2464 g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_email_activate_cb), view);
2465 midori_context_action_add (menu, action);
2466 g_free (text);
2467 }
2468 else
2469 {
2470 GtkAction* action = gtk_action_new ("OpenAddressInNewTab", _("Open Address in New _Tab"), NULL, GTK_STOCK_JUMP_TO);
2471 g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->selected_text), (GDestroyNotify)g_free);
2472 g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_link_tab_activate_cb), view);
2473 midori_context_action_add (menu, action);
2474 }
2475 }
2476
2477 KatzeArray* search_engines = katze_object_get_object (browser, "search-engines");
2478 if (search_engines != NULL)
2479 {
2480 MidoriContextAction* searches = midori_context_action_new ("SearchWith", _("Search _with"), NULL, NULL);
2481 midori_context_action_add (menu, GTK_ACTION (searches));
2482
2483 KatzeItem* item;
2484 guint i = 0;
2485 KATZE_ARRAY_FOREACH_ITEM (item, search_engines)
2486 {
2487 GdkPixbuf* pixbuf;
2488 gchar* search_option = g_strdup_printf ("SearchWith%u", i);
2489 GtkAction* action = (GtkAction*)midori_context_action_new_escaped (search_option, katze_item_get_name (item), NULL, STOCK_EDIT_FIND);
2490 g_free (search_option);
2491 midori_context_action_add (searches, action);
2492 if ((pixbuf = midori_paths_get_icon (katze_item_get_uri (item), NULL)))
2493 {
2494 gtk_action_set_gicon (action, G_ICON (pixbuf));
2495 g_object_unref (pixbuf);
2496 }
2497 else
2498 {
2499 GIcon* icon = g_themed_icon_new_with_default_fallbacks ("edit-find-option-symbolic");
2500 gtk_action_set_gicon (action, icon);
2501 }
2502 gtk_action_set_always_show_image (GTK_ACTION (action), TRUE);
2503 g_object_set_data (G_OBJECT (action), "search", (gchar*)katze_item_get_uri (item));
2504 g_signal_connect (action, "activate",
2505 G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view);
2506 i++;
2507 }
2508 g_object_unref (search_engines);
2509 }
2510 if (midori_settings_get_location_entry_search (MIDORI_SETTINGS (view->settings)) != NULL)
2511 midori_context_action_add_simple (menu, "SearchWeb", _("_Search the Web"), NULL, GTK_STOCK_FIND,
2512 midori_web_view_menu_search_web_activate_cb, view);
2513 }
2514 #endif
2515
2516 if (context == WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT)1760 if (context == WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT)
2517 {1761 {
2518 midori_context_action_add_by_name (menu, "Back");1762 midori_context_action_add_by_name (menu, "Back");
@@ -2535,12 +1779,6 @@
2535 {1779 {
2536 midori_context_action_add (menu, NULL);1780 midori_context_action_add (menu, NULL);
2537 midori_context_action_add_by_name (menu, "UndoTabClose");1781 midori_context_action_add_by_name (menu, "UndoTabClose");
2538 #ifndef HAVE_WEBKIT2
2539 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
2540 if (webkit_web_view_get_focused_frame (web_view) != webkit_web_view_get_main_frame (web_view))
2541 midori_context_action_add_simple (menu, "OpenFrameInNewTab", _("Open _Frame in New Tab"), NULL, NULL,
2542 midori_web_view_open_frame_in_new_tab_cb, view);
2543 #endif
2544 midori_context_action_add_simple (menu, "OpenInNewWindow", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW,1782 midori_context_action_add_simple (menu, "OpenInNewWindow", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW,
2545 midori_view_tab_label_menu_window_new_cb, view);1783 midori_view_tab_label_menu_window_new_cb, view);
2546 midori_context_action_add_by_name (menu, "ZoomIn");1784 midori_context_action_add_by_name (menu, "ZoomIn");
@@ -2614,26 +1852,14 @@
2614#if WEBKIT_CHECK_VERSION (1, 10, 0)1852#if WEBKIT_CHECK_VERSION (1, 10, 0)
2615static gboolean1853static gboolean
2616midori_view_web_view_context_menu_cb (WebKitWebView* web_view,1854midori_view_web_view_context_menu_cb (WebKitWebView* web_view,
2617 #ifdef HAVE_WEBKIT2
2618 WebKitContextMenu* context_menu,1855 WebKitContextMenu* context_menu,
2619 GdkEvent* event,1856 GdkEvent* event,
2620 WebKitHitTestResult* hit_test_result,1857 WebKitHitTestResult* hit_test_result,
2621 #else
2622 GtkMenu* default_menu,
2623 WebKitHitTestResult* hit_test_result,
2624 gboolean keyboard,
2625 #endif
2626 MidoriView* view)1858 MidoriView* view)
2627{1859{
2628 #ifndef HAVE_WEBKIT2
2629 GdkEvent* event = gtk_get_current_event();
2630 midori_view_ensure_link_uri (view, NULL, NULL, (GdkEventButton *)event);
2631 gdk_event_free (event);
2632 #endif
2633 MidoriContextAction* menu = midori_view_get_page_context_action (view, hit_test_result);1860 MidoriContextAction* menu = midori_view_get_page_context_action (view, hit_test_result);
2634 /* Retain specific menu items we can't re-create easily */1861 /* Retain specific menu items we can't re-create easily */
2635 guint guesses = 0, guesses_max = 10; /* Maximum number of spelling suggestions */1862 guint guesses = 0, guesses_max = 10; /* Maximum number of spelling suggestions */
2636 #ifdef HAVE_WEBKIT2
2637 GList* items = webkit_context_menu_get_items (context_menu), *item, *preserved = NULL;1863 GList* items = webkit_context_menu_get_items (context_menu), *item, *preserved = NULL;
2638 for (item = items; item; item = g_list_next (item))1864 for (item = items; item; item = g_list_next (item))
2639 {1865 {
@@ -2649,21 +1875,6 @@
2649 }1875 }
2650 g_list_free (preserved);1876 g_list_free (preserved);
2651 midori_context_action_create_webkit_context_menu (menu, context_menu);1877 midori_context_action_create_webkit_context_menu (menu, context_menu);
2652 #else
2653 GList* items = gtk_container_get_children (GTK_CONTAINER (default_menu)), *item;
2654 for (item = items; item; item = g_list_next (item))
2655 {
2656 /* Private API: Source/WebCore/platform/ContextMenuItem.h */
2657 int stock_action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item->data), "webkit-context-menu"));
2658 const int ContextMenuItemTagSpellingGuess = 30;
2659 if (stock_action == ContextMenuItemTagSpellingGuess && guesses++ < guesses_max)
2660 continue;
2661 else
2662 gtk_widget_destroy (item->data);
2663 }
2664 g_list_free (items);
2665 midori_context_action_create_menu (menu, default_menu, FALSE);
2666 #endif
2667 return FALSE;1878 return FALSE;
2668}1879}
2669#endif1880#endif
@@ -2683,20 +1894,18 @@
2683 MidoriNewView where = MIDORI_NEW_VIEW_TAB;1894 MidoriNewView where = MIDORI_NEW_VIEW_TAB;
2684 GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view));1895 GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view));
26851896
2686#ifdef HAVE_WEBKIT2
2687 WebKitWindowProperties* features = webkit_web_view_get_window_properties (WEBKIT_WEB_VIEW (web_view));1897 WebKitWindowProperties* features = webkit_web_view_get_window_properties (WEBKIT_WEB_VIEW (web_view));
2688#else
2689 WebKitWebWindowFeatures* features = webkit_web_view_get_window_features (WEBKIT_WEB_VIEW (web_view));
2690#endif
2691 gboolean locationbar_visible, menubar_visible, toolbar_visible;1898 gboolean locationbar_visible, menubar_visible, toolbar_visible;
1899 GdkRectangle* geometry = NULL;
2692 gint width, height;1900 gint width, height;
2693 g_object_get (features,1901 g_object_get (features,
2694 "locationbar-visible", &locationbar_visible,1902 "locationbar-visible", &locationbar_visible,
2695 "menubar-visible", &menubar_visible,1903 "menubar-visible", &menubar_visible,
2696 "toolbar-visible", &toolbar_visible,1904 "toolbar-visible", &toolbar_visible,
2697 "width", &width,1905 "geometry", &geometry,
2698 "height", &height,
2699 NULL);1906 NULL);
1907 width = geometry->width;
1908 height = geometry->height;
2700 midori_tab_set_is_dialog (MIDORI_TAB (view),1909 midori_tab_set_is_dialog (MIDORI_TAB (view),
2701 !locationbar_visible && !menubar_visible && !toolbar_visible1910 !locationbar_visible && !menubar_visible && !toolbar_visible
2702 && width > 0 && height > 0);1911 && width > 0 && height > 0);
@@ -2723,32 +1932,21 @@
2723 GtkWidget* toplevel = gtk_widget_get_toplevel (new_view);1932 GtkWidget* toplevel = gtk_widget_get_toplevel (new_view);
2724 if (width > 0 && height > 0)1933 if (width > 0 && height > 0)
2725 gtk_widget_set_size_request (toplevel, width, height);1934 gtk_widget_set_size_request (toplevel, width, height);
2726#ifdef HAVE_WEBKIT2
2727 g_signal_connect (web_view, "close",1935 g_signal_connect (web_view, "close",
2728 G_CALLBACK (midori_view_web_view_close_cb), new_view);1936 G_CALLBACK (midori_view_web_view_close_cb), new_view);
2729#else
2730 g_signal_connect (web_view, "close-web-view",
2731 G_CALLBACK (midori_view_web_view_close_cb), new_view);
2732#endif
2733 }1937 }
27341938
2735 return TRUE;1939 return TRUE;
2736}1940}
27371941
2738static GtkWidget*1942static GtkWidget*
2739webkit_web_view_create_web_view_cb (GtkWidget* web_view,1943webkit_web_view_create_web_view_cb (GtkWidget* web_view,
2740#ifndef HAVE_WEBKIT21944 WebKitNavigationAction* navigation_action,
2741 WebKitWebFrame* web_frame,1945 MidoriView* view)
2742#endif
2743 MidoriView* view)
2744{1946{
2745 MidoriView* new_view;1947 MidoriView* new_view;
27461948
2747#ifdef HAVE_WEBKIT2
2748 const gchar* uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view));1949 const gchar* uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view));
2749#else
2750 const gchar* uri = webkit_web_frame_get_uri (web_frame);
2751#endif
2752 if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)1950 if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
2753 new_view = view;1951 new_view = view;
2754 else1952 else
@@ -2756,53 +1954,13 @@
2756 KatzeItem* item = katze_item_new ();1954 KatzeItem* item = katze_item_new ();
2757 item->uri = g_strdup (uri);1955 item->uri = g_strdup (uri);
2758 new_view = (MidoriView*)midori_view_new_from_view (view, item, NULL);1956 new_view = (MidoriView*)midori_view_new_from_view (view, item, NULL);
2759#ifdef HAVE_WEBKIT2
2760 g_signal_connect (new_view->web_view, "ready-to-show",1957 g_signal_connect (new_view->web_view, "ready-to-show",
2761 G_CALLBACK (webkit_web_view_web_view_ready_cb), view);1958 G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
2762#else
2763 g_signal_connect (new_view->web_view, "web-view-ready",
2764 G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
2765#endif
2766 }1959 }
2767 g_object_set_data_full (G_OBJECT (new_view), "opener-uri", g_strdup (uri), g_free);1960 g_object_set_data_full (G_OBJECT (new_view), "opener-uri", g_strdup (uri), g_free);
2768 return new_view->web_view;1961 return new_view->web_view;
2769}1962}
27701963
2771#ifndef HAVE_WEBKIT2
2772static gboolean
2773webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
2774 WebKitWebFrame* web_frame,
2775 WebKitNetworkRequest* request,
2776 const gchar* mime_type,
2777 WebKitWebPolicyDecision* decision,
2778 MidoriView* view)
2779{
2780 /* FIXME: Never download plugins from sub resources */
2781 if (!strcmp (mime_type, "application/x-shockwave-flash"))
2782 if (strcmp (midori_tab_get_uri (MIDORI_TAB (view)), webkit_network_request_get_uri (request)))
2783 return FALSE;
2784
2785 if (webkit_web_view_can_show_mime_type (WEBKIT_WEB_VIEW (web_view), mime_type))
2786 {
2787 if (web_frame == webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)))
2788 {
2789 g_warn_if_fail (mime_type != NULL);
2790 midori_tab_set_mime_type (MIDORI_TAB (view), mime_type);
2791 katze_item_set_meta_string (view->item, "mime-type", mime_type);
2792 if (view->icon == NULL)
2793 midori_view_unset_icon (view);
2794 }
2795
2796 return FALSE;
2797 }
2798
2799 g_object_set_data(G_OBJECT (view), "download-mime-type", (gpointer)mime_type);
2800 webkit_web_policy_decision_download (decision);
2801 g_object_set_data(G_OBJECT (view), "download-mime-type", NULL);
2802 return TRUE;
2803}
2804#endif
2805
2806gint1964gint
2807midori_save_dialog (const gchar* title,1965midori_save_dialog (const gchar* title,
2808 const gchar * hostname,1966 const gchar * hostname,
@@ -2851,7 +2009,6 @@
2851 return response;2009 return response;
2852}2010}
28532011
2854#ifdef HAVE_WEBKIT2
2855static gboolean2012static gboolean
2856midori_view_download_decide_destination_cb (WebKitDownload* download,2013midori_view_download_decide_destination_cb (WebKitDownload* download,
2857 const gchar * suggested_filename,2014 const gchar * suggested_filename,
@@ -2877,13 +2034,6 @@
2877 WebKitDownload* download,2034 WebKitDownload* download,
2878 const gchar * suggested_filename)2035 const gchar * suggested_filename)
2879{2036{
2880#else
2881static gboolean
2882midori_view_download_requested_cb (GtkWidget* web_view,
2883 WebKitDownload* download,
2884 MidoriView* view)
2885{
2886#endif
2887 gboolean handled = TRUE;2037 gboolean handled = TRUE;
2888 gchar* hostname;2038 gchar* hostname;
2889 gchar* content_type;2039 gchar* content_type;
@@ -2897,27 +2047,17 @@
2897 hostname = midori_uri_parse_hostname (2047 hostname = midori_uri_parse_hostname (
2898 opener_uri ? opener_uri : midori_view_get_display_uri (view), NULL);2048 opener_uri ? opener_uri : midori_view_get_display_uri (view), NULL);
2899 2049
2900 #ifdef HAVE_WEBKIT2
2901 content_type = g_content_type_guess (suggested_filename, NULL ,2050 content_type = g_content_type_guess (suggested_filename, NULL ,
2902 0 ,NULL);2051 0 ,NULL);
2903 if (!content_type)2052 if (!content_type)
2904 content_type = g_strdup ("application/octet-stream");2053 content_type = g_strdup ("application/octet-stream");
2905 midori_download_set_filename (download, g_strdup (suggested_filename));2054 midori_download_set_filename (download, g_strdup (suggested_filename));
2906 #else
2907 content_type = midori_download_get_content_type (download,
2908 g_object_get_data (G_OBJECT (view), "download-mime-type"));
2909 #endif
2910 description = g_content_type_get_description (content_type);2055 description = g_content_type_get_description (content_type);
29112056
2912 details = g_string_sized_new (20 * 4);2057 details = g_string_sized_new (20 * 4);
2913 #ifdef HAVE_WEBKIT2
2914 const gchar * suggestion = webkit_uri_response_get_suggested_filename (webkit_download_get_response (download));2058 const gchar * suggestion = webkit_uri_response_get_suggested_filename (webkit_download_get_response (download));
2915 g_string_append_printf (details, _("File Name: %s"),2059 g_string_append_printf (details, _("File Name: %s"),
2916 suggestion ? suggestion : suggested_filename);2060 suggestion ? suggestion : suggested_filename);
2917 #else
2918 g_string_append_printf (details, _("File Name: %s"),
2919 webkit_download_get_suggested_filename (download));
2920 #endif
2921 g_string_append_c (details, '\n');2061 g_string_append_c (details, '\n');
29222062
2923 if (g_strrstr (description, content_type))2063 if (g_strrstr (description, content_type))
@@ -2926,51 +2066,8 @@
2926 g_string_append_printf (details, _("File Type: %s ('%s')"), description, content_type);2066 g_string_append_printf (details, _("File Type: %s ('%s')"), description, content_type);
2927 g_string_append_c (details, '\n');2067 g_string_append_c (details, '\n');
29282068
2929 #ifndef HAVE_WEBKIT2
2930 /* Link Fingerprint */
2931 /* We look at the original URI because redirection would lose the fragment */
2932 WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
2933 WebKitWebDataSource* datasource = webkit_web_frame_get_provisional_data_source (web_frame);
2934 if (datasource)
2935 {
2936 gchar* fingerprint;
2937 gchar* fplabel;
2938 WebKitNetworkRequest* original_request = webkit_web_data_source_get_initial_request (datasource);
2939 const gchar* original_uri = webkit_network_request_get_uri (original_request);
2940 midori_uri_get_fingerprint (original_uri, &fingerprint, &fplabel);
2941 if (fplabel && fingerprint)
2942 {
2943 WebKitNetworkRequest* request = webkit_download_get_network_request (download);
2944
2945 g_string_append (details, fplabel);
2946 g_string_append_c (details, ' ');
2947 g_string_append (details, fingerprint);
2948 g_string_append_c (details, '\n');
2949
2950 /* Propagate original URI to make it available when the download finishes */
2951 g_object_set_data_full (G_OBJECT (request), "midori-original-uri",
2952 g_strdup (original_uri), g_free);
2953 }
2954 g_free (fplabel);
2955 g_free (fingerprint);
2956
2957 }
2958
2959 if (webkit_download_get_total_size (download) > webkit_download_get_current_size (download))
2960 {
2961 gchar* total = g_format_size (webkit_download_get_total_size (download));
2962 g_string_append_printf (details, _("Size: %s"), total);
2963 g_string_append_c (details, '\n');
2964 g_free (total);
2965 }
2966 #endif
2967
2968 #ifdef HAVE_WEBKIT2
2969 /* i18n: A file open dialog title, ie. "Open http://fila.com/manual.tgz" */2069 /* i18n: A file open dialog title, ie. "Open http://fila.com/manual.tgz" */
2970 title = g_strdup_printf (_("Open %s"), webkit_uri_request_get_uri (webkit_download_get_request (download)));2070 title = g_strdup_printf (_("Open %s"), webkit_uri_request_get_uri (webkit_download_get_request (download)));
2971 #else
2972 title = g_strdup_printf (_("Open %s"), webkit_download_get_uri (download));
2973 #endif
2974 response = midori_save_dialog (title,2071 response = midori_save_dialog (title,
2975 hostname, details, content_type); //We prompt a dialog2072 hostname, details, content_type); //We prompt a dialog
2976 g_free (title);2073 g_free (title);
@@ -2983,147 +2080,6 @@
2983 return handled;2080 return handled;
2984}2081}
29852082
2986#ifndef HAVE_WEBKIT2
2987static gboolean
2988webkit_web_view_console_message_cb (GtkWidget* web_view,
2989 const gchar* message,
2990 guint line,
2991 const gchar* source_id,
2992 MidoriView* view)
2993{
2994 if (g_object_get_data (G_OBJECT (webkit_get_default_session ()),
2995 "pass-through-console"))
2996 return FALSE;
2997
2998 if (!strncmp (message, "speed_dial-save", 13))
2999 {
3000 MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
3001 MidoriSpeedDial* dial = katze_object_get_object (browser, "speed-dial");
3002 GError* error = NULL;
3003 midori_speed_dial_save_message (dial, message, &error);
3004 if (error != NULL)
3005 {
3006 g_critical ("Failed speed dial message: %s\n", error->message);
3007 g_error_free (error);
3008 }
3009 }
3010 else
3011 g_signal_emit_by_name (view, "console-message", message, line, source_id);
3012 return TRUE;
3013}
3014
3015static void
3016midori_view_script_response_cb (GtkWidget* infobar,
3017 gint response,
3018 MidoriView* view)
3019{
3020 view->alerts--;
3021}
3022
3023static gboolean
3024midori_view_web_view_script_alert_cb (GtkWidget* web_view,
3025 WebKitWebFrame* web_frame,
3026 const gchar* message,
3027 MidoriView* view)
3028{
3029 gchar* text;
3030
3031 /* Allow a maximum of 5 alerts */
3032 if (view->alerts > 4)
3033 return TRUE;
3034
3035 view->alerts++;
3036 /* i18n: The text of an infobar for JavaScript alert messages */
3037 text = g_strdup_printf ("JavaScript: %s", message);
3038 midori_view_add_info_bar (view, GTK_MESSAGE_WARNING, text,
3039 G_CALLBACK (midori_view_script_response_cb), view,
3040 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
3041 g_free (text);
3042 return TRUE;
3043}
3044
3045static gboolean
3046midori_view_web_view_print_requested_cb (GtkWidget* web_view,
3047 WebKitWebFrame* web_frame,
3048 MidoriView* view)
3049{
3050 midori_view_print (view);
3051 return TRUE;
3052}
3053
3054static void
3055webkit_web_view_window_object_cleared_cb (GtkWidget* web_view,
3056 WebKitWebFrame* web_frame,
3057 JSContextRef js_context,
3058 JSObjectRef js_window,
3059 MidoriView* view)
3060{
3061 const gchar* page_uri;
3062
3063 page_uri = webkit_web_frame_get_uri (web_frame);
3064 if (!midori_uri_is_http (page_uri))
3065 return;
3066
3067 if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_PRIVATE)
3068 {
3069 /* Mask language, architecture, no plugin list */
3070 gchar* result = sokoke_js_script_eval (js_context,
3071 "navigator = { 'appName': 'Netscape',"
3072 "'appCodeName': 'Mozilla',"
3073 "'appVersion': '5.0 (X11)',"
3074 "'userAgent': navigator.userAgent,"
3075 "'language': 'en-US',"
3076 "'platform': 'Linux i686',"
3077 "'cookieEnabled': true,"
3078 "'javaEnabled': function () { return true; },"
3079 "'mimeTypes': {},"
3080 "'plugins': {'refresh': function () { } } };",
3081 NULL);
3082 g_free (result);
3083 }
3084}
3085
3086static void
3087midori_view_hadjustment_notify_value_cb (GtkAdjustment* hadjustment,
3088 GParamSpec* pspec,
3089 MidoriView* view)
3090{
3091 gint value = (gint)gtk_adjustment_get_value (hadjustment);
3092 katze_item_set_meta_integer (view->item, "scrollh", value);
3093}
3094
3095static void
3096midori_view_notify_hadjustment_cb (MidoriView* view,
3097 GParamSpec* pspec,
3098 gpointer data)
3099{
3100 GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
3101 GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment (scrolled);
3102 g_signal_connect (hadjustment, "notify::value",
3103 G_CALLBACK (midori_view_hadjustment_notify_value_cb), view);
3104}
3105
3106static void
3107midori_view_vadjustment_notify_value_cb (GtkAdjustment* vadjustment,
3108 GParamSpec* pspec,
3109 MidoriView* view)
3110{
3111 gint value = (gint)gtk_adjustment_get_value (vadjustment);
3112 katze_item_set_meta_integer (view->item, "scrollv", value);
3113}
3114
3115static void
3116midori_view_notify_vadjustment_cb (MidoriView* view,
3117 GParamSpec* pspec,
3118 gpointer data)
3119{
3120 GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
3121 GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment (scrolled);
3122 g_signal_connect (vadjustment, "notify::value",
3123 G_CALLBACK (midori_view_vadjustment_notify_value_cb), view);
3124}
3125#endif
3126
3127static void2083static void
3128midori_view_init (MidoriView* view)2084midori_view_init (MidoriView* view)
3129{2085{
@@ -3140,18 +2096,6 @@
3140 view->item = katze_item_new ();2096 view->item = katze_item_new ();
31412097
3142 view->scrollh = view->scrollv = -2;2098 view->scrollh = view->scrollv = -2;
3143 #ifndef HAVE_WEBKIT2
3144 /* Adjustments are not created initially, but overwritten later */
3145 view->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
3146 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
3147 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_window),
3148 GTK_SHADOW_NONE);
3149 g_signal_connect (view->scrolled_window, "notify::hadjustment",
3150 G_CALLBACK (midori_view_notify_hadjustment_cb), view);
3151 g_signal_connect (view->scrolled_window, "notify::vadjustment",
3152 G_CALLBACK (midori_view_notify_vadjustment_cb), view);
3153 #endif
3154
3155 g_signal_connect (view->item, "meta-data-changed",2099 g_signal_connect (view->item, "meta-data-changed",
3156 G_CALLBACK (midori_view_item_meta_data_changed), view);2100 G_CALLBACK (midori_view_item_meta_data_changed), view);
3157}2101}
@@ -3282,10 +2226,6 @@
3282 NULL);2226 NULL);
32832227
3284 webkit_web_view_set_settings (WEBKIT_WEB_VIEW (view->web_view), (void*)settings);2228 webkit_web_view_set_settings (WEBKIT_WEB_VIEW (view->web_view), (void*)settings);
3285 #ifndef HAVE_WEBKIT2
3286 webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (view->web_view),
3287 zoom_text_and_images);
3288 #endif
3289 midori_view_set_zoom_level (view, zoom_level);2229 midori_view_set_zoom_level (view, zoom_level);
3290}2230}
32912231
@@ -3368,12 +2308,15 @@
3368 KatzeItem* item,2308 KatzeItem* item,
3369 MidoriWebSettings* settings)2309 MidoriWebSettings* settings)
3370{2310{
3371 MidoriView* view = g_object_new (MIDORI_TYPE_VIEW,2311 MidoriView* view;
3372 "related", MIDORI_TAB (related),2312
3373 "title", item ? katze_item_get_name (item) : NULL,
3374 NULL);
3375 if (!settings && related)2313 if (!settings && related)
3376 settings = related->settings;2314 settings = related->settings;
2315 view = g_object_new (MIDORI_TYPE_VIEW,
2316 "user-content-manager", midori_settings_get_user_content_manager (MIDORI_SETTINGS (settings)),
2317 "related", MIDORI_TAB (related),
2318 "title", item ? katze_item_get_name (item) : NULL,
2319 NULL);
3377 if (settings)2320 if (settings)
3378 _midori_view_set_settings (view, settings);2321 _midori_view_set_settings (view, settings);
3379 if (item)2322 if (item)
@@ -3400,14 +2343,6 @@
34002343
3401 if (name == g_intern_string ("open-new-pages-in"))2344 if (name == g_intern_string ("open-new-pages-in"))
3402 view->open_new_pages_in = g_value_get_enum (&value);2345 view->open_new_pages_in = g_value_get_enum (&value);
3403 #ifndef HAVE_WEBKIT2
3404 else if (name == g_intern_string ("zoom-text-and-images"))
3405 {
3406 if (view->web_view)
3407 webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (view->web_view),
3408 g_value_get_boolean (&value));
3409 }
3410 #endif
3411 else if (name == g_intern_string ("open-tabs-in-the-background"))2346 else if (name == g_intern_string ("open-tabs-in-the-background"))
3412 view->open_tabs_in_the_background = g_value_get_boolean (&value);2347 view->open_tabs_in_the_background = g_value_get_boolean (&value);
3413 else if (name == g_intern_string ("enable-javascript"))2348 else if (name == g_intern_string ("enable-javascript"))
@@ -3475,184 +2410,6 @@
3475 return midori_tab_get_progress (MIDORI_TAB (view));2410 return midori_tab_get_progress (MIDORI_TAB (view));
3476}2411}
34772412
3478#ifndef HAVE_WEBKIT2
3479static gboolean
3480midori_view_inspector_window_key_press_event_cb (GtkWidget* window,
3481 GdkEventKey* event,
3482 gpointer user_data)
3483{
3484 /* Close window on Ctrl+W */
3485 if (event->keyval == 'w' && (event->state & GDK_CONTROL_MASK))
3486 gtk_widget_destroy (window);
3487
3488 return FALSE;
3489}
3490
3491static void
3492midori_view_web_inspector_construct_window (gpointer inspector,
3493 WebKitWebView* web_view,
3494 GtkWidget* inspector_view,
3495 MidoriView* view)
3496{
3497 gchar* title;
3498 const gchar* label;
3499 GtkWidget* window;
3500 GtkWidget* toplevel;
3501 const gchar* icon_name;
3502 GtkIconTheme* icon_theme;
3503 GdkPixbuf* icon;
3504 GdkPixbuf* gray_icon;
3505 #if GTK_CHECK_VERSION (3, 0, 0)
3506 GtkWidget* scrolled;
3507 #endif
3508
3509 label = midori_view_get_display_title (view);
3510 title = g_strdup_printf (_("Inspect page - %s"), label);
3511 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3512 gtk_window_set_title (GTK_WINDOW (window), title);
3513 g_free (title);
3514
3515 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
3516 if (gtk_widget_is_toplevel (toplevel))
3517 {
3518 gtk_window_set_screen (GTK_WINDOW (window), gtk_window_get_screen (GTK_WINDOW (toplevel)));
3519 katze_window_set_sensible_default_size (GTK_WINDOW (window));
3520 }
3521
3522 /* Attempt to make a gray version of the icon on the fly */
3523 icon_name = gtk_window_get_icon_name (GTK_WINDOW (toplevel));
3524 icon_theme = gtk_icon_theme_get_for_screen (
3525 gtk_widget_get_screen (GTK_WIDGET (view)));
3526 icon = gtk_icon_theme_load_icon (icon_theme, icon_name, 32,
3527 GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
3528 if (icon)
3529 {
3530 gray_icon = gdk_pixbuf_copy (icon);
3531 if (gray_icon)
3532 {
3533 gdk_pixbuf_saturate_and_pixelate (gray_icon, gray_icon, 0.1f, FALSE);
3534 gtk_window_set_icon (GTK_WINDOW (window), gray_icon);
3535 g_object_unref (gray_icon);
3536 }
3537 g_object_unref (icon);
3538 }
3539 else
3540 gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
3541 gtk_widget_set_size_request (GTK_WIDGET (inspector_view), 700, 100);
3542 #if GTK_CHECK_VERSION (3, 0, 0)
3543 scrolled = gtk_scrolled_window_new (NULL, NULL);
3544 gtk_container_add (GTK_CONTAINER (scrolled), inspector_view);
3545 gtk_container_add (GTK_CONTAINER (window), scrolled);
3546 gtk_widget_show_all (scrolled);
3547 #else
3548 gtk_container_add (GTK_CONTAINER (window), inspector_view);
3549 gtk_widget_show_all (inspector_view);
3550 #endif
3551
3552 g_signal_connect (window, "key-press-event",
3553 G_CALLBACK (midori_view_inspector_window_key_press_event_cb), NULL);
3554
3555 /* FIXME: Update window title with URI */
3556}
3557
3558static WebKitWebView*
3559midori_view_web_inspector_inspect_web_view_cb (gpointer inspector,
3560 WebKitWebView* web_view,
3561 MidoriView* view)
3562{
3563 GtkWidget* inspector_view = webkit_web_view_new ();
3564 midori_view_web_inspector_construct_window (inspector,
3565 web_view, inspector_view, view);
3566 return WEBKIT_WEB_VIEW (inspector_view);
3567}
3568
3569static gboolean
3570midori_view_web_inspector_show_window_cb (WebKitWebInspector* inspector,
3571 MidoriView* view)
3572{
3573 GtkWidget* inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector));
3574 GtkWidget* window = gtk_widget_get_toplevel (inspector_view);
3575 if (!window)
3576 return FALSE;
3577 if (katze_object_get_boolean (view->settings, "last-inspector-attached"))
3578 {
3579 gboolean handled = FALSE;
3580 g_signal_emit_by_name (inspector, "attach-window", &handled);
3581 }
3582 else
3583 {
3584 gtk_widget_show (window);
3585 gtk_window_present (GTK_WINDOW (window));
3586 }
3587 return TRUE;
3588}
3589
3590static gboolean
3591midori_view_web_inspector_attach_window_cb (gpointer inspector,
3592 MidoriView* view)
3593{
3594 GtkWidget* inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector));
3595 g_signal_emit_by_name (view, "attach-inspector", inspector_view);
3596 return TRUE;
3597}
3598
3599/**
3600 * midori_view_web_inspector_get_own_window:
3601 * @inspector: the inspector instance
3602 *
3603 * Get the widget containing the inspector, generally either a GtkWindow
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: