use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class ChromeHttpAuthHandler method showDialog.
@CalledByNative
private void showDialog(WindowAndroid windowAndroid) {
if (windowAndroid == null) {
cancel();
}
Activity activity = windowAndroid.getActivity().get();
if (activity == null) {
cancel();
}
LoginPrompt authDialog = new LoginPrompt(activity, this);
setAutofillObserver(authDialog);
authDialog.show();
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class IntentHelper method sendEmail.
/**
* Triggers a send email intent. If no application has registered to receive these intents,
* this will fail silently. If an email is not specified and the device has exactly one
* account and the account name matches the email format, the email is set to the account name.
*
* @param context The context for issuing the intent.
* @param email The email address to send to.
* @param subject The subject of the email.
* @param body The body of the email.
* @param chooserTitle The title of the activity chooser.
* @param fileToAttach The file name of the attachment.
*/
@CalledByNative
static void sendEmail(Context context, String email, String subject, String body, String chooserTitle, String fileToAttach) {
if (TextUtils.isEmpty(email)) {
Account[] accounts = AccountManagerHelper.get(context).getGoogleAccounts();
if (accounts != null && accounts.length == 1 && Patterns.EMAIL_ADDRESS.matcher(accounts[0].name).matches()) {
email = accounts[0].name;
}
}
Intent send = new Intent(Intent.ACTION_SEND);
send.setType("message/rfc822");
if (!TextUtils.isEmpty(email))
send.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
send.putExtra(Intent.EXTRA_SUBJECT, subject);
send.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
if (!TextUtils.isEmpty(fileToAttach)) {
File fileIn = new File(fileToAttach);
Uri fileUri;
// instead.
try {
fileUri = ContentUriUtils.getContentUriFromFile(context, fileIn);
} catch (IllegalArgumentException ex) {
fileUri = Uri.fromFile(fileIn);
}
send.putExtra(Intent.EXTRA_STREAM, fileUri);
}
try {
Intent chooser = Intent.createChooser(send, chooserTitle);
// we start this activity outside the main activity.
chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(chooser);
} catch (android.content.ActivityNotFoundException ex) {
// If no app handles it, do nothing.
}
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class OfflinePageNotificationBridge method notifyDownloadProgress.
/**
* Called by offline page backend to notify the user of download progress.
* @param context Context to show notifications.
* @param guid GUID of a request to download a page related to the notification.
* @param url URL of the page to download.
* @param startTime Time of the request.
* @param displayName Name to be displayed on notification.
*/
@CalledByNative
public static void notifyDownloadProgress(Context context, String guid, String url, long startTime, String displayName) {
DownloadNotifier notifier = getDownloadNotifier(context);
if (notifier == null)
return;
DownloadInfo downloadInfo = new DownloadInfo.Builder().setIsOfflinePage(true).setDownloadGuid(guid).setFileName(displayName).setFilePath(url).setPercentCompleted(-1).setIsOffTheRecord(false).setIsResumable(true).setTimeRemainingInMillis(0).build();
notifier.notifyDownloadProgress(downloadInfo, startTime, false);
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class OfflinePageNotificationBridge method notifyDownloadInterrupted.
/**
* Update download notification to interrupted.
* @param context Context to show notifications.
* @param guid GUID of a request to download a page related to the notification.
* @param displayName Name to be displayed on notification.
*/
@CalledByNative
public static void notifyDownloadInterrupted(Context context, String guid, String displayName) {
DownloadNotifier notifier = getDownloadNotifier(context);
if (notifier == null)
return;
DownloadInfo downloadInfo = new DownloadInfo.Builder().setIsOfflinePage(true).setDownloadGuid(guid).setFileName(displayName).setIsResumable(true).build();
notifier.notifyDownloadInterrupted(downloadInfo, true);
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class DomDistillerUIUtils method reportFeedbackWithWebContents.
/**
* A static method for native code to open the external feedback form UI.
* @param webContents The WebContents containing the distilled content.
* @param url The URL to report feedback for.
* @param good True if the feedback is good and false if not.
*/
@CalledByNative
public static void reportFeedbackWithWebContents(WebContents webContents, String url, final boolean good) {
ThreadUtils.assertOnUiThread();
// TODO(mdjones): It would be better to get the WebContents from the manager so that the
// native code does not need to depend on RenderFrame.
Activity activity = getActivityFromWebContents(webContents);
if (activity == null)
return;
if (sFeedbackReporter == null) {
ChromeApplication application = (ChromeApplication) activity.getApplication();
sFeedbackReporter = application.createFeedbackReporter();
}
FeedbackCollector.create(activity, Profile.getLastUsedProfile(), url, new FeedbackCollector.FeedbackResult() {
@Override
public void onResult(FeedbackCollector collector) {
String quality = good ? DISTILLATION_QUALITY_GOOD : DISTILLATION_QUALITY_BAD;
collector.add(DISTILLATION_QUALITY_KEY, quality);
sFeedbackReporter.reportFeedback(collector);
}
});
}
Aggregations