Search in sources :

Example 1 with TabCreator

use of org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator in project AndroidChromium by JackyAndroid.

the class TabWebContentsDelegateAndroid method webContentsCreated.

@Override
public void webContentsCreated(WebContents sourceWebContents, long openerRenderFrameId, String frameName, String targetUrl, WebContents newWebContents) {
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().webContentsCreated(mTab, sourceWebContents, openerRenderFrameId, frameName, targetUrl, newWebContents);
    }
    // The URL can't be taken from the WebContents if it's paused.  Save it for later.
    assert mWebContentsUrlMapping == null;
    mWebContentsUrlMapping = Pair.create(newWebContents, targetUrl);
    // TODO(dfalcantara): Re-remove this once crbug.com/508366 is fixed.
    TabCreator tabCreator = mTab.getActivity().getTabCreator(mTab.isIncognito());
    if (tabCreator != null && tabCreator.createsTabsAsynchronously()) {
        DocumentWebContentsDelegate.getInstance().attachDelegate(newWebContents);
    }
}
Also used : TabCreator(org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator)

Example 2 with TabCreator

use of org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator 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)

Aggregations

TabCreator (org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator)2 CalledByNative (org.chromium.base.annotations.CalledByNative)1 ChromeApplication (org.chromium.chrome.browser.ChromeApplication)1 PolicyAuditor (org.chromium.chrome.browser.policy.PolicyAuditor)1