Announcement

Collapse
No announcement yet.

What happens in the OnBeforePopup function?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What happens in the OnBeforePopup function?

    Someone from github has asked me a question. And the answer is the following.
    This answer will show you how difficult it is to design a program.
    Because of poor design, programmers suffer seriously.
    It's a pain if you don't get the pointer you need as a function's parameter at the moment
    you absolutely need it.
    Especially when this happens in an asynchronous function, the pain doubles or triples.
    So if you can design a nice API that's easy for programmers to use, that's god.
    However, most designers prefer singleton designs because they are not as good as
    programmers in enterprise companies. Trying a better design may have a lesser effect
    than a singleton. I think it's better to have a singleton that puts all the information into
    one class. It's a dirty design, but at least it doesn't hurt everyone.
    It is a wise saying of the day. Remember A good design is sometimes even a dirty design.
    To avoid the same problem now, you need to modify the source code yourself.
    Become a hacker!


    when the page have form and the action is other page , it will not working properly:
    Page1:

    <body>
    <form id="form1" target="_blank" action="web2.aspx" method="post">
    <input type="text" id="input1" name="input1" />
    <input type="text" id="input2" name="input2" />
    </form>
    <div>
    <input type="button" onclick="fun_post();" value="posttest" />
    </div>
    <script type="text/javascript">
    function fun_post()
    {
    form1.submit();
    }
    </script>
    </body>

    ========================

    then the web2.aspx can not get the post data !!

    public partial class web2 : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    string TemName = "", TemValue = "";
    int temlen = this.Page.Request.Form.Count;
    if (temlen <= 0) { return; }
    int i = 0;
    for(i=0;i<=temlen-1;i++)
    {
    TemValue = this.Page.Request.Form;
    TemName = this.Page.Request.Form.Keys;
    this.Page.Response.Write(TemName + ":" + TemValue + "<br>");
    }
    }
    }

    ========================
    I am currently modifying the life_span_handler_xxx.cc files in the libcef project.
    Because, I am modifying to make OnBeforePopup to pass the ICefRequest pointer.
    And this ICefRequest parameter must exist as a parameter of OnBeforePopup function
    to extract PostData. I'm currently blocking all the process of opening a new window
    inside the OnBeforePopup function. And I'm creating a custom window inside the
    OnBeforePopup function. However, when I create a new window, I can't send the FORM
    data to the new window because I simply create a browser with just the text URL
    information. Therefore, this problem must be solved. Currently when I prevent a new
    window from opening in the OnBeforePopup function, the OnBeforeBrowse function
    is not called. Unfortunately, the OnBeforeBrowse function has an ICefRequest
    parameter. Even worse, there is no way to prevent a new window from opening when the
    OnBeforeBrowse function is executed. This is a very chronic problem for all libcef
    teams. So I am modifying the OnBeforePopup function to extract the ICefRequest
    parameter. If ICefRequest is passed as a parameter of OnBeforePopup function, you can
    pass POST request data to custom window as "(TChromium * chrome)-> LoadRequest (request)"
    while creating a new window. I hope this works.

    https://github.com/cefsharp/CefSharp/issues/1267
    https://bitbucket.org/chromiumembedded/cef/issues/1949/
    https://groups.google.com/forum/#!to...ue/XhunSAvu1zY
Working...
X