Merge lp:~osomon/oxide/tolerant-GURL2QUrl into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy
Status: Rejected
Rejected by: Olivier Tilloy
Proposed branch: lp:~osomon/oxide/tolerant-GURL2QUrl
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 44 lines (+25/-1)
1 file modified
qt/core/browser/oxide_qt_browser_platform_integration.cc (+25/-1)
To merge this branch: bzr merge lp:~osomon/oxide/tolerant-GURL2QUrl
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) Disapprove
Chris Coulson Pending
Review via email: mp+257331@code.launchpad.net

Commit message

Be more tolerant when converting a GURL to a QUrl when calling QDesktopServices::openUrl().

Description of the change

Note: I’m not sure whether this tolerant GURL2QUrl function should be used everywhere we translate a GURL into a QUrl (quite a few places in the codebase), or if it’s ok to keep it confined there.

To post a comment you must log in.
lp:~osomon/oxide/tolerant-GURL2QUrl updated
1057. By Olivier Tilloy

Add a debug check.

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

Not needed any longer as bug #1447617 is invalid now.

review: Disapprove

Unmerged revisions

1057. By Olivier Tilloy

Add a debug check.

1056. By Olivier Tilloy

Be more tolerant when converting a GURL to a QUrl when calling QDesktopServices::openUrl().

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qt/core/browser/oxide_qt_browser_platform_integration.cc'
--- qt/core/browser/oxide_qt_browser_platform_integration.cc 2015-03-24 17:06:40 +0000
+++ qt/core/browser/oxide_qt_browser_platform_integration.cc 2015-04-24 09:02:06 +0000
@@ -27,6 +27,7 @@
27#include <QtGui/qpa/qplatformnativeinterface.h>27#include <QtGui/qpa/qplatformnativeinterface.h>
2828
29#include "base/lazy_instance.h"29#include "base/lazy_instance.h"
30#include "base/logging.h"
30#include "base/message_loop/message_loop_proxy.h"31#include "base/message_loop/message_loop_proxy.h"
31#include "content/public/browser/browser_thread.h"32#include "content/public/browser/browser_thread.h"
32#include "url/gurl.h"33#include "url/gurl.h"
@@ -46,8 +47,31 @@
46namespace {47namespace {
47base::LazyInstance<QPointer<QThread> > g_io_thread;48base::LazyInstance<QPointer<QThread> > g_io_thread;
4849
50QUrl GURL2QUrl(const GURL& url) {
51 if (!url.is_valid()) {
52 return QUrl();
53 }
54 QUrl parsed = QUrl(QString::fromStdString(url.spec()));
55 if (parsed.isValid()) {
56 return parsed;
57 }
58 // Special case where GURL’s parser is more tolerant than QUrl’s
59 // (see https://launchpad.net/bugs/1447617).
60 DCHECK(!url.has_host());
61 QUrl tolerant;
62 tolerant.setScheme(QString::fromStdString(url.scheme()));
63 tolerant.setPath(QString::fromStdString(url.path()));
64 if (url.has_query()) {
65 tolerant.setQuery(QString::fromStdString(url.query()));
66 }
67 if (url.has_ref()) {
68 tolerant.setFragment(QString::fromStdString(url.ref()));
69 }
70 return tolerant;
71}
72
49void LaunchURLExternallyOnUIThread(const GURL& url) {73void LaunchURLExternallyOnUIThread(const GURL& url) {
50 QDesktopServices::openUrl(QUrl(QString::fromStdString(url.spec())));74 QDesktopServices::openUrl(GURL2QUrl(url));
51}75}
5276
53}77}

Subscribers

People subscribed via source and target branches