Commit Graph

37 Commits

Author SHA1 Message Date
Florian Müllner
4871845d01 portalHelper: Require GTK 3.0
When multiple versions of a typelib are available, GI will pick the
highest one unless an explicit version is requested. So as GTK 4.0
is becoming a thing, it's time to do that.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/970
2020-01-31 17:39:18 +01:00
Florian Müllner
ebf77748a8 cleanup: Require "dangling" commas
Since ES5, trailing commas in arrays and object literals are valid.
We generally haven't used them so far, but they are actually a good
idea, as they make additions and removals in diffs much cleaner.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
c860409da5 cleanup: Use object shorthand where possible
ES6 allows to omit property names where they match the name of the
assigned variable, which makes code less redunant and thus cleaner.
We will soon enforce that in our eslint rules, so make sure we use
the shorthand wherever possible.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
f309d98bc8 cleanup: Use more template strings
xgettext got better at recognizing template strings, so we can
replace more string concatenations. Alas xgettext is still buggy
(surprise, regular expressions are hard), so there are still a
handful of holdouts that prevent us from making a complete switch.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/792
2019-11-05 01:51:29 +00:00
Florian Müllner
e357559582 cleanup: Mark globals used from other modules as exported
eslint cannot figure out that those symbols are used from other modules
via imports, so they trigger unused-variable errors. To fix, explicitly
mark those symbols as exported.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
2f97a1a55d cleanup: Mark unused arguments as unused
This will stop eslint from warning about them, while keeping their
self-documenting benefit.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
79cf3a6dd0 cleanup: Remove some unhelpful unused arguments
Those unused arguments aren't bugs - unbeknownst to eslint, they all
correspond to valid signal parameters - but they don't contribute
anything to clarity, so just remove them anyway.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
14d7897a93 style: Stop using braces for single-line arrow functions
Braces are optional for single-line arrow functions, but there's a
subtle difference:
Without braces, the expression is implicitly used as return value; with
braces, the function returns nothing unless there's an explicit return.

We currently reflect that in our style by only omitting braces when the
function is expected to have a return value, but that's not very obvious,
not an important differentiation to make, and not easy to express in an
automatic rule.

