本文整理汇总了Java中org.chromium.chrome.browser.preferences.datareduction.DataReductionPromoUtils.getOptedOutOnFrePromo方法的典型用法代码示例。如果您正苦于以下问题:Java DataReductionPromoUtils.getOptedOutOnFrePromo方法的具体用法?Java DataReductionPromoUtils.getOptedOutOnFrePromo怎么用?Java DataReductionPromoUtils.getOptedOutOnFrePromo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.chromium.chrome.browser.preferences.datareduction.DataReductionPromoUtils
的用法示例。
在下文中一共展示了DataReductionPromoUtils.getOptedOutOnFrePromo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: maybeLaunchPromoInfoBar
import org.chromium.chrome.browser.preferences.datareduction.DataReductionPromoUtils; //导入方法依赖的package包/类
/**
* Launch the data reduction infobar promo, if it needs to be displayed.
*
* @param context An Android context.
* @param webContents The WebContents of the tab on which the infobar should show.
* @param url The URL of the page on which the infobar should show.
* @param isFragmentNavigation Whether the main frame navigation did not cause changes to the
* document (for example scrolling to a named anchor PopState).
* @param statusCode The HTTP status code of the navigation.
* @return boolean Whether the promo was launched.
*/
public static boolean maybeLaunchPromoInfoBar(Context context,
WebContents webContents, String url, boolean isErrorPage, boolean isFragmentNavigation,
int statusCode) {
ThreadUtils.assertOnUiThread();
if (webContents.isIncognito()) return false;
if (isErrorPage) return false;
if (isFragmentNavigation) return false;
if (statusCode != HttpURLConnection.HTTP_OK) return false;
if (!DataReductionPromoUtils.canShowPromos()) return false;
// Don't show the infobar promo if neither the first run experience or second run promo has
// been shown.
if (!DataReductionPromoUtils.getDisplayedFreOrSecondRunPromo()) return false;
// Don't show the promo if the user opted out on the first run experience promo.
if (DataReductionPromoUtils.getOptedOutOnFrePromo()) return false;
// Don't show the promo if the user has seen this infobar promo before.
if (DataReductionPromoUtils.getDisplayedInfoBarPromo()) return false;
// Only show the promo on HTTP pages.
if (!GURLUtils.getScheme(url).concat("://").equals(UrlConstants.HTTP_SCHEME)) return false;
int currentMilestone = VersionNumberGetter.getMilestoneFromVersionNumber(
PrefServiceBridge.getInstance().getAboutVersionStrings().getApplicationVersion());
String freOrSecondRunVersion =
DataReductionPromoUtils.getDisplayedFreOrSecondRunPromoVersion();
// Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577185
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
Calendar releaseDateOfM48Stable = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
releaseDateOfM48Stable.setTime(Date.valueOf(M48_STABLE_RELEASE_DATE));
long packageInstallTime = getPackageInstallTime(context);
// The boolean pref that stores whether user opted out on the first run experience was
// added in M51. If the last promo was shown before M51, then |freOrSecondRunVersion|
// will be empty. If Chrome was installed after the FRE promo was added in M48 and
// beforeM51,assume the user opted out from the FRE and don't show the infobar.
if (freOrSecondRunVersion.isEmpty()
&& packageInstallTime > releaseDateOfM48Stable.getTimeInMillis()) {
return false;
}
// Only show the promo if the current version is at least two milestones after the last
// promo was displayed or the command line switch is on. If the last promo was shown
// before M51 then |freOrSecondRunVersion| will be empty and it is safe to show the
// infobar promo.
if (!CommandLine.getInstance().hasSwitch(ENABLE_INFOBAR_SWITCH)
&& !freOrSecondRunVersion.isEmpty()
&& currentMilestone < VersionNumberGetter
.getMilestoneFromVersionNumber(freOrSecondRunVersion) + 2) {
return false;
}
DataReductionPromoInfoBar.launch(webContents,
BitmapFactory.decodeResource(context.getResources(),
R.drawable.infobar_chrome),
context.getString(R.string.data_reduction_promo_infobar_title),
context.getString(R.string.data_reduction_promo_infobar_text),
context.getString(R.string.data_reduction_promo_infobar_button),
context.getString(R.string.no_thanks));
return true;
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
}
示例2: maybeLaunchPromoInfoBar
import org.chromium.chrome.browser.preferences.datareduction.DataReductionPromoUtils; //导入方法依赖的package包/类
/**
* Launch the data reduction infobar promo, if it needs to be displayed.
*
* @param context An Android context.
* @param webContents The WebContents of the tab on which the infobar should show.
* @param url The URL of the page on which the infobar should show.
* @param isFragmentNavigation Whether the main frame navigation did not cause changes to the
* document (for example scrolling to a named anchor PopState).
* @param statusCode The HTTP status code of the navigation.
* @return boolean Whether the promo was launched.
*/
public static boolean maybeLaunchPromoInfoBar(Context context,
WebContents webContents, String url, boolean isErrorPage, boolean isFragmentNavigation,
int statusCode) {
ThreadUtils.assertOnUiThread();
if (webContents.isIncognito()) return false;
if (isErrorPage) return false;
if (isFragmentNavigation) return false;
if (statusCode != HttpURLConnection.HTTP_OK) return false;
if (!DataReductionPromoUtils.canShowPromos()) return false;
// Don't show the infobar promo if neither the first run experience or second run promo has
// been shown.
if (!DataReductionPromoUtils.getDisplayedFreOrSecondRunPromo()) return false;
// Don't show the promo if the user opted out on the first run experience promo.
if (DataReductionPromoUtils.getOptedOutOnFrePromo()) return false;
// Don't show the promo if the user has seen this infobar promo before.
if (DataReductionPromoUtils.getDisplayedInfoBarPromo()) return false;
// Only show the promo on HTTP pages.
if (!GURLUtils.getScheme(url).equals(UrlConstants.HTTP_SCHEME)) return false;
int currentMilestone = VersionNumberGetter.getMilestoneFromVersionNumber(
PrefServiceBridge.getInstance().getAboutVersionStrings().getApplicationVersion());
String freOrSecondRunVersion =
DataReductionPromoUtils.getDisplayedFreOrSecondRunPromoVersion();
// Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577185
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
Calendar releaseDateOfM48Stable = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
releaseDateOfM48Stable.setTime(Date.valueOf(M48_STABLE_RELEASE_DATE));
long packageInstallTime = getPackageInstallTime(context);
// The boolean pref that stores whether user opted out on the first run experience was
// added in M51. If the last promo was shown before M51, then |freOrSecondRunVersion|
// will be empty. If Chrome was installed after the FRE promo was added in M48 and
// beforeM51,assume the user opted out from the FRE and don't show the infobar.
if (freOrSecondRunVersion.isEmpty()
&& packageInstallTime > releaseDateOfM48Stable.getTimeInMillis()) {
return false;
}
// Only show the promo if the current version is at least two milestones after the last
// promo was displayed or the command line switch is on. If the last promo was shown
// before M51 then |freOrSecondRunVersion| will be empty and it is safe to show the
// infobar promo.
if (!CommandLine.getInstance().hasSwitch(ENABLE_INFOBAR_SWITCH)
&& !freOrSecondRunVersion.isEmpty()
&& currentMilestone < VersionNumberGetter
.getMilestoneFromVersionNumber(freOrSecondRunVersion) + 2) {
return false;
}
DataReductionPromoInfoBar.launch(webContents,
BitmapFactory.decodeResource(context.getResources(),
R.drawable.infobar_chrome),
context.getString(R.string.data_reduction_promo_infobar_title),
context.getString(R.string.data_reduction_promo_infobar_text),
context.getString(R.string.data_reduction_promo_infobar_button),
context.getString(R.string.no_thanks));
return true;
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
}