Merge lp:~ivaldi/midori/outsource-about-pages into lp:midori

Proposed by André Stösel
Status: Rejected
Rejected by: Cris Dywan
Proposed branch: lp:~ivaldi/midori/outsource-about-pages
Merge into: lp:midori
Diff against target: 856 lines (+471/-237)
9 files modified
extensions/about-pages.vala (+367/-0)
midori/marshal.list (+1/-0)
midori/midori-extension.c (+3/-1)
midori/midori-resource.vala (+17/-0)
midori/midori-view.c (+55/-236)
midori/midori-view.h (+4/-0)
midori/midori.vapi (+5/-0)
midori/sokoke.c (+13/-0)
midori/sokoke.h (+6/-0)
To merge this branch: bzr merge lp:~ivaldi/midori/outsource-about-pages
Reviewer Review Type Date Requested Status
Cris Dywan Disapprove
Review via email: mp+190815@code.launchpad.net

Commit message

outsource about: pages

Description of the change

To post a comment you must log in.
Revision history for this message
André Stösel (ivaldi) wrote :

right now about:dial is still in midori-view because of some technical issues

Revision history for this message
Cris Dywan (kalikiana) wrote :

I find it quite klunky to have webkit1/2 stuff in the pages and to pass a Midori.View. Is this due to the Redirect page? How about a "uri" property that if no content is given redirects?
And: how about Midori.Resource from the other branch? I have the impression Page really is the same thing except confined to the about-pages extension. Me thinks it should be merged. One step further it could replace about_content and everything becomes simpler.

review: Needs Fixing
Revision history for this message
Cris Dywan (kalikiana) wrote :

New branch based on this work, w/o the new API: lp:~midori/midori/outsource-about-pages2

review: Disapprove

Unmerged revisions

6457. By André Stösel

remove old about:home, about:new and about:search

6456. By André Stösel

always load about-pages extension

6455. By André Stösel

add about:search, about:home and about:new

6454. By André Stösel

add about:blank

6453. By André Stösel

change in signature of Page.get_contents

6452. By André Stösel

remove old about:geolocation

6451. By André Stösel

add about:geolocation

6450. By André Stösel

remove old about:paths

6449. By André Stösel

add about:paths

6448. By André Stösel

