本文整理汇总了C++中ContentChild::SendShowAlert方法的典型用法代码示例。如果您正苦于以下问题:C++ ContentChild::SendShowAlert方法的具体用法?C++ ContentChild::SendShowAlert怎么用?C++ ContentChild::SendShowAlert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentChild
的用法示例。
在下文中一共展示了ContentChild::SendShowAlert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowPersistentNotification
NS_IMETHODIMP nsAlertsService::ShowPersistentNotification(const nsAString & aPersistentData,
nsIAlertNotification * aAlert,
nsIObserver * aAlertListener)
{
NS_ENSURE_ARG(aAlert);
nsAutoString cookie;
nsresult rv = aAlert->GetCookie(cookie);
NS_ENSURE_SUCCESS(rv, rv);
if (XRE_IsContentProcess()) {
ContentChild* cpc = ContentChild::GetSingleton();
if (aAlertListener)
cpc->AddRemoteAlertObserver(cookie, aAlertListener);
cpc->SendShowAlert(aAlert);
return NS_OK;
}
// Check if there is an optional service that handles system-level notifications
if (mBackend) {
rv = ShowWithBackend(mBackend, aAlert, aAlertListener, aPersistentData);
if (NS_SUCCEEDED(rv)) {
return rv;
}
// If the system backend failed to show the alert, clear the backend and
// retry with XUL notifications. Future alerts will always use XUL.
mBackend = nullptr;
}
if (!ShouldShowAlert()) {
// Do not display the alert. Instead call alertfinished and get out.
if (aAlertListener)
aAlertListener->Observe(nullptr, "alertfinished", cookie.get());
return NS_OK;
}
// Use XUL notifications as a fallback if above methods have failed.
nsCOMPtr<nsIAlertsService> xulBackend(nsXULAlerts::GetInstance());
NS_ENSURE_TRUE(xulBackend, NS_ERROR_FAILURE);
return ShowWithBackend(xulBackend, aAlert, aAlertListener, aPersistentData);
}
示例2: ShowAlert
NS_IMETHODIMP nsAlertsService::ShowAlert(nsIAlertNotification * aAlert,
nsIObserver * aAlertListener)
{
NS_ENSURE_ARG(aAlert);
nsAutoString cookie;
nsresult rv = aAlert->GetCookie(cookie);
NS_ENSURE_SUCCESS(rv, rv);
if (XRE_IsContentProcess()) {
ContentChild* cpc = ContentChild::GetSingleton();
if (aAlertListener)
cpc->AddRemoteAlertObserver(cookie, aAlertListener);
cpc->SendShowAlert(aAlert);
return NS_OK;
}
nsAutoString imageUrl;
rv = aAlert->GetImageURL(imageUrl);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString title;
rv = aAlert->GetTitle(title);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString text;
rv = aAlert->GetText(text);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString name;
rv = aAlert->GetName(name);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principal;
rv = aAlert->GetPrincipal(getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
#ifdef MOZ_WIDGET_ANDROID
mozilla::AndroidBridge::Bridge()->ShowAlertNotification(imageUrl, title, text, cookie,
aAlertListener, name, principal);
return NS_OK;
#else
// Check if there is an optional service that handles system-level notifications
nsCOMPtr<nsIAlertsService> sysAlerts(do_GetService(NS_SYSTEMALERTSERVICE_CONTRACTID));
if (sysAlerts) {
rv = sysAlerts->ShowAlert(aAlert, aAlertListener);
if (NS_SUCCEEDED(rv))
return NS_OK;
}
if (!ShouldShowAlert()) {
// Do not display the alert. Instead call alertfinished and get out.
if (aAlertListener)
aAlertListener->Observe(nullptr, "alertfinished", cookie.get());
return NS_OK;
}
bool textClickable;
rv = aAlert->GetTextClickable(&textClickable);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString bidi;
rv = aAlert->GetDir(bidi);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString lang;
rv = aAlert->GetLang(lang);
NS_ENSURE_SUCCESS(rv, rv);
bool inPrivateBrowsing;
rv = aAlert->GetInPrivateBrowsing(&inPrivateBrowsing);
NS_ENSURE_SUCCESS(rv, rv);
// Use XUL notifications as a fallback if above methods have failed.
rv = mXULAlerts.ShowAlertNotification(imageUrl, title, text, textClickable,
cookie, aAlertListener, name,
bidi, lang, principal, inPrivateBrowsing);
return rv;
#endif // !MOZ_WIDGET_ANDROID
}