private void InitializeCEF() { CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/GPMDP"; settings.WindowlessRenderingEnabled = true; settings.CefCommandLineArgs.Add("enable-smooth-scrolling", "1"); settings.CefCommandLineArgs.Add("enable-overlay-scrollbar", "1"); settings.CefCommandLineArgs.Add("high-dpi-support", "1"); settings.CefCommandLineArgs.Add("force-device-scale-factor", MaterialSkin.Utilities.DPIMath.ratioX(this).ToString()); if (Environment.Is64BitProcess) { settings.CefCommandLineArgs.Add("ppapi-flash-path", "Resources\\pepflashplayer64_20_0_0_267.dll"); } else { settings.CefCommandLineArgs.Add("ppapi-flash-path", "Resources\\pepflashplayer32_20_0_0_267.dll"); } settings.CefCommandLineArgs.Add("ppapi-flash-version", "20.0.0.267"); Cef.Initialize(settings); GPMBrowser = new CefSharp.WinForms.ChromiumWebBrowser("https://play.google.com/music/listen") { // Use this to inject our theming and modding javascript code ResourceHandlerFactory = new GPMResouceHandlerFactory(), // Stop that silly right click menu appearing MenuHandler = new GPMMenuHandler() }; GPMBrowser.RegisterAsyncJsObject("csharpinterface", new JSBound(this)); GPMBrowser.DragHandler = new GPMDragHandler(); GPMBrowser.Dock = DockStyle.Fill; Controls.Add(GPMBrowser); }
public MainWindow() { if (!Directory.Exists(cacheLoc)) { Directory.CreateDirectory(cacheLoc); } CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = cacheLoc; Cef.Initialize(settings); InitializeComponent(); cefBrowser.LoadingStateChanged += CefBrowser_LoadingStateChanged; }
private void InitializeCEF() { CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/GPMDP"; settings.WindowlessRenderingEnabled = true; settings.CefCommandLineArgs.Add("enable-smooth-scrolling", "1"); settings.CefCommandLineArgs.Add("enable-overlay-scrollbar", "1"); settings.CefCommandLineArgs.Add("high-dpi-support", "1"); if (Environment.Is64BitProcess) { settings.CefCommandLineArgs.Add("ppapi-flash-path", "Resources\\pepflashplayer64_20_0_0_267.dll"); } else { settings.CefCommandLineArgs.Add("ppapi-flash-path", "Resources\\pepflashplayer32_20_0_0_267.dll"); } settings.CefCommandLineArgs.Add("ppapi-flash-version", "20.0.0.267"); Cef.Initialize(settings); GPMBrowser = new CefSharp.WinForms.ChromiumWebBrowser("https://play.google.com/music/listen") { // Use this to inject our theming and modding javascript code ResourceHandlerFactory = new GPMResouceHandlerFactory(), // Stop that silly right click menu appearing MenuHandler = new GPMMenuHandler() }; GPMBrowser.RegisterAsyncJsObject("csharpinterface", new JSBound(this)); GPMBrowser.DragHandler = new GPMDragHandler(); GPMBrowser.Dock = DockStyle.Fill; Controls.Add(GPMBrowser); }
public static void Main(string[] args) { watch = Stopwatch.StartNew(); options = new Options(); if (!CommandLine.Parser.Default.ParseArguments(args, options)) { //Show the help screen and return if option requirements are not met. return; } var settings = new CefSharp.CefSettings() { //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data CachePath = options.cacheLocation }; //Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); // Create the offscreen Chromium browser. browser = new ChromiumWebBrowser(options.Url); // An event that is fired when the first page is finished loading. // This returns to us from another thread. browser.LoadingStateChanged += BrowserLoadingStateChanged; // Wait on the finished event screenShotFinished.WaitOne(); // Clean up Chromium objects. You need to call this in your application otherwise // you will get a crash when closing. Cef.Shutdown(); }
/// <summary> /// 窗口加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { Utils.WriteLog("Window_Loaded"); string serverAddress = ConfigurationManager.AppSettings["server"]; #region browser #region 初始化环境 禁用gpu 防止闪烁 var setting = new CefSharp.CefSettings(); setting.CefCommandLineArgs.Add("disable-gpu", "1"); setting.Locale = "zh-CN"; setting.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 LY_CRM_BOX"; CefSharp.Cef.Initialize(setting); #endregion browser = new ChromiumWebBrowser(); //browser.Address = System.AppDomain.CurrentDomain.BaseDirectory + "index.html"; // 解决input框无法输入中文的BUG browser.PreviewTextInput += Browser_PreviewTextInput; browser.Address = serverAddress; browser.LifeSpanHandler = new prohibitNewPageJump(); //browser.Address = "http://ie.icoa.cn"; //注册JS调用函数 browser.RegisterJsObject("__phone", new CallBackForJs()); // 菜单处理事件 browser.MenuHandler = new MenuHandler(); // 下载处理事件 browser.DownloadHandler = new browerDownLoad(); this.main.Children.Add(browser); // 浏览器按键事件 browser.KeyDown += Browser_KeyDown; #endregion #region 盒子初始化 if (VoipHelper.OpenDevice() == 0) { VoipHelper.deviceState = false; MessageBox.Show("电话硬件设备连接存在问题,请关闭软件检查硬件后重试。"); } hwnd = (new System.Windows.Interop.WindowInteropHelper(this)).Handle;//盒子事件注册 for (Int16 i = 0; i < BriSDKLib.QNV_DevInfo(-1, BriSDKLib.QNV_DEVINFO_GETCHANNELS); i++) { //在windowproc处理接收到的消息 BriSDKLib.QNV_Event(i, BriSDKLib.QNV_EVENT_REGWND, (int)hwnd, "", new StringBuilder(0), 0); } VoipHelper.init(); #endregion #region 录音 uploadRecordingFile = new BackgroundWorker(); uploadRecordingFile.DoWork += uploadRecordingFile_DoWork; uploadRecordingFile.WorkerSupportsCancellation = true; uploadRecordingFile.RunWorkerAsync(); #endregion Utils.PreventSleep(); }
public FrmRestrictedWebBrowser() { InitializeComponent(); try { //webBrowser.StatusTextChanged += WebBrowser_StatusTextChanged; //webBrowser.ProgressChanged += WebBrowser_ProgressChanged; cwb.Dock = DockStyle.Fill; cwb.ContextMenu = null; cwb.ConsoleMessage += Cwb_ConsoleMessage; cwb.StatusMessage += Cwb_StatusMessage; cwb.NavStateChanged += Cwb_NavStateChanged; cwb.LoadError += Cwb_LoadError; CefSharp.BrowserSettings cbs = new CefSharp.BrowserSettings(); cbs.ApplicationCacheDisabled = true; cbs.FileAccessFromFileUrlsAllowed = false; cbs.JavaScriptCloseWindowsDisabled = true; cbs.PluginsDisabled = true; cbs.WebSecurityDisabled = false; cwb.BrowserSettings = cbs; CefSharp.CefSettings cs = new CefSharp.CefSettings(); cs.IgnoreCertificateErrors = true; cs.UserAgent = GlobalSettings.RestrictedBrowserUserAgent; cwb.AllowDrop = false; this.Controls.Add(cwb); } catch (Exception) { throw; } }
public MainWindow() { InitLog(); Log.Information("Service starting..."); CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\CEF"; CefSharp.Cef.Initialize(settings); InitializeComponent(); _libLoader = new LibraryLoader(); _libLoader.Init(); _mtBus = new MTBus(); _orderCache = new OrderCacheValidator(); _orderCache.DetectOrder += OrderCacheOnDetectOrder; Browser.FrameLoadEnd += WebBrowserFrameLoadEnded; this.Closing += OnClosing; _timeScheduler = new TimeSchedulerService(TimeSpan.FromMinutes(15)); _timeScheduler.Work += TimeSchedulerOnWork; _timeScheduler.Start(); Log.Information("Service started"); }
/// <summary> /// 浏览器初始化 /// </summary> public static void BrowserInit() { #region 浏览器全局设置 var setting = new CefSharp.CefSettings(); setting.Locale = "zh-CN"; //缓存路径 setting.CachePath = Application.StartupPath + "/BrowserCache"; //浏览器引擎的语言 setting.AcceptLanguageList = "zh-CN,zh;q=0.9"; setting.LocalesDirPath = Application.StartupPath + "/localeDir"; //日志文件 setting.LogFile = Application.StartupPath + "/LogData"; setting.PersistSessionCookies = true; setting.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"; setting.UserDataPath = Application.StartupPath + "/userData"; //开启ppapi-flash //setting.CefCommandLineArgs.Add("enable-npapi", "1"); setting.CefCommandLineArgs.Add("--ppapi-flash-path", System.AppDomain.CurrentDomain.BaseDirectory + "Plugins\\pepflashplayer32_30_0_0_134.dll"); //指定flash的版本,不使用系统安装的flash版本 setting.CefCommandLineArgs.Add("--ppapi-flash-version", "30.0.0.134"); setting.CefCommandLineArgs.Add("Connection", "keep-alive"); setting.CefCommandLineArgs.Add("Accept-Encoding", "gzip, deflate, br"); setting.CefCommandLineArgs.Add("enable-media-stream", "1"); CefSharp.Cef.Initialize(setting); #endregion }
public void InitHelper() { var setting = new CefSharp.CefSettings(); // 设置语言 setting.Locale = "en-US"; CefSharp.Cef.Initialize(setting, true, false); }
public Form1() { //log.Info("form1初始化"); Log4Helper.Info(this.GetType(), "form1初始化"); InitializeComponent(); ///设置 var setting = new CefSharp.CefSettings(); setting.Locale = "zh-CN"; setting.CachePath = "CHBrowser/BrowserCache"; //缓存路径 setting.AcceptLanguageList = "zh-CN,zh;q=0.8"; //浏览器引擎的语言 setting.LocalesDirPath = "CHBrowser/localeDir"; //日志 setting.LogFile = "CHBrowser/LogData"; //日志文件 setting.PersistSessionCookies = true; // setting.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"; //浏览器内核 setting.UserDataPath = "CHBrowser/userData"; //个人数据 //CefSharpSettings.LegacyJavascriptBindingEnabled = true; ///初始化 //CefSharp.Cef.Initialize(setting); CefSharp.Cef.Initialize(); Cef.EnableHighDPISupport(); //browser = new ChromiumWebBrowser("http://www.baidu.com"); browser = new ChromiumWebBrowser(homePageUrl); browser.Dock = DockStyle.Fill; //browser.Load("http://www.baidu.com");] browser.LifeSpanHandler = new OpenPageSelf(); //browser.JavascriptObjectRepository.Register("bound", new KeyBoard(), true); browser.JavascriptObjectRepository.Register("boundAsync", new BoundObject(), true); browser.CreateControl(); this.panel1.Controls.Add(browser); if (isFullScreen) { FullScreen(); } //new KeyBoard().ShowKeyBoard(); //browser.SetZoomLevel(2.0); //browser.FrameLoadStart += (o, e) => NowBrowserAddress.Contains("zwfw.sd.gov.cn")?browser.SetZoomLevel(2):return; ; browser.FrameLoadStart += Browser_FrameLoadStart; browser.AddressChanged += Browser_AddressChanged; }
//static MyChromiumBrowser() { } private MyChromiumBrowser() { #region 浏览器全局设置 var setting = new CefSharp.CefSettings(); setting.Locale = "zh-CN"; //缓存路径 setting.CachePath = Application.StartupPath + "/BrowserCache"; //浏览器引擎的语言 setting.AcceptLanguageList = "zh-CN,zh;q=0.9"; setting.LocalesDirPath = Application.StartupPath + "/localeDir"; //日志文件 setting.LogFile = Application.StartupPath + "/LogData"; setting.PersistSessionCookies = true; setting.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"; setting.UserDataPath = Application.StartupPath + "/userData"; //开启ppapi-flash //setting.CefCommandLineArgs.Add("enable-npapi", "1"); setting.CefCommandLineArgs.Add("--ppapi-flash-path", System.AppDomain.CurrentDomain.BaseDirectory + "Plugins\\pepflashplayer32_30_0_0_134.dll"); //指定flash的版本,不使用系统安装的flash版本 setting.CefCommandLineArgs.Add("--ppapi-flash-version", "30.0.0.134"); setting.CefCommandLineArgs.Add("Connection", "keep-alive"); setting.CefCommandLineArgs.Add("Accept-Encoding", "gzip, deflate, br"); CefSharp.Cef.Initialize(setting); #endregion webBrowser = new ChromiumWebBrowser("about:blank"); #region 设置js与cefSharp互通 CefSharp.CefSharpSettings.LegacyJavascriptBindingEnabled = true; webBrowser.RegisterJsObject("googleBrower", this, new CefSharp.BindingOptions() { CamelCaseJavascriptNames = false }); #endregion BrowserSettings bset = new BrowserSettings(); bset.Plugins = CefState.Enabled; //启用插件 bset.WebSecurity = CefState.Disabled; //禁用跨域限制 webBrowser.BrowserSettings = bset; //设置cookieManager管理器 cookieManager = Cef.GetGlobalCookieManager(); //webBrowser.DownloadHandler = new DownloadHandler(); //webBrowser.KeyboardHandler = new KeyBoardHandler(); //MenuHandler.mainWindow = mainWindow; //webBrowser.MenuHandler = new MenuHandler(); //webBrowser.Dock = DockStyle.Fill; //webBrowser.Margin = new Padding(0, 0, 0, 0); //mainWindow.Controls.Add(webBrowser); }
public Form1() { InitializeComponent(); var setting = new CefSharp.CefSettings(); // 设置语言 setting.Locale = "zh-CN"; CefSharp.Cef.Initialize(setting); }
public MainWindow() { if (!Directory.Exists(cacheLoc)) { Directory.CreateDirectory(cacheLoc); } CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = cacheLoc; Cef.Initialize(settings); InitializeComponent(); cefBrowser.LoadingStateChanged += CefBrowser_LoadingStateChanged; }
private void InitCefSharp() { var setting = new CefSharp.CefSettings() { Locale = "zh-CN", AcceptLanguageList = "zh-CN", MultiThreadedMessageLoop = true }; Cef.Initialize(setting); Cef.EnableHighDPISupport(); }
public void InitBrowser() { var setting = new CefSharp.CefSettings(); setting.CefCommandLineArgs.Add("disable-gpu", "1"); // 禁用gpu Cef.Initialize(setting, true, false); browser = new ChromiumWebBrowser("https://www.sojson.com/jsobfuscator.html"); this.Controls.Add(browser); browser.Dock = DockStyle.Fill; obj = new BoundObject(browser); browser.RegisterJsObject("bound", obj); d1 = DateTime.Now; }
public static void Init() { CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.RegisterScheme(new CefCustomScheme { SchemeName = "theme", SchemeHandlerFactory = new ThemeSchemeHandlerFactory() }); if (Cef.Initialize(settings)) { //CEF.RegisterScheme("test", new SchemeHandlerFactory()); //CEF.RegisterJsObject("bound", new BoundObject()); } }
public void Init() { var setting = new CefSharp.CefSettings(); setting.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeName, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() }); // 设置语言 setting.Locale = "zh-CN"; // en-US CefSharp.Cef.Initialize(setting, true, false); }
public static void Init() { CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.RegisterScheme(new CefCustomScheme { SchemeName = "theme", SchemeHandlerFactory = new ThemeSchemeHandlerFactory() }); if (Cef.Initialize(settings)) { //CEF.RegisterScheme("test", new SchemeHandlerFactory()); //CEF.RegisterJsObject("bound", new BoundObject()); } }
private static void InitCef() { //var settings = new CefSharp.WinForms.CefSettings();//新版本cef var settings = new CefSharp.CefSettings();//老版本的cef使用 //settings.CachePath = "cache"; settings.CefCommandLineArgs.Add("enable-media-stream", "0"); settings.CefCommandLineArgs.Add("no-proxy-server", "1"); settings.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2661.102 Safari/537.36";//老版本无默认,自己加 settings.UserAgent = "Yunwang-" + settings.UserAgent; settings.Locale = "zh-CN"; settings.AcceptLanguageList = "zh-CN"; Cef.Initialize(settings); }
private void 模拟点击_Load(object sender, EventArgs e) { CefSharp.CefSettings settings = new CefSharp.CefSettings(); CefSharp.Cef.Initialize(settings); // browser.FrameLoadEnd += new EventHandler<FrameLoadEndEventArgs>(FrameEndFunc); //browser.Load("https://shopee.com.my/"); //browser.Parent = tabPage2; //browser.Dock = DockStyle.Fill; browser.Parent = tabPage2; browser.Dock = DockStyle.Fill; browser.LifeSpanHandler = new OpenPageSelf(); }
public MainWindow() { CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.PackLoadingDisabled = true; myClass = new MyClass(); myClass.message = "BLALBLLDFL"; Cef.Initialize(settings); InitializeComponent(); Browser.Address = "http://localhost:53689"; Browser.RegisterJsObject("myClass", myClass); }
private void LoadBrowser() { var setting = new CefSharp.CefSettings(); CefSharp.Cef.Initialize(setting); webView = new CefSharp.Wpf.ChromiumWebBrowser() { BrowserSettings = { DefaultEncoding = "UTF-8" }, JsDialogHandler = new BrowserDialog(), //MenuHandler = false, }; webView.PreviewTextInput += (obj, args) => { foreach (var character in args.Text) { // 把每个字符向浏览器组件发送一遍 webView.GetBrowser().GetHost().SendKeyEvent((int)WM.CHAR, (int)character, 0); } // 不让cef自己处理 args.Handled = true; }; webView.PreviewKeyDown += (obj, args) => { if (args.Key.ToString() == "F5") { webView.Address = "localhost"; } if (args.Key.ToString() == "F12") { webView.ShowDevTools(); } if (args.Key.ToString() == "Back") { webView.Back(); } }; webView.RegisterJsObject("csharp", new CallbackObjectForJs()); webView.Address = "localhost"; webView.FrameLoadEnd += OnLoadEnd; Content = webView; }
public FrmMain() { CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = Path.GetDirectoryName(Application.ExecutablePath) + @"\\cache"; CefSharp.Cef.Initialize(settings); InitializeComponent(); mainMenu.Renderer = new CutomToolStripMenuRenderer(); tabCtrlMain.DrawMode = TabDrawMode.OwnerDrawFixed; //CefSharp.BrowserSettings st = new CefSharp.BrowserSettings(); //st.ApplicationCache = CefSharp.CefState.Enabled; //webbrsrVerbformen.BrowserSettings=st; //CefSharp.RequestContextSettings requestContextSettings = new CefSharp.RequestContextSettings(); //requestContextSettings.PersistSessionCookies = true; //requestContextSettings.PersistUserPreferences = true; //requestContextSettings.CachePath = "D:\\chro\\"; //webbrsrVerbformen.RequestContext = new CefSharp.RequestContext(requestContextSettings); }
/// <summary> /// 浏览器初始化 /// </summary> public static void BrowserInit() { #region 浏览器全局设置 var setting = new CefSharp.CefSettings(); var osVersion = Environment.OSVersion; //Disable GPU for Windows 7 if (osVersion.Version.Major == 6 && osVersion.Version.Minor == 1) { // Disable GPU in WPF and Offscreen examples until #1634 has been resolved6 //setting.CefCommandLineArgs.Add("disable-gpu", "1");//禁用GPU } setting.CefCommandLineArgs.Add("disable-gpu", "1");//禁用GPU setting.CefCommandLineArgs.Add("enable-webgl", "1"); setting.Locale = "zh-CN"; //缓存路径 setting.CachePath = Application.StartupPath + "/BrowserCache"; //浏览器引擎的语言 setting.AcceptLanguageList = "zh-CN,zh;q=0.9,en;q=0.6"; setting.LocalesDirPath = Application.StartupPath + "/localeDir"; //日志文件 setting.LogFile = Application.StartupPath + "/LogData"; //只记录错误日志 setting.LogSeverity = LogSeverity.Error; setting.PersistSessionCookies = true; setting.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"; setting.UserDataPath = Application.StartupPath + "/userData"; //开启ppapi-flash setting.CefCommandLineArgs.Add("enable-npapi", "1"); setting.CefCommandLineArgs.Add("--ppapi-flash-path", System.AppDomain.CurrentDomain.BaseDirectory + "Plugins\\pepflashplayer.dll"); //指定flash的版本,不使用系统安装的flash版本 setting.CefCommandLineArgs.Add("--ppapi-flash-version", "22.0.0.192"); setting.CefCommandLineArgs.Add("Connection", "keep-alive"); setting.CefCommandLineArgs.Add("Accept-Encoding", "gzip, deflate, br,compress"); setting.CefCommandLineArgs.Add("enable-media-stream", "1"); Cef.Initialize(setting, false, false); #endregion }
/// <summary> /// CEF初始化参数设置 /// </summary> public void cefInit() { try { //清空缓存 if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "cache\\Cache")) { string[] filedir = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "cache\\Cache", "*.*", SearchOption.TopDirectoryOnly); if (filedir != null) { foreach (string fileName in filedir) { File.Delete(fileName); } } } CefSettings setting = new CefSharp.CefSettings(); //关闭日志文件 setting.LogSeverity = CefSharp.LogSeverity.Disable; //Flash设置 //setting.CefCommandLineArgs.Add("enable-npapi","1"); //string flashPath = @"C:\Users\shallow\AppData\Local\Google\Chrome\User Data\PepperFlash\28.0.0.137\pepflashplayer.dll"; //setting.CefCommandLineArgs.Add("ppapi-flash-path", flashPath); //setting.CefCommandLineArgs.Add("ppapi-flash-version", "28.0.0.137"); //屏幕闪烁设置 setting.CefCommandLineArgs.Add("disable-gpu", "1"); // 禁用gpu setting.Locale = "zh-CN"; // 设置语言 //缓存路径 setting.CachePath = AppDomain.CurrentDomain.BaseDirectory + "cache\\"; setting.PersistSessionCookies = true; CefSharp.Cef.Initialize(setting, true, null); string cookieDirec = AppDomain.CurrentDomain.BaseDirectory + "cache\\cookie\\"; ICookieManager cookieManager = CefSharp.Cef.GetGlobalCookieManager(); cookieManager.SetStoragePath(cookieDirec, false); } catch (Exception ex) { IniHelper.WriteLog(ex); } }
public GeoBrowserUserControl() { InitializeComponent(); // Cef.Initialize(new CefSettings()); CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.PackLoadingDisabled = true; Browser = new CefSharp.Wpf.ChromiumWebBrowser(); this.mainDock.Children.Add(Browser); Browser.Address = "http://192.168.159.128:8000/Apps/HelloWorld.html"; //Wait for the page to finish loading (all resources will have been loaded, rendering is likely still happening) Browser.MouseDoubleClick += (sender, args) => { Browser.ExecuteScriptAsync("addCircle", foo, foo, "1000000"); foo += 10; }; Browser.LoadingStateChanged += (sender, args) => { //Wait for the Page to finish loading if (args.IsLoading == false) { } }; //Wait for the MainFrame to finish loading Browser.FrameLoadEnd += (sender, args) => { //Wait for the MainFrame to finish loading if (args.Frame.IsMain) { if (!doneOnce) { doneOnce = true; Browser.ExecuteScriptAsync(SetUpScript); } } }; }
public Form1() { InitializeComponent(); my = this; phoneControl.openDevInit(); //Cef.Initialize(new CefSettings()); var setting = new CefSharp.CefSettings() { CachePath = Directory.GetCurrentDirectory() + @"\Cache", }; setting.CefCommandLineArgs.Add("enable-media-stream", "1"); //setting.CefCommandLineArgs.Add("--disable-web-security", "1"); Cef.Initialize(setting); browser = new ChromiumWebBrowser(URL); //browser = new ChromiumWebBrowser("http://www.baidu.com"); browser.Height = this.Height - topSpan; browser.Width = this.Width; this.Controls.Add(browser); browser.Dock = DockStyle.Bottom; BrowserSettings browserSettings = new BrowserSettings(); browserSettings.FileAccessFromFileUrls = CefState.Enabled; browserSettings.UniversalAccessFromFileUrls = CefState.Enabled; browserSettings.WebSecurity = CefState.Enabled; browser.BrowserSettings = browserSettings; mCookieManager = CefSharp.Cef.GetGlobalCookieManager(); browser.FrameLoadEnd += Browser_FrameLoadEnd; waitingBox = new frmWaitingBox((obj, args) => { }); waitingBox.StartPosition = FormStartPosition.CenterScreen; waitingBox.Show(this); }
private void InitializeCEF() { CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/GPMDP"; settings.WindowlessRenderingEnabled = true; settings.CefCommandLineArgs.Add("enable-smooth-scrolling", "1"); settings.CefCommandLineArgs.Add("enable-overlay-scrollbar", "1"); settings.CefCommandLineArgs.Add("enable-npapi", "1"); Cef.Initialize(settings); GPMBrowser = new CefSharp.WinForms.ChromiumWebBrowser("http://play.google.com/music/listen") { // Use this to inject our theming and modding javascript code ResourceHandlerFactory = new GPMResouceHandlerFactory(), // Stop that silly right click menu appearing MenuHandler = new GPMMenuHandler() }; GPMBrowser.RegisterAsyncJsObject("csharpinterface", new JSBound(this)); GPMBrowser.Dock = DockStyle.Fill; Controls.Add(GPMBrowser); }
public LoginWindow() { InitializeComponent(); var setting = new CefSharp.CefSettings(); setting.Locale = "zh-CN"; //缓存路径 //setting.CachePath = "/BrowserCache"; //浏览器引擎的语言 setting.AcceptLanguageList = "zh-CN,zh-TW;q=0.9,zh;q=0.8,en-US;q=0.7,en;q=0.6"; //setting.LocalesDirPath = "/localeDir"; //日志文件 //setting.LogFile = "/LogData"; setting.PersistSessionCookies = true; setting.UserAgent = "Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Mobile Safari/537.36"; //setting.UserDataPath = "/userData"; CefSharp.Cef.Initialize(setting, true, new MyBrowserProcessHandler()); chromiumWebBrowser = new ChromiumWebBrowser(); chromiumWebBrowser.Address = "https://pet-chain.baidu.com/"; chromiumWebBrowser.FrameLoadEnd += ChromiumWebBrowser_FrameLoadEnd; //chromiumWebBrowser.RequestHandler = myRequest; this.pnlWB.Children.Add(chromiumWebBrowser); }
public FrmRestrictedWebBrowser() { InitializeComponent(); try { //webBrowser.StatusTextChanged += WebBrowser_StatusTextChanged; //webBrowser.ProgressChanged += WebBrowser_ProgressChanged; cwb.Dock = DockStyle.Fill; cwb.ContextMenu = null; cwb.ConsoleMessage += Cwb_ConsoleMessage; cwb.StatusMessage += Cwb_StatusMessage; cwb.NavStateChanged += Cwb_NavStateChanged; cwb.LoadError += Cwb_LoadError; CefSharp.BrowserSettings cbs = new CefSharp.BrowserSettings(); cbs.ApplicationCacheDisabled = true; cbs.FileAccessFromFileUrlsAllowed = false; cbs.JavaScriptCloseWindowsDisabled = true; cbs.PluginsDisabled = true; cbs.WebSecurityDisabled = false; cwb.BrowserSettings = cbs; CefSharp.CefSettings cs = new CefSharp.CefSettings(); cs.IgnoreCertificateErrors = true; cs.UserAgent = GlobalSettings.RestrictedBrowserUserAgent; cwb.AllowDrop = false; this.Controls.Add(cwb); } catch (Exception) { throw; } }
private void InitializeCEF() { CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/GPMDP"; settings.WindowlessRenderingEnabled = true; settings.CefCommandLineArgs.Add("enable-smooth-scrolling", "1"); settings.CefCommandLineArgs.Add("enable-overlay-scrollbar", "1"); settings.CefCommandLineArgs.Add("enable-npapi", "1"); Cef.Initialize(settings); GPMBrowser = new CefSharp.WinForms.ChromiumWebBrowser("http://play.google.com/music/listen") { // Use this to inject our theming and modding javascript code ResourceHandlerFactory = new GPMResouceHandlerFactory(), // Stop that silly right click menu appearing MenuHandler = new GPMMenuHandler() }; GPMBrowser.RegisterAsyncJsObject("csharpinterface", new JSBound(this)); GPMBrowser.Dock = DockStyle.Fill; Controls.Add(GPMBrowser); }
private void InitializeForm() { CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/GPMDP"; settings.WindowlessRenderingEnabled = true; Cef.Initialize(settings); webBrowser1 = new CefSharp.WinForms.ChromiumWebBrowser("http://play.google.com/music/listen"); webBrowser1.MenuHandler = new NoMenuHandler(); webBrowser1.Dock = DockStyle.Fill; Controls.AddRange(new Control[] { webBrowser1 }); // Global Hotkey Listener gkh.HookedKeys.Add(Keys.MediaPlayPause); gkh.HookedKeys.Add(Keys.MediaNextTrack); gkh.HookedKeys.Add(Keys.MediaPreviousTrack); gkh.HookedKeys.Add(Keys.MediaStop); gkh.KeyDown += new KeyEventHandler(gkh_KeyDown); gkh.KeyUp += new KeyEventHandler(gkh_KeyUp); webBrowser1.NavStateChanged += OnBrowserLoadingStateChanged; }
private static bool CEFLoaderInit() { var session = Helpers.Old.Log.SessionStart("CEFLoaderInit()", true); try { Helpers.Old.Log.Add(session, "Start initialization..."); if (Cef.IsInitialized) { Helpers.Old.Log.Add(session, "CEF already initialized. Exit."); return(true); } Helpers.Old.Log.Add(session, string.Format("Current directory for initialization: '{0}'", Helpers.Log.CurrentPath)); string cache = Path.Combine(Helpers.Log.CurrentPath, "cache"); Helpers.Old.Log.Add(session, string.Format("Cache directory is '{0}'. Directory exists: '{1}'", cache, Directory.Exists(cache))); if (Directory.Exists(cache)) { try { Directory.Delete(cache, true); Directory.CreateDirectory(cache); Helpers.Old.Log.Add(session, "Cache directory cleared"); } catch (Exception ex) { Helpers.Old.Log.Add(session, "Can't clear cache directory"); Helpers.Old.Log.Add(session, ex); } } string logFile = Path.Combine(Helpers.Log.CurrentPath, "chromelog.txt"); Helpers.Old.Log.Add(session, string.Format("Log file is '{0}'. Log file exists: '{1}'", logFile, File.Exists(logFile))); if (File.Exists(logFile)) { try { File.Delete(logFile); } catch (Exception ex) { Helpers.Old.Log.Add(session, "Can't remove log file"); Helpers.Old.Log.Add(session, ex); logFile = Path.Combine(Helpers.Log.CurrentPath, DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_chromelog.txt"); Helpers.Old.Log.Add(session, string.Format("New log file is '{0}'. Log file exists: '{1}'", logFile, File.Exists(logFile))); } } string subprocessPath = Path.Combine(Helpers.Log.CurrentPath, "CefSharp.BrowserSubprocess.exe"); Helpers.Old.Log.Add(session, string.Format("Subprocess path is '{0}'. Sub process file exists: '{1}'", subprocessPath, File.Exists(subprocessPath))); if (!File.Exists(subprocessPath)) { throw new Exception("Subprocess file not exists!"); } CefSharp.CefSettings settings = new CefSharp.CefSettings() { CachePath = cache.Replace(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar, string.Empty), LogFile = logFile.Replace(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar, string.Empty), BrowserSubprocessPath = subprocessPath.Replace(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar, string.Empty), RemoteDebuggingPort = 8088, LogSeverity = Debugger.IsAttached ? LogSeverity.Verbose : LogSeverity.Warning }; Cef.OnContextInitialized = delegate { Cef.GetGlobalCookieManager().SetStoragePath("cookies", true); }; Helpers.Old.Log.Add(session, "Start Cef.Initialize()"); var res = Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: !Debugger.IsAttached); Helpers.Old.Log.Add(session, "Cef.Initialize() done"); return(res); } catch (Exception ex) { Helpers.Old.Log.Add(session, ex); throw; } finally { Helpers.Old.Log.SessionEnd(session); } }
private void SetWebBrowserAttr() { try { this.strPrevFileName = ""; this.strPrevTotalText = ""; // ファイル名が有効ならば、それをWebBrowserでナビゲート var strStartFileName = Hm.Edit.FilePath ?? ""; if (wb == null) { if (!Cef.IsInitialized) { var settings = new CefSharp.CefSettings(); // By default CEF uses an in memory cache, to save cached data e.g. passwords you need to specify a cache path // NOTE: The executing user must have sufficient privileges to write to this folder. //settings.CachePath = @"C:\Users\0300002167\AppData\Local\Google\Chrome\User Data"; settings.LocalesDirPath = Hm.Macro.Var["currentmacrodirectory"] + @"\Locales"; settings.AcceptLanguageList = "ja-JP"; settings.Locale = "ja"; CefSharp.Cef.Initialize(settings); } wb = new CefSharp.WinForms.ChromiumWebBrowser(strStartFileName); CefSharp.BrowserSettings bs = new CefSharp.BrowserSettings { LocalStorage = CefSharp.CefState.Enabled, FileAccessFromFileUrls = CefSharp.CefState.Enabled, UniversalAccessFromFileUrls = CefSharp.CefState.Enabled, ApplicationCache = CefSharp.CefState.Enabled, AcceptLanguageList = "ja-JP", }; wb.BrowserSettings = bs; wb.Dock = DockStyle.Fill; wb.LoadingStateChanged += wb_LoadingStateChanged; wb.AddressChanged += wb_AddressChanged; if (strStartFileName == "") { wb_LoadHtml(Hm.Edit.TotalText); } this.Controls.Add(wb); } else { if (strStartFileName == "") { wb.ResetText(); wb_LoadHtml(Hm.Edit.TotalText); } else { wb.ResetText(); wb.Load(strStartFileName); wb.Refresh(); } } } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.Message); } }
private static bool CEFLoaderInit() { var session = Helpers.Old.Log.SessionStart("CEFLoaderInit()", true); try { Helpers.Old.Log.Add(session, "Start initialization..."); if (Cef.IsInitialized) { Helpers.Old.Log.Add(session, "CEF already initialized. Exit."); return true; } Helpers.Old.Log.Add(session, string.Format("Current directory for initialization: '{0}'", Helpers.Log.CurrentPath)); string cache = Path.Combine(Helpers.Log.CurrentPath, "cache"); Helpers.Old.Log.Add(session, string.Format("Cache directory is '{0}'. Directory exists: '{1}'", cache, Directory.Exists(cache))); if (Directory.Exists(cache)) try { Directory.Delete(cache, true); Directory.CreateDirectory(cache); Helpers.Old.Log.Add(session, "Cache directory cleared"); } catch(Exception ex) { Helpers.Old.Log.Add(session, "Can't clear cache directory"); Helpers.Old.Log.Add(session, ex); } string logFile = Path.Combine(Helpers.Log.CurrentPath, "chromelog.txt"); Helpers.Old.Log.Add(session, string.Format("Log file is '{0}'. Log file exists: '{1}'", logFile, File.Exists(logFile))); if (File.Exists(logFile)) try { File.Delete(logFile); } catch(Exception ex) { Helpers.Old.Log.Add(session, "Can't remove log file"); Helpers.Old.Log.Add(session, ex); logFile = Path.Combine(Helpers.Log.CurrentPath, DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_chromelog.txt"); Helpers.Old.Log.Add(session, string.Format("New log file is '{0}'. Log file exists: '{1}'", logFile, File.Exists(logFile))); } string subprocessPath = Path.Combine(Helpers.Log.CurrentPath, "CefSharp.BrowserSubprocess.exe"); Helpers.Old.Log.Add(session, string.Format("Subprocess path is '{0}'. Sub process file exists: '{1}'", subprocessPath, File.Exists(subprocessPath))); if (!File.Exists(subprocessPath)) throw new Exception("Subprocess file not exists!"); CefSharp.CefSettings settings = new CefSharp.CefSettings() { CachePath = cache.Replace(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar, string.Empty), LogFile = logFile.Replace(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar, string.Empty), BrowserSubprocessPath = subprocessPath.Replace(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar, string.Empty), RemoteDebuggingPort = 8088, LogSeverity = Debugger.IsAttached ? LogSeverity.Verbose : LogSeverity.Warning }; Cef.OnContextInitialized = delegate { Cef.GetGlobalCookieManager().SetStoragePath("cookies", true); }; Helpers.Old.Log.Add(session, "Start Cef.Initialize()"); var res = Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: !Debugger.IsAttached); Helpers.Old.Log.Add(session, "Cef.Initialize() done"); return res; } catch(Exception ex) { Helpers.Old.Log.Add(session, ex); throw; } finally { Helpers.Old.Log.SessionEnd(session); } }
/// <summary> /// OnStartup override to initialize our DI class /// </summary> /// <param name="e"></param> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var cefSettings = new CefSharp.CefSettings { //PackLoadingDisabled = true }; cefSettings.CefCommandLineArgs.Add("disable-gpu", "1"); cefSettings.CefCommandLineArgs.Add("disable-gpu-vsync", "1"); Cef.Initialize(cefSettings); // Create our DI container and build it ContainerHelper.InitializeBuilder(); ContainerHelper.Builder.Register(c => new EventBus()).As <IEventBus>().SingleInstance(); ContainerHelper.Builder.Register(c => new YupSettings()).As <IYupSettings>().SingleInstance(); ContainerHelper.Builder.RegisterType <YupRepository>().As <IYupRepository>().SingleInstance(); ContainerHelper.Builder.RegisterType <YtManager>().As <IYtManager>(); ContainerHelper.Builder.Register(c => new HoldingBay()).As <IHoldingBay>().SingleInstance(); //TODO: Register players named ? ContainerHelper.Builder.RegisterType <FlashAxControl>().Named <IMediaPlayer>("youtube").SingleInstance(); //TODO: Think if we want to register ViewModel classes as singleton instances ?! ContainerHelper.Builder.RegisterType <VideosViewModel>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); ContainerHelper.Builder.RegisterType <YupisViewModel>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); ContainerHelper.Builder.RegisterType <PlayerViewModel>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); ContainerHelper.Builder.RegisterType <ChannelsViewModel>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); //TODO: Register all external services here ..... ContainerHelper.SetAutofacContainer(); var repository = ContainerHelper.GetService <IYupRepository>(); repository.LoadRepository(); var eventsReg = ContainerHelper.Container.Resolve <IEnumerable <IEventRegistrator> >(); foreach (IEventRegistrator eventRegistrator in eventsReg) { eventRegistrator.PublishEvents(); } foreach (IEventRegistrator eventRegistrator in eventsReg) { eventRegistrator.SubscribeEvents(); } var settings = ContainerHelper.GetService <IYupSettings>(); settings.checkAppFolderPath(); settings.loadAppSettings(); // Create our main window - since we removed startup URI YUP.App.MainWindow wnd = new MainWindow(); wnd.Show(); }