public Browser(float zoomLevel = 0.0f)
 {
     if (!CefHelper.CefInited)
     {
         string   str  = "Bluestacks/" + RegistryManager.Instance.ClientVersion;
         string[] args = new string[0];
         Logger.Info("Init cef");
         string mBSTProcessIdentifier = str;
         CefHelper.InitCef(args, mBSTProcessIdentifier);
     }
     this.Loaded             += new RoutedEventHandler(this.Browser_Loaded);
     this.LoadingStateChange += new LoadingStateChangeEventHandler(this.Browser_LoadingStateChange);
     this.mCustomZoomLevel    = zoomLevel;
     if (RegistryManager.Instance.CefDevEnv != 1)
     {
         return;
     }
     this.mAllowDevTool  = true;
     this.mDevToolHeader = this.StartUrl;
 }
        internal static bool InitCef(string[] args, string mBSTProcessIdentifier)
        {
            try
            {
                Logger.Info("Install Boot: CefRuntime.Load");
                CefRuntime.Load(RegistryManager.Instance.CefDataPath);
            }
            catch (DllNotFoundException ex)
            {
                Logger.Info("Install Boot: DllNotFoundException");
                int num = (int)MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Hand);
                return(false);
            }
            catch (CefRuntimeException ex)
            {
                Logger.Info("Install Boot: CefRuntimeException");
                int num = (int)MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Hand);
                return(false);
            }
            catch (Exception ex)
            {
                Logger.Info("Install Boot: ex");
                int num = (int)MessageBox.Show(ex.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Hand);
                return(false);
            }
            CefMainArgs args1     = new CefMainArgs(args);
            CefHelper   cefHelper = new CefHelper();

            CefRuntime.EnableHighDpiSupport();
            if (CefRuntime.ExecuteProcess(args1, (CefApp)cefHelper, IntPtr.Zero) != -1)
            {
                return(false);
            }
            string str = "Mozilla/5.0(Windows NT 6.2; Win64; x64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" + mBSTProcessIdentifier;

            if (!SystemUtils.IsOs64Bit())
            {
                str = "Mozilla/5.0(Windows NT 6.2; WOW64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" + mBSTProcessIdentifier;
            }
            CefSettings settings = new CefSettings()
            {
                SingleProcess = false,
                WindowlessRenderingEnabled = true,
                MultiThreadedMessageLoop   = true,
                LogSeverity           = CefLogSeverity.Verbose,
                BackgroundColor       = new CefColor(byte.MaxValue, (byte)39, (byte)41, (byte)65),
                CachePath             = Path.Combine(RegistryManager.Instance.CefDataPath, "Cache"),
                PersistSessionCookies = true,
                UserAgent             = str,
                Locale = RegistryManager.Instance.UserSelectedLocale
            };

            if (RegistryManager.Instance.CefDebugPort != 0)
            {
                settings.RemoteDebuggingPort = RegistryManager.Instance.CefDebugPort;
            }
            try
            {
                CefRuntime.Initialize(args1, settings, (CefApp)cefHelper, IntPtr.Zero);
                Logger.Info("Install Boot: cef Initialized");
            }
            catch (CefRuntimeException ex)
            {
                int num = (int)MessageBox.Show(ex.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Hand);
                return(false);
            }
            CefHelper.CefInited = true;
            Logger.Info("Install Boot: cef Initialize completed");
            return(true);
        }
示例#3
0
        public static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            App.InitExceptionAndLogging();
            ProcessUtils.LogParentProcessDetails();
            if (args != null)
            {
                App.ParseWebMagnetArgs(ref args);
                Opt.Instance.Parse(args);
            }
            string path = Path.Combine(Path.Combine(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory.Trim('\\')).FullName, "Engine"), "Oem.cfg");

            Oem.CurrentOemFilePath = System.IO.File.Exists(path) ? path : Path.Combine(RegistryManager.Instance.EngineDataDir, "Oem.cfg");
            PortableInstaller.CheckAndRunPortableInstaller();
            if (!RegistryManager.Instance.Guest.ContainsKey(Opt.Instance.vmname))
            {
                Opt.Instance.vmname = "Android";
            }
            BlueStacks.Common.Strings.CurrentDefaultVmName = Opt.Instance.vmname;
            if (Opt.Instance.mergeCfg)
            {
                KMManager.MergeConfig(Opt.Instance.newPDPath);
                Environment.Exit(0);
            }
            string mBSTProcessIdentifier = "Bluestacks/" + RegistryManager.Instance.ClientVersion;

            if (!string.Join(string.Empty, args).Contains(mBSTProcessIdentifier))
            {
                Logger.Info("BOOT_STAGE: Client starting");
                if (Oem.IsOEMDmm)
                {
                    Logger.Info("checking DMMGamePlayer process");
                    if (!ProcessUtils.FindProcessByName("DMMGamePlayer") && !ProcessUtils.FindProcessByName("dmmemulatorsandboxlauncher"))
                    {
                        Logger.Info("DMM game player not running, so exiting");
                        Environment.Exit(0);
                    }
                }
                RegistryManager.ClientThemeName = RegistryManager.Instance.GetClientThemeNameFromRegistry();
                if (Oem.IsOEMDmm || !BlueStacksUpdater.CheckIfDownloadedFileExist())
                {
                    App app = new App();
                    app.Startup     += new StartupEventHandler(App.Application_Startup);
                    app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
                    app.InitializeComponent();
                    App.CheckIfAlreadyRunning();
                    RegistryManager.Instance.ClientLaunchParams = Opt.Instance.Json;
                    App.defaultResolution = new Fraction((long)RegistryManager.Instance.Guest[BlueStacks.Common.Strings.CurrentDefaultVmName].GuestWidth, (long)RegistryManager.Instance.Guest[BlueStacks.Common.Strings.CurrentDefaultVmName].GuestHeight);
                    SystemEvents.DisplaySettingsChanged += new EventHandler(App.HandleDisplaySettingsChanged);
                    BGPHelper.InitHttpServerAsync();
                    BlueStacksUIUtils.RunInstance(BlueStacks.Common.Strings.CurrentDefaultVmName, Opt.Instance.h, Opt.Instance.Json);
                    AppUsageTimer.SessionEventHandler();
                    if (!Oem.IsOEMDmm)
                    {
                        PromotionManager.ReloadPromotionsAsync();
                        GrmManager.UpdateGrmAsync((IEnumerable <string>)null);
                        GuidanceCloudInfoManager.Instance.AppsGuidanceCloudInfoRefresh();
                    }
                    if (!FeatureManager.Instance.IsHtmlHome)
                    {
                        BlueStacksUIUtils.DictWindows[BlueStacks.Common.Strings.CurrentDefaultVmName].CreateFirebaseBrowserControl();
                    }
                    MemoryManager.TrimMemory(true);
                    app.Run();
                }
                else
                {
                    BlueStacksUpdater.HandleUpgrade(RegistryManager.Instance.DownloadedUpdateFile);
                }
            }
            else
            {
                CefHelper.InitCef(args, mBSTProcessIdentifier);
            }
            AppUsageTimer.DetachSessionEventHandler();
            CefRuntime.Shutdown();
            App.ExitApplication();
        }