Code review comment for lp:~abreu-alexandre/webbrowser-app/webapp-navigation-handling

Revision history for this message
Olivier Tilloy (osomon) wrote :

> > 17 + property var onNavigationRequestedDelegate: null
> > 18 UserAgent {
> > 19 id: userAgent
> > 20 }
> > 21 experimental.userAgent: userAgent.defaultUA
> > 22 onNavigationRequested: {
> > 23 + if (onNavigationRequestedDelegate &&
> > typeof(onNavigationRequestedDelegate) == 'function') {
> > 24 + onNavigationRequestedDelegate (request);
> > 25 + if (request.action === WebView.IgnoreRequest)
> > 26 + return;
> > 27 + }
> >
> > This works, however I’m not convinced by the way it is implemented.
> > How about, instead of a property for a delegate function, implemented a
> > default method in the base class (UbuntuWebView), called e.g.
> > handleNavigationRequest(…), have onNavigationRequested call it, and override
> > it in Browser.qml?
> >
> > This would be functionally equivalent, but more elegant in my opinion.
>
> I am not really sure about that one, since it gives too much liberty to the
> UbuntuWebView's client/user. The semantics is supposed to be a delegation of
> some specialized behaviour that could override the basic one; but w/ your
> solution
> nothing prevents the client to forget to call the default behaviour, or for
> example
> behaviours from colliding/conflicting in their side-effects,

I’m not sure I’m following you. What I’m proposing is a different implementation, but the semantics are exactly the same: the specialized behavior is delegated to a function (which by default does nothing and can be overridden) instead of being delegated to a function object stored as a property.

« Back to merge proposal