本文整理汇总了C++中WKRetainPtr类的典型用法代码示例。如果您正苦于以下问题:C++ WKRetainPtr类的具体用法?C++ WKRetainPtr怎么用?C++ WKRetainPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WKRetainPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startUpdatingCallback
static void startUpdatingCallback(WKGeolocationManagerRef manager, const void* clientInfo)
{
GeolocationStateTracker* stateTracker = static_cast<GeolocationStateTracker*>(const_cast<void*>(clientInfo));
stateTracker->events.push_back(GeolocationEvent::StartUpdating);
stateTracker->eventsChanged();
WKRetainPtr<WKGeolocationPositionRef> position = adoptWK(WKGeolocationPositionCreate(0, 50.644358, 3.345453, 2.53));
WKGeolocationManagerProviderDidChangePosition(manager, position.get());
}
示例2: toWK
void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
{
WKRetainPtr<WKStringRef> sourceWK = toWK(source);
WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld());
WKBundleAddUserScript(InjectedBundle::shared().bundle(), scriptWorld.get(), sourceWK.get(), 0, 0, 0,
(runAtStart ? kWKInjectAtDocumentStart : kWKInjectAtDocumentEnd),
(allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly));
}
示例3: adoptWK
void TestRunner::setUserStyleSheetEnabled(bool enabled)
{
m_userStyleSheetEnabled = enabled;
WKRetainPtr<WKStringRef> emptyUrl = adoptWK(WKStringCreateWithUTF8CString(""));
WKStringRef location = enabled ? m_userStyleSheetLocation.get() : emptyUrl.get();
auto& injectedBundle = InjectedBundle::singleton();
WKBundleSetUserStyleSheetLocation(injectedBundle.bundle(), injectedBundle.pageGroup(), location);
}
示例4: willSendRequestForFrame
static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void *clientInfo)
{
// Allow the loading of the main resource, but don't allow the loading of an iframe, return null from willSendRequest.
if (WKBundleFrameIsMainFrame(frame)) {
WKRetainPtr<WKURLRequestRef> newRequest = request;
return newRequest.leakRef();
}
return 0;
}
示例5: TEST_F
TEST_F(WebKit2UserMessageRoundTripTest, WKString)
{
WKRetainPtr<WKStringRef> string = adoptWK(WKStringCreateWithUTF8CString("An important string"));
roundTrip(string.get());
WKTypeRef roundTrippedTypeRef = recievedBody.get();
WKRetainPtr<WKStringRef> roundTrippedString = static_cast<WKStringRef>(roundTrippedTypeRef);
EXPECT_TRUE(WKStringIsEqual(roundTrippedString.get(), string.get()));
}
示例6: didAssociateFormControls
static void didAssociateFormControls(WKBundlePageRef page, WKArrayRef elementHandles, const void*)
{
WKRetainPtr<WKMutableDictionaryRef> messageBody = adoptWK(WKMutableDictionaryCreate());
WKDictionarySetItem(messageBody.get(), Util::toWK("Page").get(), page);
WKRetainPtr<WKUInt64Ref> numberOfElements = adoptWK(WKUInt64Create(WKArrayGetSize(elementHandles)));
WKDictionarySetItem(messageBody.get(), Util::toWK("NumberOfControls").get(), numberOfElements.get());
WKBundlePostMessage(InjectedBundleController::singleton().bundle(), Util::toWK("DidReceiveDidAssociateFormControls").get(), messageBody.get());
}
示例7: bundlePathForExtension
Ref<EwkContext> EwkContext::create(const String& extensionsPath)
{
String bundlePath = bundlePathForExtension();
if (bundlePath.isEmpty())
return adoptRef(*new EwkContext(adoptWK(WKContextCreate()).get()));
WKRetainPtr<WKStringRef> path = adoptWK(toCopiedAPI(bundlePath));
return adoptRef(*new EwkContext(adoptWK(WKContextCreateWithInjectedBundlePath(path.get())).get(), extensionsPath));
}
示例8: adoptWK
/**
* @internal
* The url of view was changed by the frame loader.
*
* Emits signal: "url,changed" with pointer to new url string.
*/
void EwkView::informURLChange()
{
WKRetainPtr<WKURLRef> wkActiveURL = adoptWK(WKPageCopyActiveURL(wkPage()));
WKRetainPtr<WKStringRef> wkURLString = wkActiveURL ? adoptWK(WKURLCopyString(wkActiveURL.get())) : adoptWK(WKStringCreateWithUTF8CString(""));
if (WKStringIsEqualToUTF8CString(wkURLString.get(), m_url))
return;
m_url = WKEinaSharedString(wkURLString.get());
smartCallback<URLChanged>().call(m_url);
}
示例9: initEcoreEvas
PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
{
m_window = initEcoreEvas();
m_view = EWKViewCreate(contextRef, pageGroupRef, ecore_evas_get(m_window), /* smart */ 0);
WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(TEST_THEME_DIR "/default.edj"));
WKViewSetThemePath(EWKViewGetWKView(m_view), wkTheme.get());
evas_object_smart_callback_add(m_view, "webprocess,crashed", onWebProcessCrashed, 0);
resizeTo(600, 800);
}
示例10: filterFirstItemCallback
static bool filterFirstItemCallback(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context)
{
if (!WKStringIsEqual(valueType, WKPageGetSessionBackForwardListItemValueType()))
return true;
ASSERT(WKGetTypeID(value) == WKBackForwardListItemGetTypeID());
WKBackForwardListItemRef backForwardListItem = static_cast<WKBackForwardListItemRef>(value);
WKRetainPtr<WKURLRef> url = adoptWK(WKBackForwardListItemCopyURL(backForwardListItem));
WKRetainPtr<WKStringRef> path = adoptWK(WKURLCopyLastPathComponent(url.get()));
return !WKStringIsEqualToUTF8CString(path.get(), "simple.html");
}
示例11: EWKViewCreate
Evas_Object* EWKViewCreate(WKContextRef context, WKPageGroupRef pageGroup, Evas* canvas, Evas_Smart* smart)
{
if (!EwkMain::singleton().isInitialized()) {
EINA_LOG_CRIT("EWebKit has not been initialized. You must call ewk_init() before creating view.");
return nullptr;
}
WKRetainPtr<WKViewRef> wkView = adoptWK(WKViewCreate(context, pageGroup));
if (EwkView* ewkView = EwkView::create(wkView.get(), canvas, smart))
return ewkView->evasObject();
return nullptr;
}
示例12: adoptWK
void QtWebPageUIClient::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
{
WKRetainPtr<WKArrayRef> wkSelectedFileNames = adoptWK(WKOpenPanelParametersCopySelectedFileNames(parameters));
QStringList selectedFileNames;
size_t selectedFilesSize = WKArrayGetSize(wkSelectedFileNames.get());
selectedFileNames.reserve(selectedFilesSize);
for (size_t i = 0; i < selectedFilesSize; ++i)
selectedFileNames += WKStringCopyQString(static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkSelectedFileNames.get(), i)));
FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? MultipleFilesSelection : SingleFileSelection;
toQtWebPageUIClient(clientInfo)->runOpenPanel(listener, selectedFileNames, allowMultipleFiles);
}
示例13: WKBundlePageGetMainFrame
void EventSendingController::mouseDown(int button, JSValueRef modifierArray)
{
WKBundlePageRef page = InjectedBundle::shared().page()->page();
WKBundleFrameRef frame = WKBundlePageGetMainFrame(page);
JSContextRef context = WKBundleFrameGetJavaScriptContext(frame);
WKEventModifiers modifiers = parseModifierArray(context, modifierArray);
#ifdef USE_WEBPROCESS_EVENT_SIMULATION
updateClickCount(button);
WKBundlePageSimulateMouseDown(page, button, m_position, m_clickCount, modifiers, m_time);
#else
WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate());
WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage"));
WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("MouseDown"));
WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
WKRetainPtr<WKStringRef> buttonKey = adoptWK(WKStringCreateWithUTF8CString("Button"));
WKRetainPtr<WKUInt64Ref> buttonRef = adoptWK(WKUInt64Create(button));
WKDictionaryAddItem(EventSenderMessageBody.get(), buttonKey.get(), buttonRef.get());
WKRetainPtr<WKStringRef> modifiersKey = adoptWK(WKStringCreateWithUTF8CString("Modifiers"));
WKRetainPtr<WKUInt64Ref> modifiersRef = adoptWK(WKUInt64Create(modifiers));
WKDictionaryAddItem(EventSenderMessageBody.get(), modifiersKey.get(), modifiersRef.get());
WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
#endif
}
示例14: ASSERT
WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
{
ASSERT(m_inspectedPage);
#ifdef HAVE_ECORE_X
const char* engine = "opengl_x11";
m_inspectorWindow = ecore_evas_new(engine, 0, 0, initialWindowWidth, initialWindowHeight, 0);
// Gracefully fall back to software if evas_gl engine is not available.
if (!m_inspectorWindow)
#endif
m_inspectorWindow = ecore_evas_new(0, 0, 0, initialWindowWidth, initialWindowHeight, 0);
if (!m_inspectorWindow)
return 0;
WKContextRef wkContext = toAPI(&inspectorProcessPool());
WKRetainPtr<WKStringRef> wkGroupIdentifier = adoptWK(WKStringCreateWithUTF8CString(inspectorPageGroupIdentifier().utf8().data()));
WKPageGroupRef wkPageGroup = WKPageGroupCreateWithIdentifier(wkGroupIdentifier.get());
WKRetainPtr<WKPageConfigurationRef> wkPageConfiguration = adoptWK(WKPageConfigurationCreate());
WKPageConfigurationSetContext(wkPageConfiguration.get(), wkContext);
WKPageConfigurationSetPageGroup(wkPageConfiguration.get(), wkPageGroup);
m_inspectorView = EWKViewCreate(wkContext, wkPageConfiguration.get(), ecore_evas_get(m_inspectorWindow), /* smart */ 0);
WKViewRef wkView = EWKViewGetWKView(m_inspectorView);
WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(DEFAULT_THEME_DIR "/default.edj"));
WKViewSetThemePath(wkView, wkTheme.get());
WKPreferencesRef wkPreferences = WKPageGroupGetPreferences(wkPageGroup);
WKPreferencesSetFileAccessFromFileURLsAllowed(wkPreferences, true);
WKPreferencesSetJavaScriptRuntimeFlags(wkPreferences, 0);
return toImpl(WKViewGetPage(wkView));
}
示例15: willLoadDataRequest
static void willLoadDataRequest(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo)
{
WKRetainPtr<WKMutableDictionaryRef> messageBody = adoptWK(WKMutableDictionaryCreate());
WKDictionarySetItem(messageBody.get(), Util::toWK("URLRequestReturn").get(), request);
WKDictionarySetItem(messageBody.get(), Util::toWK("DataReturn").get(), data);
WKDictionarySetItem(messageBody.get(), Util::toWK("MIMETypeReturn").get(), MIMEType);
WKDictionarySetItem(messageBody.get(), Util::toWK("EncodingNameReturn").get(), encodingName);
WKDictionarySetItem(messageBody.get(), Util::toWK("UnreachableURLReturn").get(), unreachableURL);
WKDictionarySetItem(messageBody.get(), Util::toWK("UserDataReturn").get(), userData);
WKBundlePostMessage(InjectedBundleController::singleton().bundle(), Util::toWK("WillLoadDataRequestReturn").get(), messageBody.get());
}