use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class ChromeBackgroundService method onRunTask.
@Override
@VisibleForTesting
public int onRunTask(final TaskParams params) {
final String taskTag = params.getTag();
Log.i(TAG, "[" + taskTag + "] Woken up at " + new java.util.Date().toString());
final ChromeBackgroundServiceWaiter waiter = getWaiterIfNeeded(params.getExtras());
final Context context = this;
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
switch(taskTag) {
case BackgroundSyncLauncher.TASK_TAG:
handleBackgroundSyncEvent(context, taskTag);
break;
case OfflinePageUtils.TASK_TAG:
handleOfflinePageBackgroundLoad(context, params.getExtras(), waiter, taskTag);
break;
case SnippetsLauncher.TASK_TAG_WIFI:
case SnippetsLauncher.TASK_TAG_FALLBACK:
handleFetchSnippets(context, taskTag);
break;
case PrecacheController.PERIODIC_TASK_TAG:
case PrecacheController.CONTINUATION_TASK_TAG:
handlePrecache(context, taskTag);
break;
case DownloadResumptionScheduler.TASK_TAG:
DownloadResumptionScheduler.getDownloadResumptionScheduler(context.getApplicationContext()).handleDownloadResumption();
break;
default:
Log.i(TAG, "Unknown task tag " + taskTag);
break;
}
}
});
// If needed, block the GcmNetworkManager thread until the UI thread has finished its work.
waitForTaskIfNeeded(waiter);
return GcmNetworkManager.RESULT_SUCCESS;
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class ChromeActivity method onShareMenuItemSelected.
/**
* Triggered when the share menu item is selected.
* This creates and shows a share intent picker dialog or starts a share intent directly.
* @param shareDirectly Whether it should share directly with the activity that was most
* recently used to share.
* @param isIncognito Whether currentTab is incognito.
*/
@VisibleForTesting
public void onShareMenuItemSelected(final boolean shareDirectly, final boolean isIncognito) {
final Tab currentTab = getActivityTab();
if (currentTab == null)
return;
PrintingController printingController = PrintingControllerImpl.getInstance();
if (printingController != null && !currentTab.isNativePage() && !printingController.isBusy() && PrefServiceBridge.getInstance().isPrintingEnabled()) {
PrintShareActivity.enablePrintShareOption(this, new Runnable() {
@Override
public void run() {
triggerShare(currentTab, shareDirectly, isIncognito);
}
});
return;
}
triggerShare(currentTab, shareDirectly, isIncognito);
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class ShareHelper method setLastShareComponentName.
/*
* Stores the component selected for sharing last time share was called.
*
* This method is public since it is used in tests to avoid creating share dialog.
*/
@VisibleForTesting
public static void setLastShareComponentName(ComponentName component) {
SharedPreferences preferences = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = preferences.edit();
editor.putString(PACKAGE_NAME_KEY, component.getPackageName());
editor.putString(CLASS_NAME_KEY, component.getClassName());
editor.apply();
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class SingleWebsitePreferences method resetSite.
/**
* Resets the current site, clearing all permissions and storage used (inc. cookies).
*/
@VisibleForTesting
protected void resetSite() {
if (getActivity() == null)
return;
// Clear the screen.
// TODO(mvanouwerkerk): Refactor this class so that it does not depend on the screen state
// for its logic. This class should maintain its own data model, and only update the screen
// after a change is made.
PreferenceScreen screen = getPreferenceScreen();
for (String key : PERMISSION_PREFERENCE_KEYS) {
Preference preference = screen.findPreference(key);
if (preference != null)
screen.removePreference(preference);
}
// Clear the permissions.
mSite.setAutoplayPermission(ContentSetting.DEFAULT);
mSite.setBackgroundSyncPermission(ContentSetting.DEFAULT);
mSite.setCameraPermission(ContentSetting.DEFAULT);
mSite.setCookiePermission(ContentSetting.DEFAULT);
WebsitePreferenceBridge.nativeClearCookieData(mSite.getAddress().getTitle());
mSite.setFullscreenPermission(ContentSetting.DEFAULT);
mSite.setGeolocationPermission(ContentSetting.DEFAULT);
mSite.setJavaScriptPermission(ContentSetting.DEFAULT);
mSite.setKeygenPermission(ContentSetting.DEFAULT);
mSite.setMicrophonePermission(ContentSetting.DEFAULT);
mSite.setMidiPermission(ContentSetting.DEFAULT);
mSite.setNotificationPermission(ContentSetting.DEFAULT);
mSite.setPopupPermission(ContentSetting.DEFAULT);
mSite.setProtectedMediaIdentifierPermission(ContentSetting.DEFAULT);
for (UsbInfo info : mSite.getUsbInfo()) info.revoke();
// Clear the storage and finish the activity if necessary.
if (mSite.getTotalUsage() > 0) {
clearStoredData();
} else {
// Clearing stored data implies popping back to parent menu if there
// is nothing left to show. Therefore, we only need to explicitly
// close the activity if there's no stored data to begin with.
getActivity().finish();
}
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class NotificationBuilderBase method createIconGenerator.
@VisibleForTesting
static RoundedIconGenerator createIconGenerator(Resources resources) {
int largeIconWidthPx = resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
int largeIconHeightPx = resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
float density = resources.getDisplayMetrics().density;
int cornerRadiusPx = Math.min(largeIconWidthPx, largeIconHeightPx) / 2;
return new RoundedIconGenerator(largeIconWidthPx, largeIconHeightPx, cornerRadiusPx, NOTIFICATION_ICON_BG_COLOR, NOTIFICATION_ICON_TEXT_SIZE_DP * density);
}
Aggregations