gcWebControl::gcWebControl(wxWindow* parent, const char* defaultUrl, CreateBrowserFn createBrowserFn) : gcPanel(parent, wxID_ANY) { Bind(wxEVT_MOUSEWHEEL, &gcWebControl::onMouseScroll, this); Bind(wxEVT_SIZE, &gcWebControl::onResize, this); Bind(wxEVT_COMMAND_MENU_SELECTED, &gcWebControl::onMenuClicked, this); Bind(wxEVT_ERASE_BACKGROUND, &gcWebControl::onPaintBg, this); Bind(wxEVT_PAINT, &gcWebControl::onPaint, this); Bind(wxEVT_SET_FOCUS, &gcWebControl::onFocus, this); m_bStartedLoading = false; gcString loadingurl = gcString(GetGCThemeManager()->getWebPage("loading")); loadingurl += gcString("?url={0}", UTIL::STRING::urlEncode(gcString(defaultUrl))); m_pEventHandler = new EventHandler(this); if (createBrowserFn) m_pChromeBrowser = createBrowserFn(this, loadingurl.c_str()); else m_pChromeBrowser = CreateBrowser(this, loadingurl.c_str()); if (!m_pChromeBrowser) m_pChromeBrowser = new gcWebFakeBrowser(this); m_pChromeBrowser->setEventCallback(m_pEventHandler); onPageStartEvent += guiDelegate(this, &gcWebControl::onStartLoad); onAnyPageLoadEvent += guiDelegate(this, &gcWebControl::onPageLoad); m_szHomeUrl = defaultUrl; m_bContentLoaded = false; }
CefFacade::CefFacade(const char* startUrl,HINSTANCE hInstance,HWND pParent) { CefMainArgs main_args(hInstance); CefRefPtr<ClientApp> app(new ClientApp); int exit_code = CefExecuteProcess(main_args, app.get(), NULL); if (exit_code >= 0){ exit(exit_code); } CefSettings settings; CefSettingsTraits::init(&settings); settings.multi_threaded_message_loop = true; settings.single_process = true; TCHAR szBuffer[MAX_PATH]; SHGetSpecialFolderPath(NULL, szBuffer, CSIDL_INTERNET_CACHE, FALSE); _stprintf(szBuffer,_T("%s\\cache"), szBuffer); CefString(&settings.cache_path) = szBuffer; settings.log_severity = LOGSEVERITY_DISABLE; CefString(&settings.locale) = "zh-CN"; CefInitialize(main_args, settings, app.get(), NULL); CreateBrowser(pParent,startUrl); }
dcmapHWND DCMAPAPI CGeckoView::Create(dcmapHWND hwndParent,dcmapHWND hwndMain,dcmapRECT const* rcClient) { HINSTANCE hInst = GetModuleHandle(0); m_hWnd = hwndParent; CreateBrowser(hwndParent,rcClient); m_hWnd = FindWindowEx(hwndParent,NULL,L"MozillaContentWindowClass",NULL); return m_hWnd; }
IEHtmlWin::IEHtmlWin(wxWindow * parent, wxWindowID id) : wxWindow(parent, id) { m_oleObject = NULL; m_oleInPlaceObject = NULL; m_webBrowser = NULL; m_currentUrl = _T(""); m_specificallyOpened = false; CreateBrowser(); }
void QCefWebView::loadFromUrl(const QUrl& url) { //qDebug() << __FUNCTION__ << url; url_ = url; switch (browser_state_) { case kNone: CreateBrowser(size()); break; case kCreating: // If resizeEvent()/showEvent() before you load a url, it will // CreateBrowser() as soon as possible with "about:blank". need_load_ = true; break; default: // The browser should have been created. BrowserLoadUrl(url); } }
bool TWebViewFrame::OnInit() { if(!m_pPlayers.init(m_pCore))return false; Browser = CreateBrowser(this); Browser->Parent = this; TBrowserParams* params = new TBrowserParams; params->UserAgend = String(L"DCMap/")+DCMAP_VERSION_FAMILY; Browser->SetupBrowser(params); delete params; UpdateLoginMenu(); return TBaseModuleFrame::OnInit(); }
void QCefWebView::resizeEvent(QResizeEvent* e) { //qDebug() << __FUNCTION__ << e->size(); // On WinXP, if you load a url immediately after constructed, you will // CreateBrowser() with the wrong Size(). At the same time, it calls // resizeEvent() to resize. However the browser has not been created now, // ResizeBrowser() will fail, and it won't displayed with the right size. // Although resize(0, 0) can fix it, the other platforms maybe // give you the right size and it will make CreateBrowser() later. switch (browser_state_) { case kNone: CreateBrowser(e->size()); break; case kCreating: need_resize_ = true; break; default: ResizeBrowser(e->size()); } }
void ClientApp::OnContextInitialized() { CreateBrowserDelegates(browser_delegates_); // Register cookieable schemes with the global cookie manager. CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(); DCHECK(manager.get()); manager->SetSupportedSchemes(cookieable_schemes_); print_handler_ = CreatePrintHandler(); BrowserDelegateSet::iterator it = browser_delegates_.begin(); for (; it != browser_delegates_.end(); ++it) (*it)->OnContextInitialized(this); auto mng = XCefAppManage::Instance(); if (NULL == mng->GetClientHostHandle()) { mng->CreateBrowser(NULL); } }
void QCefWebView::showEvent(QShowEvent* e) { //qDebug() << __FUNCTION__; CreateBrowser(size()); }
void DCMAPAPI CGeckoView::AfterCreate(dcmapHWND wnd,dcmapHWND hwndParent,dcmapHWND hwndMain) { m_hWnd = wnd; RECT rc = {0,0,300,300}; CreateBrowser(hwndParent,&rc); }
// This is a good place to create the embeddable browser // instance // int CBrowserView::OnCreate(LPCREATESTRUCT lpCreateStruct) { CreateBrowser(); return 0; }
/***************************************************************************** * AddEventToPlugin * - * This method is invoked when launchd wishes the plugin to setup a launch * event matching the parameters in the dictionary. *****************************************************************************/ void AddEventToPlugin(BonjourUserEventsPlugin* plugin, CFNumberRef launchdToken, CFDictionaryRef eventParameters) { CFStringRef domain = CFDictionaryGetValue(eventParameters, sServiceDomainKey); CFStringRef type = CFDictionaryGetValue(eventParameters, sServiceTypeKey); CFStringRef name = CFDictionaryGetValue(eventParameters, sServiceNameKey); CFBooleanRef cfOnAdd = CFDictionaryGetValue(eventParameters, sOnServiceAddKey); CFBooleanRef cfOnRemove = CFDictionaryGetValue(eventParameters, sOnServiceRemoveKey); Boolean onAdd = false; Boolean onRemove = false; if (cfOnAdd && CFGetTypeID(cfOnAdd) == CFBooleanGetTypeID() && CFBooleanGetValue(cfOnAdd)) onAdd = true; if (cfOnRemove && CFGetTypeID(cfOnRemove) == CFBooleanGetTypeID() && CFBooleanGetValue(cfOnRemove)) onRemove = true; // A type is required. If none is specified, BAIL if (!type || CFGetTypeID(type) != CFStringGetTypeID()) { fprintf(stderr, "%s:%s: a LaunchEvent is missing a service type.\n", sPluginIdentifier, __FUNCTION__); return; } // If we aren't suppose to launch on services appearing or disappearing, this service does nothing. Ignore. if (!onAdd && !onRemove) { fprintf(stderr, "%s:%s a LaunchEvent is missing both onAdd and onRemove events\n", sPluginIdentifier, __FUNCTION__); return; } // If no domain is specified, assume local. if (!domain) { domain = CFSTR("local"); } else if (CFGetTypeID(domain) != CFStringGetTypeID() ) // If the domain is not a string, fail { fprintf(stderr, "%s:%s a LaunchEvent has a domain that is not a string.\n", sPluginIdentifier, __FUNCTION__); return; } // If we have a name filter, but it's not a string. This event is broken, bail. if (name && CFGetTypeID(name) != CFStringGetTypeID()) { fprintf(stderr, "%s:%s a LaunchEvent has a domain that is not a string.\n", sPluginIdentifier, __FUNCTION__); return; } // Get us a browser NetBrowserInfo* browser = CreateBrowser(plugin, type, domain); if (!browser) { fprintf(stderr, "%s:%s cannot create browser\n", sPluginIdentifier, __FUNCTION__); return; } // Create Event Dictionary CFMutableDictionaryRef eventDictionary = CFDictionaryCreateMutable(NULL, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); // We store both the Token and the Dictionary. UserEventAgentSetLaunchEventState needs // the token and UserEventAgentSetFireEvent needs both the token and the dictionary CFDictionarySetValue(eventDictionary, sLaunchdTokenKey, launchdToken); CFDictionarySetValue(eventDictionary, sLaunchdDictKey, eventParameters); if (name) CFDictionarySetValue(eventDictionary, sServiceNameKey, name); // Add to the correct dictionary. if (onAdd) { asl_log(NULL, NULL, ASL_LEVEL_INFO, "%s:%s: Adding browser to AddEvents", sPluginIdentifier, __FUNCTION__); AddEventDictionary(eventDictionary, plugin->_onAddEvents, browser); } if (onRemove) { asl_log(NULL, NULL, ASL_LEVEL_INFO, "%s:%s: Adding browser to RemoveEvents", sPluginIdentifier, __FUNCTION__); AddEventDictionary(eventDictionary, plugin->_onRemoveEvents, browser); } // Add Token Mapping CFDictionarySetValue(plugin->_tokenToBrowserMap, launchdToken, browser); // Release Memory CFRelease(eventDictionary); }