So just omit braces consistently as mandated by gjs' coding style.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608
2019-07-02 12:17:46 +00:00
Florian Müllner
7ac35c644e style: Fix stray/missing spaces
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
e56d7f5021 cleanup: Remove unused variables
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:10 +02:00
Florian Müllner
fd50b9a45e cleanup: Use destructuring for imports from GI
This is *much* nicer than repetitive "imports.gi" lines ...

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/399
2019-02-09 07:39:20 +01:00
Florian Müllner
e68dfed1f7 cleanup: Port GObject classes to JS6 classes
GJS added API for defining GObject classes with ES6 class syntax
last cycle, use it to port the remaining Lang.Class classes to
the new syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
2019-01-25 14:02:44 +00:00
Florian Müllner
94423151b2 dbus: Move all interface descriptions into the resource
https://gitlab.gnome.org/GNOME/gnome-shell/issues/537
2018-09-17 07:34:49 +00:00
Marco Trevisan (Treviño)
dbf993300a js: use ES6 template strings for dbus interfaces
Use multiline template strings for dbus interfaces as they're easier to maintain
2018-08-27 19:23:00 +02:00
Florian Müllner
3b1330880f cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:02 +00:00
Florian Müllner
213e38c2ef cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:00 +00:00
Florian Müllner
76f09b1e49 cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:54:58 +00:00
Florian Müllner
2582d16ca7 Define classes with 'var' instead of 'const'
Any symbols (including class properties) that should be visible
outside the module it's defined in need to be defined as global.
For now gjs still allows the access for 'const', but get rid of
the warnings spill now by changing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Bastien Nocera
50d37e74a3 portalHelper: Fix auth URI not being passed to window
Gjs-Message: JS WARNING: [resource:///org/gnome/shell/portalHelper/main.js 360]: reference to undefined property top.uri
is caused by the URI variable actually being called "url".

https://bugzilla.gnome.org/show_bug.cgi?id=783286
2017-05-31 16:51:05 +02:00
Bastien Nocera
c22287b517 portalHelper: Don't go through proxies for captive portals
When using an SSH tunnel (through a SOCKS proxy) to funnel all
the outgoing traffic, we need the captive portal to not go through that
proxy, otherwise we can't go through the proxy because we're not
connected to the Internet and we can't go through the portal because
we're not connected through the proxy.

This fixes a blank captive portal window and no error reporting in that
particular configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=769692
2017-05-31 16:03:11 +02:00
Catalin Iacob
8369dc6b64 portalHelper: Fix portals which require a new window to be loaded
https://bugzilla.gnome.org/show_bug.cgi?id=759044
2017-04-06 12:28:43 +02:00
Catalin Iacob
a0c31478c0 portalHelper: Use the correct enum values
Without this the tests never succeeded because they were comparing
loadEvent to undefined resulting in the icon not changing as it
should.

https://bugzilla.gnome.org/show_bug.cgi?id=780606
2017-04-05 09:27:07 +02:00
Bastien Nocera
6557ae0a2b portalHelper: Simplify our non-use of cache
Instead of using directories that we'll destroy when done, use the new
"ephemeral" data manager feature, through the JavaScript version of:
webkit_web_context_new_ephemeral()

We also throw an error on startup, in the logs, if WebKitGTK is too old.

https://bugzilla.gnome.org/show_bug.cgi?id=780453
2017-03-28 14:18:25 +02:00
Bastien Nocera
a76869216a portalHelper: Don't fail to load because of TLS errors
Accept self-signed and expired certificates as if we errored out, we
couldn't access the network at all. Consider this insecure though.

https://bugzilla.gnome.org/show_bug.cgi?id=778253
2017-02-15 14:30:07 +01:00
Bastien Nocera
b5bf82b5db portalHelper: Fix signal arguments
How did this work in tests?!

https://bugzilla.gnome.org/show_bug.cgi?id=778552
2017-02-13 11:54:35 +01:00
Bastien Nocera
98cdd44543 portalHelper: Fix runtime warning
When there is no URI, then the title should be empty, not null:
Gjs-WARNING **: JS ERROR: Error: Argument 'str' (type utf8) may not be null

https://bugzilla.gnome.org/show_bug.cgi?id=778552
2017-02-13 11:54:35 +01:00
Bastien Nocera
304b68eff9 portalHelper: Add security icon to titlebar
This adds a security icon (either secure or insecure) to the portal
helper's title bar. As soon as a part or all of the page and its content
is served insecurely, the icon shown will be a broken padlock.

https://bugzilla.gnome.org/show_bug.cgi?id=749197
2017-02-13 10:26:56 +01:00
Bastien Nocera
49607e1313 portalHelper: Don't change the main window title
The title of the window should not be in control of a potentially
hostile hotspot provider, so only set the subtitle to be that of the
page, the main title will stay the same.

The subtitle will also be set to a URI, so that the hotspot cannot be
used to control the title shown in our UI.

Helps https://bugzilla.gnome.org/show_bug.cgi?id=749197
2017-01-24 13:36:09 +01:00
Bastien Nocera
a81f18592a portalHelper: Set a minimum window size
Even though the window is maximised when created, the window is still
resizable. This avoids making the window smaller than usable. If the
screen is smaller than the minimum window size, the maximise should make
it fullscreen and non-resizable.

https://bugzilla.gnome.org/show_bug.cgi?id=735233
2017-01-24 13:36:09 +01:00
Bastien Nocera
2ff988ef37 portalHelper: Use private data/cache directories
https://bugzilla.gnome.org/show_bug.cgi?id=775639
2017-01-24 13:36:09 +01:00
Bastien Nocera
d200fb1d14 portalHelper: Handle Ctrl+W/Ctrl+Q to close window
https://bugzilla.gnome.org/show_bug.cgi?id=764133
2017-01-19 14:04:34 +01:00
Debarshi Ray
c4a07fad83 portalHelper: Use a constant for the host name and URI
https://bugzilla.gnome.org/show_bug.cgi?id=769940
2016-11-23 21:38:24 +01:00
Debarshi Ray
9ea8fdc1d1 portalHelper: Address intermittent TLS failures
Users are currently experiencing intermittent (and hard to debug) TLS
errors when loading the portal authentication page. This could be
caused by using http://www.gnome.org/ for our connectivity checks
because it redirects to HTTPS.

We can completely remove TLS from the equation by not using HTTPS.
http://nmcheck.gnome.org/ is a good choice because it doesn't redirect
to HTTPS and was created for NetworkManager's connectivity check.

https://bugzilla.gnome.org/show_bug.cgi?id=769940
2016-11-23 21:38:24 +01:00
Bastien Nocera
c363e2a322 PortalHelper: Make translator comment appear
Use "/* */" for the translator comment, so that xgettext can extract it.

https://bugzilla.gnome.org/show_bug.cgi?id=736182
2015-01-28 13:47:56 +01:00
Giovanni Campagna
b6e6e097b7 PortalHelper: fix portals that don't redirect properly
We assumed that either a portal would give us a target URI, or we
would eventually reach the URI of our choice (which is http://www.gnome.org)

This is not always the case: even after a successful login we may
stay in a confirmation page, so make sure that every time we see a
redirect we trigger a connectivity check (or queue one for when
the user closes the window)

https://bugzilla.gnome.org/show_bug.cgi?id=733848
2014-08-19 15:29:22 +02:00
Giovanni Campagna
365bfcae12 portalHelper: fix typo
Not even an hour, and already the first bug...
2014-06-26 20:10:18 +02:00
Giovanni Campagna
8c67a70db0 Add a helper to handle captive portal logins
Add a small DBus-activated GtkApplication that embeds a WebKitWebView
and implements some minimal logic to see if the login succeeds.
It will try to connect to a custom NM-provided url (the portal login
page), if one exists, or to www.gnome.org in the normal case of
a portal doing redirect.

https://bugzilla.gnome.org/show_bug.cgi?id=704416
2014-06-26 19:54:58 +02:00