package org.openqa.selenium.server.browserlaunchers;

import java.io.IOException;

import org.openqa.selenium.server.SeleniumServer;


/**
 * launcher for IE under proxy injection mode
 * 
 * In proxy injection mode, the selenium server is a proxy for all traffic from the browser, 
 * not just traffic going to selenium-server URLs.  The incoming HTML is modified 
 * to include selenium's JavaScript, which then controls the test page from within (as 
 * opposed to controlling the test page from a different window, as selenium remote 
 * control normally does).
 * 
 * @author nelsons
 *
 */
public class ProxyInjectionInternetExplorerCustomProxyLauncher extends InternetExplorerCustomProxyLauncher {

    public ProxyInjectionInternetExplorerCustomProxyLauncher(int port, String sessionId) {
        super(port, sessionId);
    }
    
    public ProxyInjectionInternetExplorerCustomProxyLauncher(int port, String sessionId, String browserLaunchLocation) {
        super(port, sessionId, browserLaunchLocation);
    }    
    
    @Override
    protected void changeRegistrySettings() throws IOException {
        customPACappropriate = false;
        super.changeRegistrySettings();
        WindowsUtils.writeBooleanRegistryValue(REG_KEY_BASE + REG_KEY_PROXY_ENABLE, true);
        WindowsUtils.writeStringRegistryValue(REG_KEY_BASE + REG_KEY_PROXY_SERVER, "127.0.0.1:" + SeleniumServer.getPortDriversShouldContact());

        // need at least 1 xmlHttp connection per frame/window
        WindowsUtils.writeIntRegistryValue(REG_KEY_BASE + REG_KEY_MAX_CONNECTIONS_PER_1_0_SVR, 256);
        WindowsUtils.writeIntRegistryValue(REG_KEY_BASE + REG_KEY_MAX_CONNECTIONS_PER_1_1_SVR, 256);
    }
}

@@ -717,16 +717,73 @@
 ncher %7B%0D
+%0A    private static boolean changeMaxConnections = true;%0D
 %0A%0D%0A    p
@@ -1507,24 +1507,65 @@
 tact());%0D%0A%0D%0A
+        if (changeMaxConnections) %7B%0D%0A    
         // n
@@ -1616,16 +1616,20 @@
 window%0D%0A
+    
         
@@ -1722,32 +1722,36 @@
  256);%0D%0A        
+   
+ 
 WindowsUtils.wri
@@ -1824,22 +1824,226 @@
 SVR, 256);%0D%0A
+        %7D%0D%0A    %7D%0D%0A%0D%0A    public static void setChangeMaxConnections(boolean changeMaxConnections) %7B%0D%0A        ProxyInjectionInternetExplorerCustomProxyLauncher.changeMaxConnections = changeMaxConnections;%0D%0A
     %7D%0D%0A%7D%0D%0A

allow developers to programatically disable the changing of the max connections