public UserAgent(String userAgentString) {
    String userAgentLowercaseString =
        userAgentString == null ? null : userAgentString.toLowerCase();
    Browser browser = Browser.parseUserAgentLowercaseString(userAgentLowercaseString);

    OperatingSystem operatingSystem = OperatingSystem.UNKNOWN;

    // BOTs don't have an interesting OS for us
    if (browser != Browser.BOT)
      operatingSystem = OperatingSystem.parseUserAgentLowercaseString(userAgentLowercaseString);

    this.operatingSystem = operatingSystem;
    this.browser = browser;
    this.id = ((operatingSystem.getId() << 16) + browser.getId());
    this.userAgentString = userAgentString;
  }
 private URL buildURL(URL url) throws UnsupportedEncodingException, MalformedURLException {
   String fullURLString = url.toString();
   fullURLString += "/runner";
   boolean hasFirstParameter = false;
   if (overrideURL != null) {
     fullURLString += "?url=" + URLEncoder.encode(overrideURL, "UTF-8");
     hasFirstParameter = true;
   } else if (configuration.getTestURL() != null) {
     fullURLString += "?url=" + URLEncoder.encode(configuration.getTestURL().toString(), "UTF-8");
     hasFirstParameter = true;
   }
   if (remoteBrowser != null) {
     fullURLString += (hasFirstParameter ? "&" : "?");
     fullURLString += "browserId=" + remoteBrowser.getId();
   }
   return new URL(fullURLString);
 }
Beispiel #3
0
 /**
  * Set the active/visible Browser.
  *
  * @param browser The Browser to make selected.
  */
 public void setCurrentBrowser(Browser browser) {
   Tab tab = Tabs.getInstance().getTab(browser.getId());
   if (tab != null) {
     Tabs.getInstance().selectTab(tab.getId());
   }
 }
Beispiel #4
0
 /**
  * Remove a Browser from the GeckoView container.
  *
  * @param browser The Browser to remove.
  */
 public void removeBrowser(Browser browser) {
   Tab tab = Tabs.getInstance().getTab(browser.getId());
   if (tab != null) {
     Tabs.getInstance().closeTab(tab);
   }
 }
 public UserAgent(OperatingSystem operatingSystem, Browser browser) {
   this.operatingSystem = operatingSystem;
   this.browser = browser;
   this.id = ((operatingSystem.getId() << 16) + browser.getId());
 }