<commit_before>﻿using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Linq;

namespace FreenetTray.Browsers
{
    class Firefox : IBrowser
    {
        /*
         * https://developer.mozilla.org/en-US/docs/Adding_Extensions_using_the_Windows_Registry
         * is out of date as of this writing - it uses "Mozilla Firefox" instead of "Firefox".
         * Earlier versions use HKEY_LOCAL_MACHINE but current ones use HKEY_CURRENT_USER.
         */
        readonly string[] _registryKeys = {
                                            @"HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox",
                                            @"HKEY_CURRENT_USER\SOFTWARE\Mozilla\Mozilla Firefox",
                                          };

        private readonly bool _isInstalled;
        private readonly Version _version;
        private readonly string _path;

        public Firefox()
        {
            _version = GetVersion();
            _path = GetPath();
            _isInstalled = _version != null;
        }

        public bool Open(Uri target)
        {
            if (!IsAvailable())
            {
                return false;
            }
            /*<commit_msg>Fix Firefox appearing as usable when exe path not found<commit_after>﻿using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Linq;

namespace FreenetTray.Browsers
{
    class Firefox : IBrowser
    {
        /*
         * https://developer.mozilla.org/en-US/docs/Adding_Extensions_using_the_Windows_Registry
         * is out of date as of this writing - it uses "Mozilla Firefox" instead of "Firefox".
         * Earlier versions use HKEY_LOCAL_MACHINE but current ones use HKEY_CURRENT_USER.
         */
        readonly string[] _registryKeys = {
                                            @"HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox",
                                            @"HKEY_CURRENT_USER\SOFTWARE\Mozilla\Mozilla Firefox",
                                          };

        private readonly bool _isInstalled;
        private readonly Version _version;
        private readonly string _path;

        public Firefox()
        {
            _version = GetVersion();
            _path = GetPath();
            _isInstalled = _version != null && _path != null;
        }

        public bool Open(Uri target)
        {
            if (!IsAvailable())
            {
                return false;
            }
            /*
{'fraction_non_alphanumeric': 0.07416364369205965, 'fraction_numerical': 0.0016122531237404273, 'mean_word_length': 1.5640495867768596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1831423', 'n_tokens_mistral': 638, 'n_tokens_neox': 607, 'n_words': 159}