本文整理汇总了C++中CefString类的典型用法代码示例。如果您正苦于以下问题:C++ CefString类的具体用法?C++ CefString怎么用?C++ CefString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CefString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPrintJob
bool ClientPrintHandlerGtk::OnPrintJob(
const CefString& document_name,
const CefString& pdf_file_path,
CefRefPtr<CefPrintJobCallback> callback) {
// If |printer_| is NULL then somehow the GTK printer list changed out under
// us. In which case, just bail out.
if (!printer_)
return false;
job_callback_ = callback;
// Save the settings for next time.
GetLastUsedSettings()->SetLastUsedSettings(gtk_settings_);
GtkPrintJob* print_job = gtk_print_job_new(
document_name.ToString().c_str(),
printer_,
gtk_settings_,
page_setup_);
gtk_print_job_set_source_file(print_job,
pdf_file_path.ToString().c_str(),
NULL);
gtk_print_job_send(print_job, OnJobCompletedThunk, this, NULL);
return true;
}
示例2: cef_string_list_size
FWebBrowserPopupFeatures::FWebBrowserPopupFeatures( const CefPopupFeatures& PopupFeatures )
{
X = PopupFeatures.x;
bXSet = PopupFeatures.xSet ? true : false;
Y = PopupFeatures.y;
bYSet = PopupFeatures.ySet ? true : false;
Width = PopupFeatures.width;
bWidthSet = PopupFeatures.widthSet ? true : false;
Height = PopupFeatures.height;
bHeightSet = PopupFeatures.heightSet ? true : false;
bMenuBarVisible = PopupFeatures.menuBarVisible ? true : false;
bStatusBarVisible = PopupFeatures.statusBarVisible ? true : false;
bToolBarVisible = PopupFeatures.toolBarVisible ? true : false;
bLocationBarVisible = PopupFeatures.locationBarVisible ? true : false;
bScrollbarsVisible = PopupFeatures.scrollbarsVisible ? true : false;
bResizable = PopupFeatures.resizable ? true : false;
bIsFullscreen = PopupFeatures.fullscreen ? true : false;
bIsDialog = PopupFeatures.dialog ? true : false;
int Count = PopupFeatures.additionalFeatures ? cef_string_list_size(PopupFeatures.additionalFeatures) : 0;
CefString ListValue;
for(int ListIdx = 0; ListIdx < Count; ListIdx++)
{
cef_string_list_value(PopupFeatures.additionalFeatures, ListIdx, ListValue.GetWritableStruct());
AdditionalFeatures.Add(ListValue.ToWString().c_str());
}
}
示例3: GetBrowser
QUrl QCefWebView::url() const {
if (GetBrowser().get()) {
CefString url = GetBrowser()->GetMainFrame()->GetURL();
return QUrl(QString::fromStdWString(url.ToWString()));
}
return QUrl();
}
示例4: AppGetCommandLine
// Inject webinos.js
// The file is loaded from the webinos\test\client folder if possible.
// If this fails, the current folder is used.
void ClientApp::InjectWebinos(CefRefPtr<CefFrame> frame)
{
CefRefPtr<CefCommandLine> commandLine = AppGetCommandLine();
// First try and load the platform-supplied webinos.js
std::string pzpPath = AppGetWebinosWRTConfig(NULL,NULL);
CefString wrtPath;
// Make sure there is a trailing separator on the path.
if (pzpPath.length() > 0)
{
if (pzpPath.find_last_of('/') == pzpPath.length()-1 || pzpPath.find_last_of('\\') == pzpPath.length()-1)
wrtPath = pzpPath + "wrt/webinos.js";
else
wrtPath = pzpPath + "/wrt/webinos.js";
}
#if defined(OS_WIN)
base::FilePath webinosJSPath(wrtPath.ToWString().c_str());
#else
base::FilePath webinosJSPath(wrtPath);
#endif
LOG(INFO) << "webinos.js path is " << wrtPath;
int64 webinosJSCodeSize;
bool gotJSFile = base::GetFileSize(webinosJSPath, &webinosJSCodeSize);
if (gotJSFile)
{
char* webinosJSCode = new char[webinosJSCodeSize+1];
base::ReadFile(webinosJSPath, webinosJSCode, webinosJSCodeSize);
webinosJSCode[webinosJSCodeSize] = 0;
if (frame == NULL)
{
// Register as a Cef extension.
CefRegisterExtension("webinos", webinosJSCode, NULL);
}
else
{
// Run the code in the frame javascript context right now,
// but only if the URL refers to the widget server.
int widgetServerPort;
AppGetWebinosWRTConfig(NULL,&widgetServerPort);
char injectionCandidate[MAX_URL_LENGTH];
sprintf(injectionCandidate,"http://localhost:%d",widgetServerPort);
std::string url = frame->GetURL();
if (url.substr(0,strlen(injectionCandidate)) == injectionCandidate)
frame->ExecuteJavaScript(webinosJSCode, url, 0);
}
delete[] webinosJSCode;
}
else
{
LOG(ERROR) << "Can't find webinos.js";
}
}
示例5: navigateToUrl
void QCefView::navigateToUrl(const QString& url)
{
if (cefWindow_)
{
CefString strUrl;
strUrl.FromString(url.toStdString());
cefWindow_->cefViewHandler()->GetBrowser()->GetMainFrame()->LoadURL(strUrl);
}
}
示例6: value
JNIEXPORT jstring JNICALL Java_org_limewire_cef_CefV8Value_1N_N_1GetStringValue
(JNIEnv *env, jobject obj)
{
CefRefPtr<CefV8Value> value(
(CefV8Value*)GetCefBaseFromJNIObject(env, obj));
if(!value.get())
return NULL;
CefString str = value->GetStringValue();
return env->NewString((const jchar*)str.c_str(), str.length());
}
示例7: ExecuteJavaScript
//================================================================================
// Ejecuta JavaScript
//================================================================================
void CefBasePanel::ExecuteJavaScript( const char *script )
{
if ( !GetClient() )
return;
CefString code;
code.FromASCII( script );
CefString file;
GetClient()->GetBrowser()->GetMainFrame()->ExecuteJavaScript( code, file, 0 );
}
示例8: navigateToString
void QCefView::navigateToString(const QString& content, const QString& url)
{
if (cefWindow_)
{
CefString strContent;
strContent.FromString(content.toStdString());
CefString strUrl;
strUrl.FromString(url.toStdString());
cefWindow_->cefViewHandler()->GetBrowser()->GetMainFrame()->LoadString(strContent, strUrl);
}
}
示例9: OpenURL
//================================================================================
// Abre la dirección web
//================================================================================
void CefBasePanel::OpenURL( const char *address )
{
if ( !GetClient() )
return;
CefString str;
str.FromASCII( address );
GetClient()->GetBrowser()->GetMainFrame()->LoadURL( str );
ResizeView();
DevMsg( "CefBasePanel::OpenURL: %s \n", address );
}
示例10: GetIcon
HICON TransparentWnd::GetIcon(CefString path){
if(path.ToWString().find(L":")==-1){
wstring _path;
_path=url.ToWString();
replace_allW(_path, L"\\", L"/");
_path=_path.substr(0,_path.find_last_of('/')+1);
path=_path.append(path);
}
return (HICON)::LoadImage(NULL,path.ToWString().data(),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
//Bitmap bm(path.ToWString().data());
//HICON hIcon;
//bm.GetHICON(&hIcon);
//return hIcon;
}
示例11: Download
void TransparentWnd::Download(CefString url,CefString filename){
std::stringstream ss;
string s=url.ToString();
ss<<"var img = new Image();"
<<"img.src='"<<url.ToString();
if(s.find("?")==string::npos){
ss<<"?t='+Date.now()+'&AlloyDesktop_download=";
}
else{
ss<<"&AlloyDesktop_download=";
}
ss<<filename.ToString()<<"';";
this->ExecJS(ss.str());
}
示例12: sendEVentNotifyMessage
bool QCefView::sendEVentNotifyMessage(int frameId, const QString& name, const QCefEvent& event)
{
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create(
TRIGGEREVENT_NOTIFY_MESSAGE);
CefRefPtr<CefListValue> arguments = msg->GetArgumentList();
int idx = 0;
arguments->SetInt(idx++, frameId);
CefString eventName = name.toStdString();
arguments->SetString(idx++, eventName);
CefRefPtr<CefDictionaryValue> dict = CefDictionaryValue::Create();
CefString cefStr;
cefStr.FromWString(event.objectName().toStdWString());
dict->SetString("name", cefStr);
QList<QByteArray> keys = event.dynamicPropertyNames();
for (QByteArray key : keys)
{
QVariant value = event.property(key.data());
if (value.type() == QMetaType::Bool)
{
dict->SetBool(key.data(), value.toBool());
}
else if (value.type() == QMetaType::Int || value.type() == QMetaType::UInt)
{
dict->SetInt(key.data(), value.toInt());
}
else if (value.type() == QMetaType::Double)
{
dict->SetDouble(key.data(), value.toDouble());
}
else if (value.type() == QMetaType::QString)
{
cefStr.FromWString(value.toString().toStdWString());
dict->SetString(key.data(), cefStr);
}
else
{
__noop(_T("QCefView"), _T("Unknow Type!"));
}
}
arguments->SetDictionary(idx++, dict);
return cefWindow_->cefViewHandler()->TriggerEvent(msg);
}
示例13: OpenLiveBrowser
int32 OpenLiveBrowser(ExtensionString argURL, bool enableRemoteDebugging)
{
const char *remoteDebuggingFormat = "--no-first-run --no-default-browser-check --allow-file-access-from-files --temp-profile --user-data-dir=%s --remote-debugging-port=9222";
gchar *remoteDebugging;
gchar *cmdline;
int error = ERR_BROWSER_NOT_INSTALLED;
GError *gerror = NULL;
if (enableRemoteDebugging) {
CefString appSupportDirectory = ClientApp::AppGetSupportDirectory();
// TODO: (INGO) to better understand to string conversion issue, I need a consultant
// here. Getting the char* from CefString I had to call ToString().c_str()
// Calling only c_str() didn't return anything.
gchar *userDataDir = g_strdup_printf("%s/live-dev-profile",
appSupportDirectory.ToString().c_str());
g_message("USERDATADIR= %s", userDataDir);
remoteDebugging = g_strdup_printf(remoteDebuggingFormat, userDataDir);
g_free(userDataDir);
} else {
remoteDebugging = g_strdup("");
}
// check for supported browsers (in PATH directories)
for (size_t i = 0; i < sizeof(browsers) / sizeof(browsers[0]); i++) {
cmdline = g_strdup_printf("%s %s %s", browsers[i].c_str(), argURL.c_str(), remoteDebugging);
if (g_spawn_command_line_async(cmdline, &gerror)) {
// browser is found in os; stop iterating
error = NO_ERROR;
} else {
error = ConvertGnomeErrorCode(gerror);
}
g_free(cmdline);
if (error == NO_ERROR) {
break;
} else {
g_error_free(gerror);
gerror = NULL;
}
}
g_free(remoteDebugging);
return error;
}
示例14: OnJSDialog
bool CaffeineClientHandler::OnJSDialog(
CefRefPtr<CefBrowser> browser,
const CefString& origin_url,
const CefString& accept_lang,
JSDialogType dialog_type,
const CefString& message_text,
const CefString& default_prompt_text,
CefRefPtr<CefJSDialogCallback> callback,
bool& suppress_message)
{
if (dialog_type == JSDIALOGTYPE_ALERT)
{
#ifdef OS_WIN
// TODO: Look up from the string table.
MessageBox(m_MainHwnd, message_text.c_str(), FULL_PRODUCT, MB_OK);
#else
wstring msg = message_text;
alertMessage(msg);
#endif
callback->Continue(true, message_text);
return true;
}
return false;
}
示例15: OpenFileDialog
CefString TransparentWnd::GetOpenName(CefString fileName){
TCHAR szFile[4096];
OpenFileDialog(hWnd, fileName.ToWString().data(), szFile);
wstring d(szFile);
CefString s(d);
return s;
}