title: What is NewWindow2 and NewWindow3 in WebForm/WebBrowser
body: <p>I am trying to convert our current WebForms app to use CefSharp browser which uses ChromimumWebBrowser. I came across the below in current code:</p>
  <pre><code>private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
      if (!newWindow3ListenerAdded) {        
          newWindow3ListenerAdded = true;
          SHDocVw.WebBrowser browser = (SHDocVw.WebBrowser)webBrowser.ActiveXInstance;        
          browser.NewWindow3 += Browser_NewWindow3;
          browser.NewWindow2 += browser_NewWindow2;
      }
  }
  
  private void browser_NewWindow2(ref object ppDisp, ref bool Cancel)
  {
      webform.webBrowser.GoBack();
      ppDisp = webform.webBrowser.ActiveXInstance;
      webform.Show();
  }
  
  private void Browser_NewWindow3(ref object ppDisp, ref bool cancel, uint dwFlags, string sourceUrl, string targetUrl) 
  {
      cancel = true;
      if (targetUrl.Contains(&quot;.pdf&quot;)) {
          WebForm webForm = new WebForm();
          webForm.Text = targetUrl;
          webForm.Navigate(targetUrl);
          webForm.Show();
      } else {
          webBrowser.Navigate(targetUrl);
      }
  }
  </code></pre>
  <p>Could someone please guide me in converting this to Cef. I know I have to implement OnBeforePopup() in ILifeSpanHandler. But how exactly can I write the logic to load pdf/GoBack/Navigate(targetUrl) for different types of popups.</p>
  <p>I think I can easily convert Browser_NewWindow3() the way it is (checking if targetUrl.Contains(&quot;.pdf&quot;)) but on what condition do I handle browser_NewWindow2() logic i.e. webBrowser.GoBack(); ?</p>
  <p>This is what I tried,</p>
  <pre><code>OnBeforePopup() {
  newBrowser = null;
      if (targetUrl.Contains(&quot;.pdf&quot;)) {
         CefForm cefForm = new CefForm();
         cefForm.Text = targetUrl;
         cefForm.Navigate(targetUrl);
         cefForm.Show();
         return false;
      } else {
         browserControl.Load(targetUrl);
         return true;
      }
  }
  </code></pre>
  <p>But how do I handle browser_NewWindow2 logic ?</p>