<commit_before>package com.codeborne.selenide.webdriver;

import com.codeborne.selenide.Browser;
import com.codeborne.selenide.Config;
import org.apache.commons.lang3.math.NumberUtils;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class ChromeDriverFactory extends AbstractDriverFactory {
  private static final Logger log = LoggerFactory.getLogger(ChromeDriverFactory.class);

  @Override
  WebDriver create(Config config, Proxy proxy) {
    ChromeOptions options = createChromeOptions(config, proxy);
    return new ChromeDriver(options);
  }

  @Override
  boolean supports(Config config, Browser browser) {
    return browser.isChrome();
  }

  ChromeOptions createChromeOptions(Config config, Proxy proxy) {
    ChromeOptions options = new ChromeOptions();
    options.setHeadless(config.headless());
    if (!config.browserBinary().isEmpty()) {
      log.info("Using browser binary: {}", config.browserBinary());
      options.setBinary(config.browserBinary());
    }
    options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
    options.addArguments("--proxy-bypass-list=<-loopback>");
    options.merge(createCommonCapabilities(config, proxy));
    transferChromeOptionsFromSystemProperties(config, options);
    log.debug("Chrome options: {}", options.toString());
    return options;
  }


  /**<commit_msg>#1119 disable annoying popup about extensions in Chrome<commit_after>package com.codeborne.selenide.webdriver;

import com.codeborne.selenide.Browser;
import com.codeborne.selenide.Config;
import org.apache.commons.lang3.math.NumberUtils;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class ChromeDriverFactory extends AbstractDriverFactory {
  private static final Logger log = LoggerFactory.getLogger(ChromeDriverFactory.class);

  @Override
  WebDriver create(Config config, Proxy proxy) {
    ChromeOptions options = createChromeOptions(config, proxy);
    return new ChromeDriver(options);
  }

  @Override
  boolean supports(Config config, Browser browser) {
    return browser.isChrome();
  }

  ChromeOptions createChromeOptions(Config config, Proxy proxy) {
    ChromeOptions options = new ChromeOptions();
    options.setHeadless(config.headless());
    if (!config.browserBinary().isEmpty()) {
      log.info("Using browser binary: {}", config.browserBinary());
      options.setBinary(config.browserBinary());
    }
    options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation", "load-extension"});
    options.addArguments("--proxy-bypass-list=<-loopback>");
    options.merge(createCommonCapabilities(config, proxy));
    transferChromeOptionsFromSystemProperties(config, options);
    log.debug("Chrome options: {}", options.toString());
    return options;
  }


  /**
{'fraction_non_alphanumeric': 0.1171919770773639, 'fraction_numerical': 0.0028653295128939827, 'mean_word_length': 5.3014440433212995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1566796', 'n_tokens_mistral': 1026, 'n_tokens_neox': 1008, 'n_words': 198}