Search in sources :

Example 6 with ChromeApplication

use of org.chromium.chrome.browser.ChromeApplication in project AndroidChromium by JackyAndroid.

the class ProcessInitializationHandler method handlePostNativeInitialization.

/**
 * Performs the post native initialization.
 */
protected void handlePostNativeInitialization() {
    final ChromeApplication application = (ChromeApplication) ContextUtils.getApplicationContext();
    DataReductionProxySettings.reconcileDataReductionProxyEnabledState(application);
    ChromeActivitySessionTracker.getInstance().initializeWithNative();
    ChromeApplication.removeSessionCookies();
    AppBannerManager.setAppDetailsDelegate(application.createAppDetailsDelegate());
    ChromeLifetimeController.initialize();
    PrefServiceBridge.getInstance().migratePreferences(application);
}
Also used : ChromeApplication(org.chromium.chrome.browser.ChromeApplication)

Example 7 with ChromeApplication

use of org.chromium.chrome.browser.ChromeApplication 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);
        }
    });
}
Also used : ChromeApplication(org.chromium.chrome.browser.ChromeApplication) Activity(android.app.Activity) FeedbackCollector(org.chromium.chrome.browser.feedback.FeedbackCollector) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 8 with ChromeApplication

use of org.chromium.chrome.browser.ChromeApplication in project AndroidChromium by JackyAndroid.

the class RevenueStats method getInstance.

/**
 * Returns the singleton instance of ExternalAuthUtils, creating it if needed.
 */
public static RevenueStats getInstance() {
    if (sInstance.get() == null) {
        ChromeApplication application = (ChromeApplication) ContextUtils.getApplicationContext();
        sInstance.compareAndSet(null, application.createRevenueStatsInstance());
    }
    return sInstance.get();
}
Also used : ChromeApplication(org.chromium.chrome.browser.ChromeApplication)

Example 9 with ChromeApplication

use of org.chromium.chrome.browser.ChromeApplication in project AndroidChromium by JackyAndroid.

the class TabWebContentsDelegateAndroid method addNewContents.

@CalledByNative
public boolean addNewContents(WebContents sourceWebContents, WebContents webContents, int disposition, Rect initialPosition, boolean userGesture) {
    assert mWebContentsUrlMapping.first == webContents;
    TabCreator tabCreator = mTab.getActivity().getTabCreator(mTab.isIncognito());
    assert tabCreator != null;
    // Grab the URL, which might not be available via the Tab.
    String url = mWebContentsUrlMapping.second;
    mWebContentsUrlMapping = null;
    // Skip opening a new Tab if it doesn't make sense.
    if (mTab.isClosing())
        return false;
    // Creating new Tabs asynchronously requires starting a new Activity to create the Tab,
    // so the Tab returned will always be null.  There's no way to know synchronously
    // whether the Tab is created, so assume it's always successful.
    boolean createdSuccessfully = tabCreator.createTabWithWebContents(mTab, webContents, mTab.getId(), TabLaunchType.FROM_LONGPRESS_FOREGROUND, url);
    boolean success = tabCreator.createsTabsAsynchronously() || createdSuccessfully;
    if (success && disposition == WindowOpenDisposition.NEW_POPUP) {
        PolicyAuditor auditor = ((ChromeApplication) mTab.getApplicationContext()).getPolicyAuditor();
        auditor.notifyAuditEvent(mTab.getApplicationContext(), AuditEvent.OPEN_POPUP_URL_SUCCESS, url, "");
    }
    return success;
}
Also used : ChromeApplication(org.chromium.chrome.browser.ChromeApplication) TabCreator(org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator) PolicyAuditor(org.chromium.chrome.browser.policy.PolicyAuditor) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 10 with ChromeApplication

use of org.chromium.chrome.browser.ChromeApplication in project AndroidChromium by JackyAndroid.

the class TabWebContentsObserver method didFinishLoad.

@Override
public void didFinishLoad(long frameId, String validatedUrl, boolean isMainFrame) {
    if (isMainFrame)
        mTab.didFinishPageLoad();
    PolicyAuditor auditor = ((ChromeApplication) mTab.getApplicationContext()).getPolicyAuditor();
    auditor.notifyAuditEvent(mTab.getApplicationContext(), AuditEvent.OPEN_URL_SUCCESS, validatedUrl, "");
}
Also used : ChromeApplication(org.chromium.chrome.browser.ChromeApplication) PolicyAuditor(org.chromium.chrome.browser.policy.PolicyAuditor)

Aggregations

ChromeApplication (org.chromium.chrome.browser.ChromeApplication)17 PolicyAuditor (org.chromium.chrome.browser.policy.PolicyAuditor)4 Activity (android.app.Activity)3 Context (android.content.Context)3 SuppressFBWarnings (org.chromium.base.annotations.SuppressFBWarnings)3 CalledByNative (org.chromium.base.annotations.CalledByNative)2 FeedbackCollector (org.chromium.chrome.browser.feedback.FeedbackCollector)2 Intent (android.content.Intent)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 View (android.view.View)1 ProcessInitException (org.chromium.base.library_loader.ProcessInitException)1 DevToolsServer (org.chromium.chrome.browser.DevToolsServer)1 UuidBasedUniqueIdentificationGenerator (org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGenerator)1 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)1 SyncPreference (org.chromium.chrome.browser.preferences.SyncPreference)1 TabCreator (org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator)1 ChildProcessCreationParams (org.chromium.content.browser.ChildProcessCreationParams)1 PrintDocumentAdapterWrapper (org.chromium.printing.PrintDocumentAdapterWrapper)1 UiUtils (org.chromium.ui.UiUtils)1