code: private void writeOEXtoWidgetsDat(String wuid, File oexpath) throws IOException {
      // Define a path relative to the profile directory. Don't use an absolute path,
      // because that will break when used with the Remote web driver.
      String oexpathRelative = "{LargePreferences}widgets/" + oexpath.getName();
  
      String widgetString = Files.toString(widgetsDat, Charsets.UTF_8);
      int beforePreferencesEndTag = widgetString.lastIndexOf("</preferences>");
      if (beforePreferencesEndTag == -1) {
        throw new WebDriverException("</preferences> not found in " + widgetsDat.getPath());
      }
      String widgetDatSection = String.format(WIDGET_DAT_ITEM, wuid, oexpathRelative);
      // Insert the new <section ..> ... </section> before </preferences>
      widgetString = widgetString.substring(0, beforePreferencesEndTag)
                     + widgetDatSection
                     + widgetString.substring(beforePreferencesEndTag);
      Files.write(widgetString, widgetsDat, Charsets.UTF_8);
    }
docs: Install the extension by writing to widgets.dat
  
  @param wuid    Unique identifier of the widget.
  @param oexpath Location of .oex file within profile