org.chromium.base.Callback Java Examples
The following examples show how to use
org.chromium.base.Callback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SuggestionsSection.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void dismissItem(int position, Callback<String> itemRemovedCallback) { checkIndex(position); SuggestionsSource suggestionsSource = mUiDelegate.getSuggestionsSource(); if (suggestionsSource == null) { // It is possible for this method to be called after the NewTabPage has had // destroy() called. This can happen when // NewTabPageRecyclerView.dismissWithAnimation() is called and the animation ends // after the user has navigated away. In this case we cannot inform the native side // that the snippet has been dismissed (http://crbug.com/649299). return; } SnippetArticle suggestion = remove(position); suggestionsSource.dismissSuggestion(suggestion); itemRemovedCallback.onResult(suggestion.mTitle); }
Example #2
Source File: WebsitePermissionsFetcher.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void runAsync(final TaskQueue queue) { WebsitePreferenceBridge.fetchStorageInfo(new Callback<ArrayList>() { @Override public void onResult(ArrayList result) { @SuppressWarnings("unchecked") ArrayList<StorageInfo> infoArray = result; for (StorageInfo info : infoArray) { WebsiteAddress address = WebsiteAddress.create(info.getHost()); if (address == null) continue; findOrCreateSite(address, null).addStorageInfo(info); } queue.next(); } }); }
Example #3
Source File: PaymentRequestImpl.java From delion with Apache License 2.0 | 6 votes |
@Override public void getSectionInformation(@PaymentRequestUI.DataType final int optionType, final Callback<SectionInformation> callback) { mHandler.post(new Runnable() { @Override public void run() { if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { callback.onResult(mShippingAddressesSection); } else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) { callback.onResult(mUiShippingOptions); } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { callback.onResult(mContactSection); } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { assert mPaymentMethodsSection != null; callback.onResult(mPaymentMethodsSection); } } }); }
Example #4
Source File: OfflinePageUtils.java From 365browser with Apache License 2.0 | 6 votes |
/** * Takes the offline page item from selectPageForOnlineURL. If it exists, invokes * |prepareForSharing| with it. Otherwise, saves a page for the online URL and invokes * |prepareForSharing| with the result when it's ready. * @param webContents Contents of the page to save. * @param offlinePageBridge A static copy of the offlinePageBridge. * @param prepareForSharing Callback of a single OfflinePageItem that is used to call * prepareForSharing * @return a callback of OfflinePageItem */ private static Callback<OfflinePageItem> selectPageForOnlineUrlCallback( final WebContents webContents, final OfflinePageBridge offlinePageBridge, final Callback<OfflinePageItem> prepareForSharing) { return new Callback<OfflinePageItem>() { @Override public void onResult(OfflinePageItem item) { if (item == null) { // If the page has no offline copy, save the page offline. ClientId clientId = ClientId.createGuidClientIdForNamespace( OfflinePageBridge.SHARE_NAMESPACE); offlinePageBridge.savePage(webContents, clientId, savePageCallback(prepareForSharing, offlinePageBridge)); return; } // If the online page has offline copy associated with it, use the file directly. prepareForSharing.onResult(item); } }; }
Example #5
Source File: PaymentRequestImpl.java From delion with Apache License 2.0 | 6 votes |
@Override public boolean onSectionAddOption( @PaymentRequestUI.DataType int optionType, Callback<PaymentInformation> callback) { if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { editAddress(null); if (mMerchantNeedsShippingAddress) { mPaymentInformationCallback = callback; return true; } } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { editContact(null); } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { PreferencesLauncher.launchSettingsPage( mContext, AutofillLocalCardEditor.class.getName()); } return false; }
Example #6
Source File: OfflinePageUtils.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Takes the offline page item from selectPageForOnlineURL. If it exists, invokes * |prepareForSharing| with it. Otherwise, saves a page for the online URL and invokes * |prepareForSharing| with the result when it's ready. * @param webContents Contents of the page to save. * @param offlinePageBridge A static copy of the offlinePageBridge. * @param prepareForSharing Callback of a single OfflinePageItem that is used to call * prepareForSharing * @return a callback of OfflinePageItem */ private static Callback<OfflinePageItem> selectPageForOnlineUrlCallback( final WebContents webContents, final OfflinePageBridge offlinePageBridge, final Callback<OfflinePageItem> prepareForSharing) { return new Callback<OfflinePageItem>() { @Override public void onResult(OfflinePageItem item) { if (item == null) { // If the page has no offline copy, save the page offline. ClientId clientId = ClientId.createGuidClientIdForNamespace( OfflinePageBridge.SHARE_NAMESPACE); offlinePageBridge.savePage(webContents, clientId, savePageCallback(prepareForSharing, offlinePageBridge)); return; } // If the online page has offline copy associated with it, use the file directly. prepareForSharing.onResult(item); } }; }
Example #7
Source File: AccountSigninView.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void showConfirmSigninPagePreviousAccountCheck() { String accountName = getSelectedAccountName(); ConfirmSyncDataStateMachine.run(PrefServiceBridge.getInstance().getSyncLastAccountName(), accountName, ImportSyncType.PREVIOUS_DATA_FOUND, mDelegate.getFragmentManager(), getContext(), new ConfirmImportSyncDataDialog.Listener() { @Override public void onConfirm(boolean wipeData) { SigninManager.wipeSyncUserDataIfRequired(wipeData) .then(new Callback<Void>() { @Override public void onResult(Void v) { showConfirmSigninPage(); } }); } @Override public void onCancel() { setButtonsEnabled(true); } }); }
Example #8
Source File: WebsitePermissionsFetcher.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void runAsync(final TaskQueue queue) { WebsitePreferenceBridge.fetchLocalStorageInfo(new Callback<HashMap>() { @Override public void onResult(HashMap result) { for (Object o : result.entrySet()) { @SuppressWarnings("unchecked") Map.Entry<String, LocalStorageInfo> entry = (Map.Entry<String, LocalStorageInfo>) o; WebsiteAddress address = WebsiteAddress.create(entry.getKey()); if (address == null) continue; findOrCreateSite(address, null).setLocalStorageInfo(entry.getValue()); } queue.next(); } }); }
Example #9
Source File: MediaDrmSessionManager.java From 365browser with Apache License 2.0 | 6 votes |
/** * Load |emeId|'s session data from persistent storage. */ void load(byte[] emeId, final Callback<SessionId> callback) { mStorage.loadInfo(emeId, new Callback<PersistentInfo>() { @Override public void onResult(PersistentInfo persistentInfo) { if (persistentInfo == null) { callback.onResult(null); return; } // Loading same persistent license into different sessions isn't // supported. assert getSessionIdByEmeId(persistentInfo.emeId()) == null; SessionInfo info = SessionInfo.fromPersistentInfo(persistentInfo); mEmeSessionInfoMap.put(ByteBuffer.wrap(persistentInfo.emeId()), info); callback.onResult(info.sessionId()); } }); }
Example #10
Source File: PaymentRequestImpl.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void editContact(final AutofillContact toEdit) { if (toEdit != null) { // Log the edit of a contact info. mJourneyLogger.incrementSelectionEdits( PaymentRequestJourneyLogger.SECTION_CONTACT_INFO); } mContactEditor.edit(toEdit, new Callback<AutofillContact>() { @Override public void onResult(AutofillContact completeContact) { if (mUI == null) return; if (completeContact == null) { mContactSection.setSelectedItemIndex(SectionInformation.NO_SELECTION); } else if (toEdit == null) { mContactSection.addAndSelectItem(completeContact); } mUI.updateSection(PaymentRequestUI.TYPE_CONTACT_DETAILS, mContactSection); } }); }
Example #11
Source File: VariationsSession.java From 365browser with Apache License 2.0 | 6 votes |
/** * Triggers to the native VariationsService that the application has entered the foreground. */ public void start(Context context) { // If |mRestrictModeFetchStarted| is true and |mRestrictMode| is null, then async // initializationn is in progress and nativeStartVariationsSession() will be called // when it completes. if (mRestrictModeFetchStarted && mRestrictMode == null) { return; } mRestrictModeFetchStarted = true; getRestrictModeValue(context, new Callback<String>() { @Override public void onResult(String restrictMode) { nativeStartVariationsSession(mRestrictMode); } }); }
Example #12
Source File: AccountSigninView.java From 365browser with Apache License 2.0 | 6 votes |
private void showConfirmSigninPagePreviousAccountCheck(long seedingStartTime) { RecordHistogram.recordTimesHistogram("Signin.AndroidAccountSigninViewSeedingTime", SystemClock.elapsedRealtime() - seedingStartTime, TimeUnit.MILLISECONDS); String accountName = getSelectedAccountName(); ConfirmSyncDataStateMachine.run(PrefServiceBridge.getInstance().getSyncLastAccountName(), accountName, ImportSyncType.PREVIOUS_DATA_FOUND, mDelegate.getFragmentManager(), getContext(), new ConfirmImportSyncDataDialog.Listener() { @Override public void onConfirm(boolean wipeData) { SigninManager.wipeSyncUserDataIfRequired(wipeData) .then(new Callback<Void>() { @Override public void onResult(Void v) { showConfirmSigninPage(); } }); } @Override public void onCancel() { setButtonsEnabled(true); } }); }
Example #13
Source File: PaymentRequestImpl.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void editAddress(final AutofillAddress toEdit) { if (toEdit != null) { // Log the edit of a shipping address. mJourneyLogger.incrementSelectionEdits( PaymentRequestJourneyLogger.SECTION_SHIPPING_ADDRESS); } mAddressEditor.edit(toEdit, new Callback<AutofillAddress>() { @Override public void onResult(AutofillAddress completeAddress) { if (mUI == null) return; if (completeAddress == null) { mShippingAddressesSection.setSelectedItemIndex(SectionInformation.NO_SELECTION); providePaymentInformation(); } else { if (toEdit == null) mShippingAddressesSection.addAndSelectItem(completeAddress); mCardEditor.updateBillingAddressIfComplete(completeAddress); mClient.onShippingAddressChange(completeAddress.toPaymentAddress()); } } }); }
Example #14
Source File: TabbedModeTabPersistencePolicy.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * <p> * Creates an asynchronous task to delete persistent data. The task is run using a thread pool * and may be executed in parallel with other tasks. The cleanup task use a combination of the * current model and the tab state files for other models to determine which tab files should * be deleted. The cleanup task should be canceled if a second tab model is created. */ @Override public void cleanupUnusedFiles(Callback<List<String>> filesToDelete) { synchronized (CLEAN_UP_TASK_LOCK) { if (sCleanupTask != null) sCleanupTask.cancel(true); sCleanupTask = new CleanUpTabStateDataTask(filesToDelete); sCleanupTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }
Example #15
Source File: BrowserActionsContextMenuHelper.java From 365browser with Apache License 2.0 | 5 votes |
public BrowserActionsContextMenuHelper(BrowserActionActivity activity, ContextMenuParams params, List<BrowserActionItem> customItems) { mActivity = activity; mCurrentContextMenuParams = params; mOnMenuShown = new Runnable() { @Override public void run() { mActivity.onMenuShown(); } }; mOnMenuClosed = new Runnable() { @Override public void run() { mActivity.finish(); } }; mItemSelectedCallback = new Callback<Integer>() { @Override public void onResult(Integer result) { onItemSelected(result); } }; mOnShareClickedRunnable = new Runnable() { @Override public void run() {} }; mDelegate = new BrowserActionsContextMenuItemDelegate(); mItems = buildContextMenuItems(customItems); }
Example #16
Source File: PaymentRequestImpl.java From delion with Apache License 2.0 | 5 votes |
private void editContact(final AutofillContact toEdit) { mContactEditor.edit(toEdit, new Callback<AutofillContact>() { @Override public void onResult(AutofillContact completeContact) { if (completeContact == null) { mContactSection.setSelectedItemIndex(SectionInformation.NO_SELECTION); } else if (toEdit == null) { mContactSection.addAndSelectItem(completeContact); } mUI.updateSection(PaymentRequestUI.TYPE_CONTACT_DETAILS, mContactSection); } }); }
Example #17
Source File: MediaDrmSessionManager.java From 365browser with Apache License 2.0 | 5 votes |
/** * Set key set ID. It should only be called for persistent license session. */ void setKeySetId(SessionId sessionId, byte[] keySetId, Callback<Boolean> callback) { assert get(sessionId) != null; assert get(sessionId).keyType() == MediaDrm.KEY_TYPE_OFFLINE; assert sessionId.keySetId() == null; sessionId.setKeySetId(keySetId); mStorage.saveInfo(get(sessionId).toPersistentInfo(), callback); }
Example #18
Source File: MediaDrmStorageBridge.java From 365browser with Apache License 2.0 | 5 votes |
/** * Called when device provisioning is finished. */ void onProvisioned(Callback<Boolean> cb) { if (isNativeMediaDrmStorageValid()) { nativeOnProvisioned(mNativeMediaDrmStorageBridge, cb); } else { cb.onResult(true); } }
Example #19
Source File: TileGroupDelegateImpl.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void removeMostVisitedItem(Tile item, Callback<String> removalUndoneCallback) { assert !mIsDestroyed; mMostVisitedSites.addBlacklistedUrl(item.getUrl()); showTileRemovedSnackbar(item.getUrl(), removalUndoneCallback); }
Example #20
Source File: ChildAccountService.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Checks for the presence of child accounts on the device. * * @param callback A callback which will be called with the result. */ public static void checkHasChildAccount(Context context, final Callback<Boolean> callback) { ThreadUtils.assertOnUiThread(); final AccountManagerHelper helper = AccountManagerHelper.get(context); helper.getGoogleAccounts(new Callback<Account[]>() { @Override public void onResult(Account[] accounts) { if (accounts.length != 1) { callback.onResult(false); } else { helper.checkChildAccount(accounts[0], callback); } } }); }
Example #21
Source File: OfflinePageUtils.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Share an offline copy of the current page. * @param shareDirectly Whether it should share directly with the activity that was most * recently used to share. * @param saveLastUsed Whether to save the chosen activity for future direct sharing. * @param mainActivity Activity that is used to access package manager. * @param text Text to be shared. If both |text| and |url| are supplied, they are concatenated * with a space. * @param screenshotUri Screenshot of the page to be shared. * @param callback Optional callback to be called when user makes a choice. Will not be called * if receiving a response when the user makes a choice is not supported (see * TargetChosenReceiver#isSupported()). * @param currentTab The current tab for which sharing is being done. */ public static void shareOfflinePage(final boolean shareDirectly, final boolean saveLastUsed, final Activity mainActivity, final String text, final Uri screenshotUri, final ShareHelper.TargetChosenCallback callback, final Tab currentTab) { final String url = currentTab.getUrl(); final String title = currentTab.getTitle(); final OfflinePageBridge offlinePageBridge = OfflinePageBridge.getForProfile(currentTab.getProfile()); if (offlinePageBridge == null) { Log.e(TAG, "Unable to perform sharing on current tab."); return; } OfflinePageItem offlinePage = currentTab.getOfflinePage(); if (offlinePage != null) { // If we're currently on offline page get the saved file directly. prepareFileAndShare(shareDirectly, saveLastUsed, mainActivity, title, text, url, screenshotUri, callback, offlinePage.getFilePath()); return; } // If this is an online page, share the offline copy of it. Callback<OfflinePageItem> prepareForSharing = onGotOfflinePageItemToShare(shareDirectly, saveLastUsed, mainActivity, title, text, url, screenshotUri, callback); offlinePageBridge.selectPageForOnlineUrl(url, currentTab.getId(), selectPageForOnlineUrlCallback(currentTab.getWebContents(), offlinePageBridge, prepareForSharing)); }
Example #22
Source File: PaymentRequestUI.java From 365browser with Apache License 2.0 | 5 votes |
/** * Shows the PaymentRequest UI. */ public void show() { mDialog.show(); mClient.getDefaultPaymentInformation(new Callback<PaymentInformation>() { @Override public void onResult(PaymentInformation result) { updateOrderSummarySection(result.getShoppingCart()); if (mRequestShipping) { updateSection(TYPE_SHIPPING_ADDRESSES, result.getShippingAddresses()); updateSection(TYPE_SHIPPING_OPTIONS, result.getShippingOptions()); mShippingSummarySection.update(new ShippingSummaryInformation( result.getShippingAddresses(), result.getShippingOptions())); // Let the summary display a CHOOSE/ADD button for the first subsection that // needs it. PaymentRequestSection section = mShippingAddressSection.getEditButtonState() == EDIT_BUTTON_GONE ? mShippingOptionSection : mShippingAddressSection; mShippingSummarySection.setEditButtonState(section.getEditButtonState()); } if (mRequestContactDetails) { updateSection(TYPE_CONTACT_DETAILS, result.getContactDetails()); } updateSection(TYPE_PAYMENT_METHODS, result.getPaymentMethods()); updatePayButtonEnabled(); // Hide the loading indicators and show the real sections. changeSpinnerVisibility(false); mRequestView.addOnLayoutChangeListener(new SheetEnlargingAnimator(false)); } }); }
Example #23
Source File: SigninManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Same as above but retrieves the Account object for the given accountName. */ public void signIn(String accountName, @Nullable final Activity activity, @Nullable final SignInCallback callback) { AccountManagerHelper.get(mContext).getAccountFromName(accountName, new Callback<Account>() { @Override public void onResult(Account account) { signIn(account, activity, callback); } }); }
Example #24
Source File: ConfirmSyncDataStateMachine.java From 365browser with Apache License 2.0 | 5 votes |
private void requestNewAccountManagementStatus() { SigninManager.isUserManaged(mNewAccountName, new Callback<Boolean>() { @Override public void onResult(Boolean result) { setIsNewAccountManaged(result); } }); }
Example #25
Source File: TabPersistentStore.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Asynchronously triggers a cleanup of any unused persistent data. */ private void cleanUpPersistentData() { mPersistencePolicy.cleanupUnusedFiles(new Callback<List<String>>() { @Override public void onResult(List<String> result) { if (result == null) return; for (int i = 0; i < result.size(); i++) { deleteFileAsync(result.get(i)); } } }); }
Example #26
Source File: PaymentRequestImpl.java From 365browser with Apache License 2.0 | 5 votes |
private void editContact(final AutofillContact toEdit) { if (toEdit != null) { // Log the edit of a contact info. mJourneyLogger.incrementSelectionEdits(Section.CONTACT_INFO); } mContactEditor.edit(toEdit, new Callback<AutofillContact>() { @Override public void onResult(AutofillContact editedContact) { if (mUI == null) return; if (editedContact != null) { // A partial or complete contact came back from the editor (could have been from // adding/editing or cancelling out of the edit flow). if (!editedContact.isComplete()) { // If the contact is not complete according to the requirements of the flow, // unselect it (editor can return incomplete information when cancelled). mContactSection.setSelectedItemIndex(SectionInformation.NO_SELECTION); } else if (toEdit == null) { // Contact is complete and we were in the "Add flow": add an item to the // list. mContactSection.addAndSelectItem(editedContact); } // If contact is complete and (toEdit != null), no action needed: the contact // was already selected in the UI. } // If |editedContact| is null, the user has cancelled out of the "Add flow". No // action to take (if a contact was selected in the UI, it will stay selected). mUI.updateSection(PaymentRequestUI.TYPE_CONTACT_DETAILS, mContactSection); } }); }
Example #27
Source File: PaymentRequestImpl.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void getShoppingCart(final Callback<ShoppingCart> callback) { mHandler.post(new Runnable() { @Override public void run() { callback.onResult(mUiShoppingCart); } }); }
Example #28
Source File: BackgroundOfflinerTask.java From 365browser with Apache License 2.0 | 5 votes |
private Callback<Boolean> createCallback(final ChromeBackgroundServiceWaiter waiter) { return new Callback<Boolean>() { /** Callback releasing the wakelock once background work concludes. */ @Override public void onResult(Boolean result) { Log.d(TAG, "onResult"); // Release the wake lock. waiter.onWaitDone(); } }; }
Example #29
Source File: OfflinePageBridge.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Gets the offline pages associated with the provided client IDs. * * @param clientIds Client's IDs associated with offline pages. * @return A list of {@link OfflinePageItem} matching the provided IDs, or an empty list if none * exist. */ @VisibleForTesting public void getPagesByClientIds( final List<ClientId> clientIds, final Callback<List<OfflinePageItem>> callback) { String[] namespaces = new String[clientIds.size()]; String[] ids = new String[clientIds.size()]; for (int i = 0; i < clientIds.size(); i++) { namespaces[i] = clientIds.get(i).getNamespace(); ids[i] = clientIds.get(i).getId(); } List<OfflinePageItem> result = new ArrayList<>(); nativeGetPagesByClientId(mNativeOfflinePageBridge, result, namespaces, ids, callback); }
Example #30
Source File: OfflineBackgroundTask.java From 365browser with Apache License 2.0 | 5 votes |
/** Wraps the callback for code reuse */ private Callback<Boolean> wrapCallback(final TaskFinishedCallback callback) { return new Callback<Boolean>() { @Override public void onResult(Boolean result) { callback.taskFinished(result); } }; }