You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/12/14 19:28:00 UTC

[jira] [Commented] (CB-3360) Set custom InAppBrowser user-agent

    [ https://issues.apache.org/jira/browse/CB-3360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16291409#comment-16291409 ] 

ASF GitHub Bot commented on CB-3360:
------------------------------------

surajpindoria closed pull request #174: CB-3360 Fix Oxide version & support _system target for ubuntu
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/174
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/ubuntu/InAppBrowser.qml b/src/ubuntu/InAppBrowser.qml
index 781e8a6e..bb8a4189 100644
--- a/src/ubuntu/InAppBrowser.qml
+++ b/src/ubuntu/InAppBrowser.qml
@@ -23,7 +23,7 @@
 import QtQuick 2.0
 import Ubuntu.Components.Popups 0.1
 import Ubuntu.Components 0.1
-import com.canonical.Oxide 1.0
+import com.canonical.Oxide 1.10
 
 Rectangle {
     anchors.fill: parent
diff --git a/src/ubuntu/inappbrowser.cpp b/src/ubuntu/inappbrowser.cpp
index c5a9e64a..cd9f13a8 100644
--- a/src/ubuntu/inappbrowser.cpp
+++ b/src/ubuntu/inappbrowser.cpp
@@ -50,15 +50,25 @@ const char LOADSTART_EVENT[] = "{type: 'loadstart'}";
 const char LOADSTOP_EVENT[] = "{type: 'loadstop'}";
 const char LOADERROR_EVENT[] = "{type: 'loaderror'}";
 
-void Inappbrowser::open(int cb, int, const QString &url, const QString &, const QString &) {
+void Inappbrowser::open(int cb, int,
+                        const QString &url,
+                        const QString &windowName,
+                        const QString &windowFeatures) {
     assert(_eventCb == 0);
 
     _eventCb = cb;
 
-    QString path = m_cordova->get_app_dir() + "/../qml/InAppBrowser.qml";
-    QString qml = QString(code)
-      .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(url));
-    m_cordova->execQML(qml);
+    if (windowName == "_blank") {
+      QString path = m_cordova->get_app_dir() + "/../qml/InAppBrowser.qml";
+      QString qml = QString(code)
+        .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(url));
+
+      m_cordova->execQML(qml);
+    } else if (windowName == "_system") {
+      // TODO: use ual?
+      m_cordova->execQML(
+          QString("Qt.openUrlExternally(\"%1\")").arg(url));
+    }
 }
 
 void Inappbrowser::show(int, int) {
diff --git a/src/ubuntu/inappbrowser.h b/src/ubuntu/inappbrowser.h
index 1da4e033..a31d5606 100644
--- a/src/ubuntu/inappbrowser.h
+++ b/src/ubuntu/inappbrowser.h
@@ -44,7 +44,9 @@ class Inappbrowser: public CPlugin {
     }
 
 public slots:
-    void open(int cb, int, const QString &url, const QString &windowName, const QString &windowFeatures);
+    void open(int cb, int,
+              const QString &url, const QString &windowName,
+              const QString &windowFeatures);
     void show(int, int);
     void close(int, int);
     void injectStyleFile(int cb, int, const QString&, bool);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Set custom InAppBrowser user-agent
> ----------------------------------
>
>                 Key: CB-3360
>                 URL: https://issues.apache.org/jira/browse/CB-3360
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-plugin-inappbrowser
>    Affects Versions: 2.7.0
>         Environment: iOS, Android, WP8, BlackBerry
>            Reporter: Kevin Simpson
>            Assignee: Shazron Abdullah
>            Priority: Minor
>              Labels: Cordova, InAppBrowser, android
>
> Currently you can set a custom user-agent for the main Cordova webview by overriding the init method for the DroidGap class. However, when opening a page in the InAppBrowser, that webview will still contain the default user-agent.
> There are two solutions that I have thought of to this:
> 1. Set the user-agent of the InAppBrowser webview to whatever the user-agent in the Cordova webview is set to. (This is what I am currently doing, as it was a one line change, but it requires rebuilding Cordova manually)
> 2. Have some sort of configuration option to set the user-agent for the InAppBrowser. This would allow a different user-agent from the main webview, but is also a more involved change.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org