remove old about:private

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'extensions/about-pages.vala'
2--- extensions/about-pages.vala 1970-01-01 00:00:00 +0000
3+++ extensions/about-pages.vala 2013-10-19 16:00:26 +0000
4@@ -0,0 +1,367 @@
5+/*
6+ Copyright (C) 2013 André Stösel <andre@stoesel.de>
7+
8+ This library is free software; you can redistribute it and/or
9+ modify it under the terms of the GNU Lesser General Public
10+ License as published by the Free Software Foundation; either
11+ version 2.1 of the License, or (at your option) any later version.
12+
13+ See the file COPYING for the full license text.
14+*/
15+
16+namespace About {
17+ private abstract class Page : GLib.Object {
18+ public abstract void get_contents (Midori.View view, string uri);
19+ protected void load_html (Midori.View view, string content, string uri) {
20+ #if HAVE_WEBKIT2
21+ view.web_view.load_html (content, uri);
22+ #else
23+ view.web_view.load_html_string (content, uri);
24+ #endif
25+ }
26+ }
27+
28+ private class Widget : Page {
29+ public override void get_contents (Midori.View view, string uri) {
30+ string[] widgets = {
31+ "<input value=\"demo\"%s>",
32+ "<p><input type=\"password\" value=\"demo\"%s></p>",
33+ "<p><input type=\"checkbox\" value=\"demo\"%s> demo</p>",
34+ "<p><input type=\"radio\" value=\"demo\"%s> demo</p>",
35+ "<p><select%s><option>foo bar</option><option selected>spam eggs</option></select></p>",
36+ "<p><select%s size=\"3\"><option>foo bar</option><option selected>spam eggs</option></select></p>",
37+ "<p><input type=\"file\"%s></p>",
38+ "<p><input type=\"file\" multiple%s></p>",
39+ "<input type=\"button\" value=\"demo\"%s>",
40+ "<p><input type=\"email\" value=\"user@localhost.com\"%s></p>",
41+ "<input type=\"url\" value=\"http://www.example.com\"%s>",
42+ "<input type=\"tel\" value=\"+1 234 567 890\" pattern=\"^[0+][1-9 /-]*$\"%s>",
43+ "<input type=\"number\" min=1 max=9 step=1 value=\"4\"%s>",
44+ "<input type=\"range\" min=1 max=9 step=1 value=\"4\"%s>",
45+ "<input type=\"date\" min=1990-01-01 max=2010-01-01%s>",
46+ "<input type=\"search\" placeholder=\"demo\"%s>",
47+ "<textarea%s>Lorem ipsum doloret sit amet…</textarea>",
48+ "<input type=\"color\" value=\"#d1eeb9\"%s>",
49+ "<progress min=1 max=9 value=4 %s></progress>",
50+ "<keygen type=\"rsa\" challenge=\"235ldahlae983dadfar\"%s>",
51+ "<p><input type=\"reset\"%s></p>",
52+ "<input type=\"submit\"%s>"
53+ };
54+
55+ string content = """<html>
56+ <head>
57+ <style>
58+ .fallback::-webkit-slider-thumb,
59+ .fallback, .fallback::-webkit-file-upload-button {
60+ -webkit-appearance: none !important;
61+ }
62+ .column {
63+ display:inline-block; vertical-align:top;
64+ width:25%;
65+ margin-right:1%;
66+ }
67+ </style>
68+ <title>%s</title>
69+ </head>
70+ <body>
71+ <h1>%s</h1>
72+ <div class="column">%s</div>
73+ <div class="column">%s</div>
74+ <div class="column">%s</div>
75+ <p><a href="http://example.com" target="wp" onclick="javascript:window.open('http://example.com','wp','width=320, height=240, toolbar=false'); return false;">Popup window</a></p>
76+ </body>
77+ </html>""";
78+
79+ string[] widget_options = {"", " disabled", " class=\"fallback\""};
80+ string[] widgets_formated = {"", "", ""};
81+
82+ for (int i = 0; i < widget_options.length && i < widgets_formated.length; i++) {
83+ for (int j = 0; j < widgets.length; j++) {
84+ widgets_formated[i] = widgets_formated[i] + widgets[j].printf (widget_options[i]);
85+ }
86+ }
87+
88+ this.load_html (view, content.printf (uri, uri, widgets_formated[0], widgets_formated[1], widgets_formated[2]), uri);
89+ }
90+ }
91+
92+ private class Version : Page {
93+ private string[] valid_about_uris = {
94+ "about:dial",
95+ "about:geolocation",
96+ "about:home",
97+ "about:new",
98+ "about:paths",
99+ "about:private",
100+ "about:search",
101+ "about:widgets",
102+ };
103+
104+ private string list_about_uris () {
105+ string links = "";
106+ for (int i = 0; i < valid_about_uris.length; i++) {
107+ links = links + "<a href=\"%s\">%s</a> &nbsp;".printf (valid_about_uris[i], valid_about_uris[i]);
108+ }
109+ return "<p>%s</p>".printf (links);
110+ }
111+
112+ public override void get_contents (Midori.View view, string uri) {
113+ string contents = """<html>
114+ <head><title>about:version</title></head>
115+ <body>
116+ <h1>a<span style="position: absolute; left: -1000px; top: -1000px">lias a=b; echo Copy carefully #</span>bout:version</h1>
117+ <p>%s</p>
118+ <img src="res://logo-shade.png" style="position: absolute; right: 15px; bottom: 15px; z-index: -9;">
119+ <table>
120+ <tr><td>Command line %s</td></tr>
121+ %s
122+ <tr><td>Platform %s %s %s</td></tr>
123+ <tr><td>Identification %s</td></tr>
124+ %s
125+ </table>
126+ <table>
127+ %s
128+ </table>
129+ %s
130+ </body>
131+ </html>""";
132+
133+ GLib.StringBuilder versions = new GLib.StringBuilder ();
134+ Midori.View.list_versions (versions, true);
135+
136+ string ident;
137+ unowned string architecture;
138+ unowned string platform;
139+ unowned string sys_name = Midori.WebSettings.get_system_name (out architecture, out platform);
140+ view.settings.get ("user-agent", out ident);
141+
142+ GLib.StringBuilder video_formats = new GLib.StringBuilder ();
143+ view.list_video_formats (video_formats, true);
144+
145+ GLib.StringBuilder ns_plugins = new GLib.StringBuilder ();
146+ view.list_plugins (ns_plugins, true);
147+
148+ /* TODO: list active extensions */
149+
150+ this.load_html (view, contents.printf (
151+ _("Version numbers in brackets show the version used at runtime."),
152+ Midori.Paths.get_command_line_str (true),
153+ versions.str,
154+ platform, sys_name, architecture != null ? architecture : "",
155+ ident,
156+ video_formats.str,
157+ ns_plugins.str,
158+ this.list_about_uris ()
159+ ), uri);
160+ }
161+ }
162+
163+ private class Private : Page {
164+ public override void get_contents (Midori.View view, string uri) {
165+ this.load_html (view, """<html dir="ltr">
166+ <head>
167+ <title>%s</title>
168+ <link rel="stylesheet" type="text/css" href="res://about.css">
169+ </head>
170+ <body>
171+ <img id="logo" src="res://logo-shade.png" />
172+ <div id="main" style="background-image: url(stock://dialog/gtk-dialog-info);">
173+ <div id="text">
174+ <h1>%s</h1>
175+ <p class="message">%s</p><ul class=" suggestions"><li>%s</li><li>%s</li><li>%s</li></ul>
176+ <p class="message">%s</p><ul class=" suggestions"><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>
177+ </div><br style="clear: both"></div>
178+ </body>
179+ </html>""".printf (
180+ _("Private Browsing"), _("Private Browsing"),
181+ _("Midori doesn't store any personal data:"),
182+ _("No history or web cookies are being saved."),
183+ _("Extensions are disabled."),
184+ _("HTML5 storage, local database and application caches are disabled."),
185+ _("Midori prevents websites from tracking the user:"),
186+ _("Referrer URLs are stripped down to the hostname."),
187+ _("DNS prefetching is disabled."),
188+ _("The language and timezone are not revealed to websites."),
189+ _("Flash and other Netscape plugins cannot be listed by websites.")
190+ ), uri);
191+ }
192+ }
193+
194+ private class Paths : Page {
195+ public override void get_contents (Midori.View view, string uri) {
196+ string res_dir = Midori.Paths.get_res_filename ("about.css");
197+ string lib_dir = Midori.Paths.get_lib_path (PACKAGE_NAME);
198+ this.load_html (view, """<html>
199+ <body>
200+ <h1>%s</h1>
201+ <p>config: <code>%s</code></p>
202+ <p>res: <code>%s</code></p>
203+ <p>data: <code>%s/%s</code></p>
204+ <p>lib: <code>%s</code></p>
205+ <p>cache: <code>%s</code></p>
206+ <p>tmp: <code>%s</code></p>
207+ </body>
208+ </html>""".printf (
209+ uri, Midori.Paths.get_config_dir_for_reading (), res_dir,
210+ Midori.Paths.get_user_data_dir_for_reading (), PACKAGE_NAME,
211+ lib_dir, Midori.Paths.get_cache_dir_for_reading (), Midori.Paths.get_tmp_dir ()
212+ ), uri);
213+ }
214+ }
215+
216+ private class Geolocation : Page {
217+ public override void get_contents (Midori.View view, string uri) {
218+ this.load_html (view, """<html>
219+ <body>
220+ <a href="http://dev.w3.org/geo/api/spec-source.html" id="method"></a>
221+ <span id="locationInfo"><noscript>No Geolocation without Javascript</noscript></span>
222+ <script>
223+ function displayLocation (position) {
224+ var geouri = 'geo:' + position.coords.latitude + ',' + position.coords.longitude + ',' + position.coords.altitude + ',u=' + position.coords.accuracy;
225+ document.getElementById('locationInfo').innerHTML = '<a href="' + geouri + '">' + geouri + '</a><br><code>'
226+ + ' timestamp: ' + position.timestamp
227+ + ' latitude: ' + position.coords.latitude
228+ + ' longitude: ' + position.coords.longitude
229+ + ' altitude: ' + position.coords.altitude + '<br>'
230+ + ' accuracy: ' + position.coords.accuracy
231+ + ' altitudeAccuracy: ' + position.coords.altitudeAccuracy
232+ + ' heading: ' + position.coords.heading
233+ + ' speed: ' + position.coords.speed
234+ + '</code>';
235+ }
236+ function handleError (error) {
237+ var errorMessage = '<b>' + ['Unknown error', 'Permission denied', 'Position failed', 'Timed out'][error.code] + '</b>';
238+ if (error.code == 3) document.getElementById('locationInfo').innerHTML += (' ' + errorMessage);
239+ else document.getElementById('locationInfo').innerHTML = errorMessage;
240+ }
241+ if (navigator.geolocation) {
242+ var options = { enableHighAccuracy: true, timeout: 60000, maximumAge: "Infinite" };
243+ if (navigator.geolocation.watchPosition) {
244+ document.getElementById('method').innerHTML = '<code>geolocation.watchPosition</code>:';
245+ navigator.geolocation.watchPosition(displayLocation, handleError, options);
246+ } else {
247+ document.getElementById('method').innerHTML = '<code>geolocation.getCurrentPosition</code>:';
248+ navigator.geolocation.getCurrentPosition(displayLocation, handleError);
249+ }
250+ } else
251+ document.getElementById('locationInfo').innerHTML = 'Geolocation unavailable';
252+ </script>
253+ </body>
254+ </html>""", uri);
255+ }
256+ }
257+
258+ private class Blank : Page {
259+ public override void get_contents (Midori.View view, string uri) {
260+ /* do nothing (return true in about_content is required) */
261+ }
262+ }
263+
264+ private class New : Page {
265+ public override void get_contents (Midori.View view, string uri) {
266+ view.web_view.load_uri (view.settings.tabhome);
267+ }
268+ }
269+
270+ private class Redirects : Page {
271+ public override void get_contents (Midori.View view, string uri) {
272+ string? new_uri = null;
273+ if (uri == "about:new") {
274+ new_uri = view.settings.tabhome;
275+ }
276+
277+ if (uri == "about:home") {
278+ new_uri = view.settings.homepage;
279+ }
280+
281+ if (uri == "about:search") {
282+ new_uri = Midori.URI.for_search (view.settings.location_entry_search, "");
283+ }
284+
285+ if (new_uri != null) {
286+ view.set_uri (new_uri);
287+ }
288+ }
289+ }
290+
291+ private class Manager : Midori.Extension {
292+ private GLib.HashTable<string, Page>? about_pages;
293+
294+ private bool about_content (Midori.View view, string uri) {
295+ unowned Page? page = this.about_pages.get (uri);
296+ if (page != null) {
297+ page.get_contents (view, uri);
298+ return true;
299+ }
300+
301+ return false;
302+ }
303+
304+ private void tab_added (Midori.Browser browser, Midori.View view) {
305+ view.about_content.connect (this.about_content);
306+ }
307+
308+ private void tab_removed (Midori.Browser browser, Midori.View view) {
309+ view.about_content.disconnect (this.about_content);
310+ }
311+
312+ private void browser_added (Midori.Browser browser) {
313+ foreach (Midori.View tab in browser.get_tabs ()) {
314+ this.tab_added (browser, tab);
315+ }
316+ browser.add_tab.connect (this.tab_added);
317+ browser.remove_tab.connect (this.tab_removed);
318+ }
319+
320+ private void browser_removed (Midori.Browser browser) {
321+ foreach (Midori.View tab in browser.get_tabs ()) {
322+ this.tab_removed (browser, tab);
323+ }
324+ browser.add_tab.disconnect (this.tab_added);
325+ browser.remove_tab.disconnect (this.tab_removed);
326+ }
327+
328+ public void activated (Midori.App app) {
329+ this.about_pages = new GLib.HashTable<string, Page> (GLib.str_hash, GLib.str_equal);
330+ this.about_pages.insert ("about:widgets", new Widget ());
331+ this.about_pages.insert ("about:version", new Version ());
332+ this.about_pages.insert ("about:private", new Private ());
333+ this.about_pages.insert ("about:paths", new Paths ());
334+ this.about_pages.insert ("about:geolocation", new Geolocation ());
335+ this.about_pages.insert ("about:blank", new Blank ());
336+ this.about_pages.insert ("about:new", new Redirects ());
337+ this.about_pages.insert ("about:home", new Redirects ());
338+ this.about_pages.insert ("about:search", new Redirects ());
339+
340+ foreach (Midori.Browser browser in app.get_browsers ()) {
341+ this.browser_added (browser);
342+ }
343+ app.add_browser.connect (this.browser_added);
344+ }
345+
346+ public void deactivated () {
347+ Midori.App app = this.get_app ();
348+ foreach (Midori.Browser browser in app.get_browsers ()) {
349+ this.browser_removed (browser);
350+ }
351+ app.add_browser.disconnect (this.browser_added);
352+
353+ this.about_pages = null;
354+ }
355+
356+ internal Manager () {
357+ GLib.Object (name: _("About pages"),
358+ description: _(".."),
359+ version: "0.1",
360+ authors: "André Stösel <andre@stoesel.de>");
361+
362+ this.activate.connect (this.activated);
363+ this.deactivate.connect (this.deactivated);
364+ }
365+ }
366+}
367+
368+public Midori.Extension extension_init () {
369+ return new About.Manager ();
370+}
371+
372
373=== modified file 'midori/marshal.list'
374--- midori/marshal.list 2013-09-03 14:45:17 +0000
375+++ midori/marshal.list 2013-10-19 16:00:26 +0000
376@@ -4,6 +4,7 @@
377 BOOLEAN:VOID
378 BOOLEAN:STRING
379 OBJECT:OBJECT
380+OBJECT:STRING
381 VOID:BOOLEAN,STRING
382 VOID:OBJECT,ENUM,BOOLEAN
383 VOID:OBJECT,INT,INT
384
385=== modified file 'midori/midori-extension.c'
386--- midori/midori-extension.c 2013-09-08 00:50:33 +0000
387+++ midori/midori-extension.c 2013-10-19 16:00:26 +0000
388@@ -563,6 +563,7 @@
389 g_assert (midori_extension_activate_gracefully (app, extension_path, "libapps." G_MODULE_SUFFIX, activate));
390 g_assert (midori_extension_activate_gracefully (app, extension_path, "libdelayed-load." G_MODULE_SUFFIX, activate));
391 g_assert (midori_extension_activate_gracefully (app, extension_path, "libtabby." G_MODULE_SUFFIX, activate));
392+ g_assert (midori_extension_activate_gracefully (app, extension_path, "libabout-pages." G_MODULE_SUFFIX, activate));
393 }
394 else
395 {
396@@ -677,7 +678,8 @@
397 if (!strcmp (filename, "libtransfers." G_MODULE_SUFFIX)
398 || !strcmp (filename, "libapps." G_MODULE_SUFFIX)
399 || !strcmp (filename, "libdelayed-load." G_MODULE_SUFFIX)
400- || !strcmp (filename, "libtabby." G_MODULE_SUFFIX))
401+ || !strcmp (filename, "libtabby." G_MODULE_SUFFIX)
402+ || !strcmp (filename, "libabout-pages." G_MODULE_SUFFIX))
403 return;
404
405 katze_array_add_item (extensions, extension);
406
407=== added file 'midori/midori-resource.vala'
408--- midori/midori-resource.vala 1970-01-01 00:00:00 +0000
409+++ midori/midori-resource.vala 2013-10-19 16:00:26 +0000
410@@ -0,0 +1,17 @@
411+/*
412+ Copyright (C) 2013 André Stösel <andre@stoesel.de>
413+
414+ This library is free software; you can redistribute it and/or
415+ modify it under the terms of the GNU Lesser General Public
416+ License as published by the Free Software Foundation; either
417+ version 2.1 of the License, or (at your option) any later version.
418+
419+ See the file COPYING for the full license text.
420+*/
421+
422+namespace Midori {
423+ public abstract class Resource : GLib.Object {
424+ public abstract string get_contents ();
425+ public abstract string get_mime_type ();
426+ }
427+}
428
429=== modified file 'midori/midori-view.c'
430--- midori/midori-view.c 2013-10-16 18:57:04 +0000
431+++ midori/midori-view.c 2013-10-19 16:00:26 +0000
432@@ -161,6 +161,7 @@
433 DOWNLOAD_REQUESTED,
434 ADD_BOOKMARK,
435 ABOUT_CONTENT,
436+ RESOURCE_REQUEST,
437
438 LAST_SIGNAL
439 };
440@@ -326,6 +327,28 @@
441 G_TYPE_BOOLEAN, 1,
442 G_TYPE_STRING);
443
444+ /**
445+ * MidoriView::resource-request:
446+ * @view: the object on which the signal is emitted
447+ * @uri: the resource URI
448+ *
449+ * Emitted for resource requests on special views
450+ *
451+ * Return value: Midori.Resource object
452+ *
453+ * Since: 0.5.6
454+ */
455+ signals[RESOURCE_REQUEST] = g_signal_new (
456+ "resource-request",
457+ G_TYPE_FROM_CLASS (class),
458+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
459+ 0,
460+ sokoke_signal_accumulator_object_handled,
461+ NULL,
462+ midori_cclosure_marshal_OBJECT__STRING,
463+ G_TYPE_OBJECT, 1,
464+ G_TYPE_STRING);
465+
466 gobject_class = G_OBJECT_CLASS (class);
467 gobject_class->constructor = midori_view_constructor;
468 gobject_class->finalize = midori_view_finalize;
469@@ -871,11 +894,35 @@
470 if (!midori_tab_get_special (MIDORI_TAB (view)))
471 return;
472
473- if (g_str_has_prefix (uri, "res://"))
474+ gchar* contents;
475+ MidoriResource* resource = NULL;
476+ g_signal_emit (view, signals[RESOURCE_REQUEST], 0, uri, &resource);
477+
478+ if (resource) {
479+ gchar* mime_type = midori_resource_get_mime_type (MIDORI_RESOURCE (resource));
480+ contents = midori_resource_get_contents (MIDORI_RESOURCE (resource));
481+
482+ #ifdef HAVE_WEBKIT2
483+ GInputStream* stream = g_memory_input_stream_new_from_data (contents, -1, g_free);
484+ webkit_uri_scheme_request_finish (request, stream, -1, mime_type);
485+ g_object_unref (stream);
486+ #else
487+ gchar* encoded;
488+ gchar* data_uri;
489+
490+ encoded = g_base64_encode (contents, strlen (contents));
491+ data_uri = g_strconcat ("data:", mime_type, ";base64,", encoded, NULL);
492+ g_free (encoded);
493+ webkit_network_request_set_uri (request, data_uri);
494+ g_free (data_uri);
495+ g_free (contents);
496+ #endif
497+ g_free (mime_type);
498+ }
499+ else if (g_str_has_prefix (uri, "res://"))
500 {
501 gchar* filepath = midori_paths_get_res_filename (&uri[6]);
502 #ifdef HAVE_WEBKIT2
503- gchar* contents;
504 gsize length;
505 if (g_file_get_contents (filepath, &contents, &length, NULL))
506 {
507@@ -3773,44 +3820,7 @@
508 #endif
509 }
510
511-static void
512-list_geolocation (GString* markup)
513-{
514- g_string_append (markup,
515- "<a href=\"http://dev.w3.org/geo/api/spec-source.html\" id=\"method\"></a>"
516- "<span id=\"locationInfo\"><noscript>No Geolocation without Javascript</noscript></span>"
517- "<script>"
518- "function displayLocation (position) {"
519- "var geouri = 'geo:' + position.coords.latitude + ',' + position.coords.longitude + ',' + position.coords.altitude + ',u=' + position.coords.accuracy;"
520- "document.getElementById('locationInfo').innerHTML = '<a href=\"' + geouri + '\">' + geouri + '</a><br><code>'"
521- "+ ' timestamp: ' + position.timestamp"
522- "+ ' latitude: ' + position.coords.latitude"
523- "+ ' longitude: ' + position.coords.longitude"
524- "+ ' altitude: ' + position.coords.altitude + '<br>'"
525- "+ ' accuracy: ' + position.coords.accuracy"
526- "+ ' altitudeAccuracy: ' + position.coords.altitudeAccuracy"
527- "+ ' heading: ' + position.coords.heading"
528- "+ ' speed: ' + position.coords.speed"
529- "+ '</code>'; }"
530- "function handleError (error) {"
531- "var errorMessage = '<b>' + ['Unknown error', 'Permission denied', 'Position failed', 'Timed out'][error.code] + '</b>';"
532- "if (error.code == 3) document.getElementById('locationInfo').innerHTML += (' ' + errorMessage);"
533- "else document.getElementById('locationInfo').innerHTML = errorMessage; }"
534- "if (navigator.geolocation) {"
535- "var options = { enableHighAccuracy: true, timeout: 60000, maximumAge: \"Infinite\" };"
536- " if (navigator.geolocation.watchPosition) {"
537- " document.getElementById('method').innerHTML = '<code>geolocation.watchPosition</code>:';"
538- " navigator.geolocation.watchPosition(displayLocation, handleError, options);"
539- " } else {"
540- " document.getElementById('method').innerHTML = '<code>geolocation.getCurrentPosition</code>:';"
541- " navigator.geolocation.getCurrentPosition(displayLocation, handleError);"
542- " }"
543- "} else"
544- " document.getElementById('locationInfo').innerHTML = 'Geolocation unavailable';"
545- "</script>");
546-}
547-
548-static void
549+void
550 midori_view_list_video_formats (MidoriView* view,
551 GString* formats,
552 gboolean html)
553@@ -3835,28 +3845,6 @@
554 #endif
555 }
556
557-static const gchar* valid_about_uris[] = {
558- "about:dial",
559- "about:geolocation",
560- "about:home",
561- "about:new",
562- "about:paths",
563- "about:private",
564- "about:search",
565- "about:widgets",
566-};
567-
568-static void
569-list_about_uris (GString* markup)
570-{
571- g_string_append (markup, "<p>");
572- guint i;
573- for (i = 0; i < G_N_ELEMENTS (valid_about_uris); i++)
574- g_string_append_printf (markup, "<a href=\"%s\">%s</a> &nbsp;",
575- valid_about_uris[i], valid_about_uris[i]);
576-}
577-
578-
579 /**
580 * midori_view_set_uri:
581 * @view: a #MidoriView
582@@ -3888,17 +3876,12 @@
583 g_signal_emit (view, signals[ABOUT_CONTENT], 0, uri, &handled);
584
585 if (handled)
586+ {
587+ midori_tab_set_uri (MIDORI_TAB (view), uri);
588+ midori_tab_set_special (MIDORI_TAB (view), TRUE);
589+ katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED);
590+ katze_item_set_uri (view->item, midori_tab_get_uri (MIDORI_TAB (view)));
591 return;
592-
593- if (!strcmp (uri, "about:new"))
594- uri = midori_settings_get_tabhome (MIDORI_SETTINGS (view->settings));
595- if (!strcmp (uri, "about:home"))
596- uri = midori_settings_get_homepage (MIDORI_SETTINGS (view->settings));
597- if (!strcmp (uri, "about:search"))
598- {
599- uri = midori_settings_get_location_entry_search (MIDORI_SETTINGS (view->settings));
600- temporary_uri = midori_uri_for_search (uri, "");
601- uri = temporary_uri;
602 }
603
604 if (!strcmp (uri, "about:dial"))
605@@ -3925,170 +3908,6 @@
606 g_timer_destroy (timer);
607 }
608 }
609- else if (midori_uri_is_blank (uri))
610- {
611- data = NULL;
612- if (!strcmp (uri, "about:widgets"))
613- {
614- static const gchar* widgets[] = {
615- "<input value=\"demo\"%s>",
616- "<p><input type=\"password\" value=\"demo\"%s>",
617- "<p><input type=\"checkbox\" value=\"demo\"%s> demo",
618- "<p><input type=\"radio\" value=\"demo\"%s> demo",
619- "<p><select%s><option>foo bar</option><option selected>spam eggs</option></select>",
620- "<p><select%s size=\"3\"><option>foo bar</option><option selected>spam eggs</option></select>",
621- "<p><input type=\"file\"%s>",
622- "<p><input type=\"file\" multiple%s>",
623- "<input type=\"button\" value=\"demo\"%s>",
624- "<p><input type=\"email\" value=\"user@localhost.com\"%s>",
625- "<input type=\"url\" value=\"http://www.example.com\"%s>",
626- "<input type=\"tel\" value=\"+1 234 567 890\" pattern=\"^[0+][1-9 /-]*$\"%s>",
627- "<input type=\"number\" min=1 max=9 step=1 value=\"4\"%s>",
628- "<input type=\"range\" min=1 max=9 step=1 value=\"4\"%s>",
629- "<input type=\"date\" min=1990-01-01 max=2010-01-01%s>",
630- "<input type=\"search\" placeholder=\"demo\"%s>",
631- "<textarea%s>Lorem ipsum doloret sit amet…</textarea>",
632- "<input type=\"color\" value=\"#d1eeb9\"%s>",
633- "<progress min=1 max=9 value=4 %s></progress>",
634- "<keygen type=\"rsa\" challenge=\"235ldahlae983dadfar\"%s>",
635- "<p><input type=\"reset\"%s>",
636- "<input type=\"submit\"%s>",
637- };
638- guint i;
639- GString* demo = g_string_new ("<html><head><style>"
640- ".fallback::-webkit-slider-thumb,"
641- ".fallback, .fallback::-webkit-file-upload-button {"
642- "-webkit-appearance: none !important }"
643- ".column { display:inline-block; vertical-align:top;"
644- "width:25%;margin-right:1% }</style><title>");
645- g_string_append_printf (demo,
646- "%s</title></head><body><h1>%s</h1>", uri, uri);
647- g_string_append (demo, "<div class=\"column\">");
648- for (i = 0; i < G_N_ELEMENTS (widgets); i++)
649- g_string_append_printf (demo, widgets[i], "");
650- g_string_append (demo, "</div><div class=\"column\">");
651- for (i = 0; i < G_N_ELEMENTS (widgets); i++)
652- g_string_append_printf (demo, widgets[i], " disabled");
653- g_string_append (demo, "</div><div class=\"column\">");
654- for (i = 0; i < G_N_ELEMENTS (widgets); i++)
655- g_string_append_printf (demo, widgets[i], " class=\"fallback\"");
656- g_string_append (demo, "</div>");
657- g_string_append (demo, "<p><a href=\"http://example.com\" target=\"wp\" "
658- "onclick=\"javascript:window.open('http://example.com','wp',"
659- "'width=320, height=240, toolbar=false'); return false\""
660- ">Popup window</a></p>");
661- data = g_string_free (demo, FALSE);
662- }
663- else if (!strcmp (uri, "about:private"))
664- {
665- data = g_strdup_printf (
666- "<html dir=\"ltr\"><head><title>%s</title>"
667- "<link rel=\"stylesheet\" type=\"text/css\" href=\"res://about.css\">"
668- "</head>"
669- "<body>"
670- "<img id=\"logo\" src=\"res://logo-shade.png\" />"
671- "<div id=\"main\" style=\"background-image: url(stock://dialog/gtk-dialog-info);\">"
672- "<div id=\"text\">"
673- "<h1>%s</h1>"
674- "<p class=\"message\">%s</p><ul class=\" suggestions\"><li>%s</li><li>%s</li><li>%s</li></ul>"
675- "<p class=\"message\">%s</p><ul class=\" suggestions\"><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>"
676- "</div><br style=\"clear: both\"></div></body></html>",
677- _("Private Browsing"), _("Private Browsing"),
678- _("Midori doesn't store any personal data:"),
679- _("No history or web cookies are being saved."),
680- _("Extensions are disabled."),
681- _("HTML5 storage, local database and application caches are disabled."),
682- _("Midori prevents websites from tracking the user:"),
683- _("Referrer URLs are stripped down to the hostname."),
684- _("DNS prefetching is disabled."),
685- _("The language and timezone are not revealed to websites."),
686- _("Flash and other Netscape plugins cannot be listed by websites."));
687- }
688- else if (!strcmp (uri, "about:geolocation"))
689- {
690- GString* markup = g_string_new ("");
691- list_geolocation (markup);
692- data = g_string_free (markup, FALSE);
693- }
694- else if (!strcmp (uri, "about:paths"))
695- {
696- gchar* res_dir = midori_paths_get_res_filename ("about.css");
697- gchar* lib_dir = midori_paths_get_lib_path (PACKAGE_NAME);
698- data = g_markup_printf_escaped ("<body><h1>%s</h1>"
699- "<p>config: <code>%s</code></p>"
700- "<p>res: <code>%s</code></p>"
701- "<p>data: <code>%s/%s</code></p>"
702- "<p>lib: <code>%s</code></p>"
703- "<p>cache: <code>%s</code></p>"
704- "<p>tmp: <code>%s</code></p>"
705- "</body>",
706- uri, midori_paths_get_config_dir_for_reading (), res_dir,
707- midori_paths_get_user_data_dir_for_reading (), PACKAGE_NAME,
708- lib_dir, midori_paths_get_cache_dir_for_reading (), midori_paths_get_tmp_dir ());
709- g_free (res_dir);
710- g_free (lib_dir);
711- }
712- else if (!strcmp (uri, "about:") || !strcmp (uri, "about:version"))
713- {
714- gchar* command_line = midori_paths_get_command_line_str (TRUE);
715- gchar* architecture, *platform;
716- const gchar* sys_name = midori_web_settings_get_system_name (
717- &architecture, &platform);
718- gchar* ident = katze_object_get_string (view->settings, "user-agent");
719- GString * tmp = g_string_new ("");
720-
721- g_string_append_printf (tmp,
722- "<html><head><title>about:version</title></head>"
723- "<body><h1>a%sbout:version</h1>"
724- "<p>%s</p>"
725- "<img src=\"res://logo-shade.png\" "
726- "style=\"position: absolute; right: 15px; bottom: 15px; z-index: -9;\">"
727- "<table>",
728- "<span style=\"position: absolute; left: -1000px; top: -1000px\">lias a=b; echo Copy carefully #</span>",
729- _("Version numbers in brackets show the version used at runtime."));
730- midori_view_add_version (tmp, TRUE, g_markup_printf_escaped ("Command line %s",
731- command_line));
732- midori_view_list_versions (tmp, TRUE);
733- midori_view_add_version (tmp, TRUE, g_markup_printf_escaped ("Platform %s %s %s",
734- platform, sys_name, architecture ? architecture : ""));
735- midori_view_add_version (tmp, TRUE, g_markup_printf_escaped ("Identification %s",
736- ident));
737- midori_view_list_video_formats (view, tmp, TRUE);
738-
739- g_string_append (tmp, "</table><table>");
740- midori_view_list_plugins (view, tmp, TRUE);
741- g_string_append (tmp, "</table>");
742- list_about_uris (tmp);
743- /* TODO: list active extensions */
744-
745- g_string_append (tmp, "</body></html>");
746- data = g_string_free (tmp, FALSE);
747-
748- g_free (command_line);
749- g_free (ident);
750- }
751- else if (!strcmp (uri, "about:blank"))
752- data = g_strdup ("<body></body>");
753- else
754- {
755- data = g_strdup_printf (
756- "<html><head><title>%s</title></head><body><h1>%s</h1>"
757- "<img src=\"res://logo-shade.png\" "
758- "style=\"position: absolute; right: 15px; bottom: 15px; z-index: -9;\">"
759- "</body></html>", uri, uri);
760- }
761-
762- midori_tab_set_uri (MIDORI_TAB (view), uri);
763- midori_tab_set_special (MIDORI_TAB (view), TRUE);
764-#ifndef HAVE_WEBKIT2
765- webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (view->web_view), data, uri);
766-#else
767- webkit_web_view_load_html (WEBKIT_WEB_VIEW (view->web_view), data, uri);
768-#endif
769- g_free (data);
770- katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED);
771- katze_item_set_uri (view->item, midori_tab_get_uri (MIDORI_TAB (view)));
772- }
773 else if (katze_item_get_meta_integer (view->item, "delay") == MIDORI_DELAY_DELAYED)
774 {
775 midori_tab_set_uri (MIDORI_TAB (view), uri);
776
777=== modified file 'midori/midori-view.h'
778--- midori/midori-view.h 2013-04-08 18:11:54 +0000
779+++ midori/midori-view.h 2013-10-19 16:00:26 +0000
780@@ -79,6 +79,10 @@
781 midori_view_get_load_status (MidoriView* view);
782
783 void
784+midori_view_list_video_formats (MidoriView* view,
785+ GString* formats,
786+ gboolean html);
787+void
788 midori_view_set_uri (MidoriView* view,
789 const gchar* uri);
790
791
792=== modified file 'midori/midori.vapi'
793--- midori/midori.vapi 2013-10-09 20:05:29 +0000
794+++ midori/midori.vapi 2013-10-19 16:00:26 +0000
795@@ -194,6 +194,9 @@
796 public void reload (bool from_cache);
797 public Gtk.Widget add_info_bar (Gtk.MessageType type, string message, GLib.Callback? callback, void* object, ...);
798 public ContextAction get_page_context_action (WebKit.HitTestResult hit_test_result);
799+ public void list_plugins (GLib.StringBuilder ns_plugins, bool html);
800+ public void list_video_formats (GLib.StringBuilder formats, bool html);
801+ public static void list_versions (GLib.StringBuilder markup, bool html);
802
803 public string title { get; }
804 public Gdk.Pixbuf icon { get; }
805@@ -207,6 +210,7 @@
806 [HasEmitter]
807 public signal bool download_requested (WebKit.Download download);
808 public signal bool about_content (string uri);
809+ public signal GLib.Object? resource_request (string uri);
810
811 }
812
813@@ -244,6 +248,7 @@
814 public MidoriStartup load_on_startup { get; set; }
815 public static bool has_plugin_support ();
816 public static bool skip_plugin (string path);
817+ public static unowned string get_system_name (out unowned string? architecture, out unowned string? platform);
818 }
819
820 [CCode (cheader_filename = "midori/midori-websettings.h", cprefix = "MIDORI_STARTUP_")]
821
822=== modified file 'midori/sokoke.c'
823--- midori/sokoke.c 2013-08-07 21:23:54 +0000
824+++ midori/sokoke.c 2013-10-19 16:00:26 +0000
825@@ -1119,3 +1119,16 @@
826 g_free (launcher_type);
827 }
828 #endif
829+
830+gboolean
831+sokoke_signal_accumulator_object_handled (GSignalInvocationHint* ihint,
832+ GValue* returnAccu,
833+ const GValue* handlerReturn,
834+ gpointer dummy)
835+{
836+ gpointer newObject = g_value_get_object(handlerReturn);
837+ g_value_set_object(returnAccu, newObject);
838+
839+ // Continue if we don't have a newObject
840+ return !newObject;
841+}
842
843=== modified file 'midori/sokoke.h'
844--- midori/sokoke.h 2013-08-02 16:40:27 +0000
845+++ midori/sokoke.h 2013-10-19 16:00:26 +0000
846@@ -133,4 +133,10 @@
847 sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* filename, gchar* uri);
848 #endif
849
850+gboolean
851+sokoke_signal_accumulator_object_handled (GSignalInvocationHint* ihint,
852+ GValue* returnAccu,
853+ const GValue* handlerReturn,
854+ gpointer dummy);
855+
856 #endif /* !__SOKOKE_H__ */

Subscribers

People subscribed via source and target branches

to all changes: