Browse files

MythBrowser: Change the user-agent string reported by the browser wid…

…get.

This replaces the name 'Safari' with 'MythBrowser' in the default user-agent
string sent by MythBrowser. This fixes a problem with the BBC iPlayer thinking
we are running on an unsupported mobile phone and refusing to do anything!

This backports f19c610 from master.
  • Loading branch information...
1 parent c502e0d commit 8028a5875f6a43ec83bff7c775ff2125f1a46a98 Paul Harrison committed Aug 17, 2011
Showing with 23 additions and 0 deletions.
  1. +12 −0 mythtv/libs/libmythui/mythuiwebbrowser.cpp
  2. +11 −0 mythtv/libs/libmythui/mythuiwebbrowser.h
View
12 mythtv/libs/libmythui/mythuiwebbrowser.cpp
@@ -31,6 +31,17 @@
#include "mythuihelper.h"
#include "mythcorecontext.h"
+
+MythWebPage::MythWebPage(QObject *parent)
+ : QWebPage(parent)
+{
+}
+
+QString MythWebPage::userAgentForUrl(const QUrl &url) const
+{
+ return QWebPage::userAgentForUrl(url).replace("Safari", "MythBrowser");
+}
+
/**
* @class MythWebView
* @brief Subclass of QWebView
@@ -39,6 +50,7 @@
MythWebView::MythWebView(QWidget *parent, MythUIWebBrowser *parentBrowser)
: QWebView(parent)
{
+ setPage(new MythWebPage(this));
m_parentBrowser = parentBrowser;
connect(this->page(), SIGNAL(unsupportedContent(QNetworkReply *)),
View
11 mythtv/libs/libmythui/mythuiwebbrowser.h
@@ -17,6 +17,17 @@
class MythUIWebBrowser;
+class MythWebPage : public QWebPage
+{
+ Q_OBJECT
+
+ public:
+ MythWebPage(QObject *parent = 0);
+
+ protected:
+ virtual QString userAgentForUrl(const QUrl &url) const;
+};
+
class MythWebView : public QWebView
{
Q_OBJECT

0 comments on commit 8028a58

Please sign in to comment.