webView:decisionListener not working for iframe











up vote
0
down vote

favorite












I use cocoa calls to set an webView:decidePolicyForNavigationAction:request:frame:decisionListener:



By this callback, I can decode about what to do with the links some user clicked. But sadly, if there is some iframe inside, I do not get the callback for the links inside of the iframe.



I tried using findFrameNamed: function to get the webFrame of the iframe (seem to work) and then getting the underlying webView to set the decisionListener there, but it does not fire.



Any hints?



PS. I use PureBasic, calling the Cocoa functions manually. So I can only add my PB code, if this is of any help:



Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Global delegateClass = CocoaMessage(0, appDelegate, "class")

ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
; handle all links like it is _blank target. We do not want something else in regify client.
Protected URL = CocoaMessage(0, request, "URL")
Protected URLText.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)
Debug "URL: " + URLText.s
EndProcedure

class_addMethod(delegateClass,
sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"),
@PolicyDecisionMaker(),
"v@:@@@@@")

Procedure.i SetMacWebgadgetTargetSupport(WebgadgetID.i, iFrameName.s = "")
If iFrameName.s = ""
CocoaMessage(0, GadgetID(WebgadgetID.i), "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf

Protected macMainFrame = CocoaMessage(0, GadgetID(WebgadgetID), "mainFrame")
Protected maciFrameView = CocoaMessage(0, macMainFrame, "findFrameNamed:$", @iFrameName.s); get iframe
If maciFrameView <> 0
; Set appDelegate on the given iFrame
Protected macWebView = CocoaMessage(0, maciFrameView, "webView") ; get webView object
CocoaMessage(0, macWebView, "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
ProcedureReturn #False

EndProcedure


The above works fine on normal HTML (eg file://somefile.html). But it fails for iFrame with links inside.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I use cocoa calls to set an webView:decidePolicyForNavigationAction:request:frame:decisionListener:



    By this callback, I can decode about what to do with the links some user clicked. But sadly, if there is some iframe inside, I do not get the callback for the links inside of the iframe.



    I tried using findFrameNamed: function to get the webFrame of the iframe (seem to work) and then getting the underlying webView to set the decisionListener there, but it does not fire.



    Any hints?



    PS. I use PureBasic, calling the Cocoa functions manually. So I can only add my PB code, if this is of any help:



    Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
    Global delegateClass = CocoaMessage(0, appDelegate, "class")

    ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
    ; handle all links like it is _blank target. We do not want something else in regify client.
    Protected URL = CocoaMessage(0, request, "URL")
    Protected URLText.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)
    Debug "URL: " + URLText.s
    EndProcedure

    class_addMethod(delegateClass,
    sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"),
    @PolicyDecisionMaker(),
    "v@:@@@@@")

    Procedure.i SetMacWebgadgetTargetSupport(WebgadgetID.i, iFrameName.s = "")
    If iFrameName.s = ""
    CocoaMessage(0, GadgetID(WebgadgetID.i), "setPolicyDelegate:", appDelegate)
    ProcedureReturn #True
    EndIf

    Protected macMainFrame = CocoaMessage(0, GadgetID(WebgadgetID), "mainFrame")
    Protected maciFrameView = CocoaMessage(0, macMainFrame, "findFrameNamed:$", @iFrameName.s); get iframe
    If maciFrameView <> 0
    ; Set appDelegate on the given iFrame
    Protected macWebView = CocoaMessage(0, maciFrameView, "webView") ; get webView object
    CocoaMessage(0, macWebView, "setPolicyDelegate:", appDelegate)
    ProcedureReturn #True
    EndIf
    ProcedureReturn #False

    EndProcedure


    The above works fine on normal HTML (eg file://somefile.html). But it fails for iFrame with links inside.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I use cocoa calls to set an webView:decidePolicyForNavigationAction:request:frame:decisionListener:



      By this callback, I can decode about what to do with the links some user clicked. But sadly, if there is some iframe inside, I do not get the callback for the links inside of the iframe.



      I tried using findFrameNamed: function to get the webFrame of the iframe (seem to work) and then getting the underlying webView to set the decisionListener there, but it does not fire.



      Any hints?



      PS. I use PureBasic, calling the Cocoa functions manually. So I can only add my PB code, if this is of any help:



      Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
      Global delegateClass = CocoaMessage(0, appDelegate, "class")

      ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
      ; handle all links like it is _blank target. We do not want something else in regify client.
      Protected URL = CocoaMessage(0, request, "URL")
      Protected URLText.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)
      Debug "URL: " + URLText.s
      EndProcedure

      class_addMethod(delegateClass,
      sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"),
      @PolicyDecisionMaker(),
      "v@:@@@@@")

      Procedure.i SetMacWebgadgetTargetSupport(WebgadgetID.i, iFrameName.s = "")
      If iFrameName.s = ""
      CocoaMessage(0, GadgetID(WebgadgetID.i), "setPolicyDelegate:", appDelegate)
      ProcedureReturn #True
      EndIf

      Protected macMainFrame = CocoaMessage(0, GadgetID(WebgadgetID), "mainFrame")
      Protected maciFrameView = CocoaMessage(0, macMainFrame, "findFrameNamed:$", @iFrameName.s); get iframe
      If maciFrameView <> 0
      ; Set appDelegate on the given iFrame
      Protected macWebView = CocoaMessage(0, maciFrameView, "webView") ; get webView object
      CocoaMessage(0, macWebView, "setPolicyDelegate:", appDelegate)
      ProcedureReturn #True
      EndIf
      ProcedureReturn #False

      EndProcedure


      The above works fine on normal HTML (eg file://somefile.html). But it fails for iFrame with links inside.










      share|improve this question













      I use cocoa calls to set an webView:decidePolicyForNavigationAction:request:frame:decisionListener:



      By this callback, I can decode about what to do with the links some user clicked. But sadly, if there is some iframe inside, I do not get the callback for the links inside of the iframe.



      I tried using findFrameNamed: function to get the webFrame of the iframe (seem to work) and then getting the underlying webView to set the decisionListener there, but it does not fire.



      Any hints?



      PS. I use PureBasic, calling the Cocoa functions manually. So I can only add my PB code, if this is of any help:



      Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
      Global delegateClass = CocoaMessage(0, appDelegate, "class")

      ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
      ; handle all links like it is _blank target. We do not want something else in regify client.
      Protected URL = CocoaMessage(0, request, "URL")
      Protected URLText.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)
      Debug "URL: " + URLText.s
      EndProcedure

      class_addMethod(delegateClass,
      sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"),
      @PolicyDecisionMaker(),
      "v@:@@@@@")

      Procedure.i SetMacWebgadgetTargetSupport(WebgadgetID.i, iFrameName.s = "")
      If iFrameName.s = ""
      CocoaMessage(0, GadgetID(WebgadgetID.i), "setPolicyDelegate:", appDelegate)
      ProcedureReturn #True
      EndIf

      Protected macMainFrame = CocoaMessage(0, GadgetID(WebgadgetID), "mainFrame")
      Protected maciFrameView = CocoaMessage(0, macMainFrame, "findFrameNamed:$", @iFrameName.s); get iframe
      If maciFrameView <> 0
      ; Set appDelegate on the given iFrame
      Protected macWebView = CocoaMessage(0, maciFrameView, "webView") ; get webView object
      CocoaMessage(0, macWebView, "setPolicyDelegate:", appDelegate)
      ProcedureReturn #True
      EndIf
      ProcedureReturn #False

      EndProcedure


      The above works fine on normal HTML (eg file://somefile.html). But it fails for iFrame with links inside.







      macos cocoa iframe webkit






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 15 hours ago









      Volker Schmid

      12




      12





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265978%2fwebviewdecisionlistener-not-working-for-iframe%23new-answer', 'question_page');
          }
          );

          Post as a guest





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265978%2fwebviewdecisionlistener-not-working-for-iframe%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          How to send String Array data to Server using php in android

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Is anime1.com a legal site for watching anime?