org.chromium.chrome.browser.compositor.layouts.content.TabContentManager Java Examples

The following examples show how to use org.chromium.chrome.browser.compositor.layouts.content.TabContentManager. 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: CompositorViewHolder.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the appropriate objects this class should represent.
 * @param tabModelSelector        The {@link TabModelSelector} this View should hold and
 *                                represent.
 * @param tabCreatorManager       The {@link TabCreatorManager} for this view.
 * @param tabContentManager       The {@link TabContentManager} for the tabs.
 * @param androidContentContainer The {@link ViewGroup} the {@link LayoutManager} should bind
 *                                Android content to.
 * @param contextualSearchManager A {@link ContextualSearchManagementDelegate} instance.
 * @param readerModeManager       A {@link ReaderModeManagerDelegate} instance.
 */
public void onFinishNativeInitialization(TabModelSelector tabModelSelector,
        TabCreatorManager tabCreatorManager, TabContentManager tabContentManager,
        ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchManager,
        ReaderModeManagerDelegate readerModeManager) {
    assert mLayoutManager != null;
    mLayoutManager.init(tabModelSelector, tabCreatorManager, tabContentManager,
            androidContentContainer, contextualSearchManager, readerModeManager,
            mCompositorView.getResourceManager().getDynamicResourceLoader());
    mTabModelSelector = tabModelSelector;
    tabModelSelector.addObserver(new EmptyTabModelSelectorObserver() {
        @Override
        public void onChange() {
            onContentChanged();
        }

        @Override
        public void onNewTabCreated(Tab tab) {
            initializeTab(tab);
        }
    });

    onContentChanged();
}
 
Example #2
Source File: Layout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Build a {@link SceneLayer} if it hasn't already been built, and update it and return it.
 *
 * @param viewport          A viewport in which to display content.
 * @param contentViewport   The visible section of the viewport.
 * @param layerTitleCache   A layer title cache.
 * @param tabContentManager A tab content manager.
 * @param resourceManager   A resource manager.
 * @param fullscreenManager A fullscreen manager.
 * @return                  A {@link SceneLayer} that represents the content for this
 *                          {@link Layout}.
 */
public final SceneLayer getUpdatedSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);

    float offsetPx = fullscreenManager != null ? fullscreenManager.getTopControlOffset() : 0.f;
    float dpToPx = getContext().getResources().getDisplayMetrics().density;
    float offsetDp = offsetPx / dpToPx;

    SceneLayer content = getSceneLayer();
    for (int i = 0; i < mSceneOverlays.size(); i++) {
        // If the SceneOverlay is not showing, don't bother adding it to the tree.
        if (!mSceneOverlays.get(i).isSceneOverlayTreeShowing()) continue;

        SceneOverlayLayer overlayLayer = mSceneOverlays.get(i).getUpdatedSceneOverlayTree(
                layerTitleCache, resourceManager, offsetDp);

        overlayLayer.setContentTree(content);
        content = overlayLayer;
    }

    return content;
}
 
Example #3
Source File: StaticLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;

    final LayoutTab[] tabs = getLayoutTabsToRender();
    if (tabs == null || tabs.length != 1 || tabs[0].getId() == Tab.INVALID_TAB_ID) {
        return;
    }
    LayoutTab layoutTab = tabs[0];
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;

    mSceneLayer.update(dpToPx, contentViewport, layerTitleCache, tabContentManager,
            fullscreenManager, layoutTab);

    // TODO(dtrainor): Find the best way to properly track this metric for cold starts.
    // We should probably erase the thumbnail when we select a tab that we need to restore.
    if (tabContentManager != null
            && tabContentManager.hasFullCachedThumbnail(layoutTab.getId())) {
        TabModelImpl.logPerceivedTabSwitchLatencyMetric();
    }
}
 
Example #4
Source File: StaticTabSceneLayer.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Update {@link StaticTabSceneLayer} with the given parameters.
 *
 * @param dpToPx            The ratio of dp to px.
 * @param contentViewport   The viewport of the content.
 * @param layerTitleCache   The LayerTitleCache.
 * @param tabContentManager The TabContentManager.
 * @param fullscreenManager The FullscreenManager.
 * @param layoutTab         The LayoutTab.
 */
public void update(float dpToPx, Rect contentViewport, LayerTitleCache layerTitleCache,
        TabContentManager tabContentManager, ChromeFullscreenManager fullscreenManager,
        LayoutTab layoutTab) {
    if (layoutTab == null) {
        return;
    }

    float contentOffset =
            fullscreenManager != null ? fullscreenManager.getContentOffset() : 0.f;

    // TODO(dtrainor, clholgat): remove "* dpToPx" once the native part is fully supporting dp.
    nativeUpdateTabLayer(mNativePtr, contentViewport.left, contentViewport.top,
            contentViewport.width(), contentViewport.height(), tabContentManager,
            layoutTab.getId(), mResToolbarControlContainer, layoutTab.canUseLiveTexture(),
            layoutTab.getBackgroundColor(), layoutTab.getRenderX() * dpToPx,
            layoutTab.getRenderY() * dpToPx, layoutTab.getScaledContentWidth() * dpToPx,
            layoutTab.getScaledContentHeight() * dpToPx, contentOffset,
            layoutTab.getStaticToViewBlend(), layoutTab.getSaturation(),
            layoutTab.getBrightness());
}
 
Example #5
Source File: StaticTabSceneLayer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Update {@link StaticTabSceneLayer} with the given parameters.
 *
 * @param dpToPx            The ratio of dp to px.
 * @param contentViewport   The viewport of the content.
 * @param layerTitleCache   The LayerTitleCache.
 * @param tabContentManager The TabContentManager.
 * @param fullscreenManager The FullscreenManager.
 * @param layoutTab         The LayoutTab.
 */
public void update(float dpToPx, Rect contentViewport, LayerTitleCache layerTitleCache,
        TabContentManager tabContentManager, ChromeFullscreenManager fullscreenManager,
        LayoutTab layoutTab) {
    if (layoutTab == null) {
        return;
    }

    float contentOffset =
            fullscreenManager != null ? fullscreenManager.getContentOffset() : 0.f;

    // TODO(dtrainor, clholgat): remove "* dpToPx" once the native part is fully supporting dp.
    nativeUpdateTabLayer(mNativePtr, contentViewport.left, contentViewport.top,
            contentViewport.width(), contentViewport.height(), tabContentManager,
            layoutTab.getId(), mResToolbarControlContainer, layoutTab.canUseLiveTexture(),
            layoutTab.getBackgroundColor(), layoutTab.getRenderX() * dpToPx,
            layoutTab.getRenderY() * dpToPx, layoutTab.getScaledContentWidth() * dpToPx,
            layoutTab.getScaledContentHeight() * dpToPx, contentOffset,
            layoutTab.getStaticToViewBlend(), layoutTab.getSaturation(),
            layoutTab.getBrightness());
}
 
Example #6
Source File: TabModelImpl.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
public TabModelImpl(boolean incognito, boolean isTabbedActivity, TabCreator regularTabCreator,
        TabCreator incognitoTabCreator, TabModelSelectorUma uma,
        TabModelOrderController orderController, TabContentManager tabContentManager,
        TabPersistentStore tabSaver, TabModelDelegate modelDelegate, boolean supportUndo) {
    super(incognito, isTabbedActivity);
    initializeNative();
    mRegularTabCreator = regularTabCreator;
    mIncognitoTabCreator = incognitoTabCreator;
    mUma = uma;
    mOrderController = orderController;
    mTabContentManager = tabContentManager;
    mTabSaver = tabSaver;
    mModelDelegate = modelDelegate;
    mIsUndoSupported = supportUndo;
    mObservers = new ObserverList<TabModelObserver>();
    mRecentlyClosedBridge = new RecentlyClosedBridge(getProfile());
}
 
Example #7
Source File: TabModelImpl.java    From 365browser with Apache License 2.0 6 votes vote down vote up
public TabModelImpl(boolean incognito, boolean isTabbedActivity, TabCreator regularTabCreator,
        TabCreator incognitoTabCreator, TabModelSelectorUma uma,
        TabModelOrderController orderController, TabContentManager tabContentManager,
        TabPersistentStore tabSaver, TabModelDelegate modelDelegate, boolean supportUndo) {
    super(incognito, isTabbedActivity);
    initializeNative();
    mRegularTabCreator = regularTabCreator;
    mIncognitoTabCreator = incognitoTabCreator;
    mUma = uma;
    mOrderController = orderController;
    mTabContentManager = tabContentManager;
    mTabSaver = tabSaver;
    mModelDelegate = modelDelegate;
    mIsUndoSupported = supportUndo;
    mObservers = new ObserverList<TabModelObserver>();
    mRecentlyClosedBridge = new RecentlyClosedBridge(getProfile());
}
 
Example #8
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * This is called when the native library are ready.
 */
public void onNativeLibraryReady(
        WindowAndroid windowAndroid, TabContentManager tabContentManager) {
    assert mLayerTitleCache == null : "Should be called once";

    if (DeviceClassManager.enableLayerDecorationCache()) {
        mLayerTitleCache = new LayerTitleCache(getContext());
    }

    mCompositorView.initNativeCompositor(
            SysUtils.isLowEndDevice(), windowAndroid, mLayerTitleCache, tabContentManager);

    if (mLayerTitleCache != null) {
        mLayerTitleCache.setResourceManager(getResourceManager());
    }

    if (mControlContainer != null) {
        mCompositorView.getResourceManager().getDynamicResourceLoader().registerResource(
                R.id.control_container, mControlContainer.getToolbarResourceAdapter());
    }
}
 
Example #9
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeCompositor() {
    TraceEvent.begin("ChromeActivity:CompositorInitialization");
    super.initializeCompositor();

    setTabContentManager(new TabContentManager(this, getContentOffsetProvider(),
            DeviceClassManager.enableSnapshots()));
    mCompositorViewHolder.onNativeLibraryReady(getWindowAndroid(), getTabContentManager());

    if (isContextualSearchAllowed() && ContextualSearchFieldTrial.isEnabled()) {
        mContextualSearchManager = new ContextualSearchManager(this, this);
    }

    if (ReaderModeManager.isEnabled(this)) {
        mReaderModeManager = new ReaderModeManager(getTabModelSelector(), this);
        if (mToolbarManager != null) {
            mToolbarManager.addFindToolbarObserver(
                    mReaderModeManager.getFindToolbarObserver());
        }
    }

    TraceEvent.end("ChromeActivity:CompositorInitialization");
}
 
Example #10
Source File: Layout.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Build a {@link SceneLayer} if it hasn't already been built, and update it and return it.
 *
 * @param viewport          A viewport in which to display content.
 * @param contentViewport   The visible section of the viewport.
 * @param layerTitleCache   A layer title cache.
 * @param tabContentManager A tab content manager.
 * @param resourceManager   A resource manager.
 * @param fullscreenManager A fullscreen manager.
 * @return                  A {@link SceneLayer} that represents the content for this
 *                          {@link Layout}.
 */
public final SceneLayer getUpdatedSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);

    float offsetPx = fullscreenManager != null ? fullscreenManager.getControlOffset() : 0.f;
    float dpToPx = getContext().getResources().getDisplayMetrics().density;
    float offsetDp = offsetPx / dpToPx;

    SceneLayer content = getSceneLayer();
    for (int i = 0; i < mSceneOverlays.size(); i++) {
        // If the SceneOverlay is not showing, don't bother adding it to the tree.
        if (!mSceneOverlays.get(i).isSceneOverlayTreeShowing()) continue;

        SceneOverlayLayer overlayLayer = mSceneOverlays.get(i).getUpdatedSceneOverlayTree(
                layerTitleCache, resourceManager, offsetDp);

        overlayLayer.setContentTree(content);
        content = overlayLayer;
    }

    return content;
}
 
Example #11
Source File: StaticLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateSceneLayer(RectF viewport, RectF contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;

    final LayoutTab[] tabs = getLayoutTabsToRender();
    if (tabs == null || tabs.length != 1 || tabs[0].getId() == Tab.INVALID_TAB_ID) {
        return;
    }
    LayoutTab layoutTab = tabs[0];
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;

    mSceneLayer.update(
            dpToPx, layerTitleCache, tabContentManager, fullscreenManager, layoutTab);

    // TODO(dtrainor): Find the best way to properly track this metric for cold starts.
    // We should probably erase the thumbnail when we select a tab that we need to restore.
    if (tabContentManager != null
            && tabContentManager.hasFullCachedThumbnail(layoutTab.getId())) {
        TabModelImpl.logPerceivedTabSwitchLatencyMetric();
    }
}
 
Example #12
Source File: StaticLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;

    final LayoutTab[] tabs = getLayoutTabsToRender();
    if (tabs == null || tabs.length != 1 || tabs[0].getId() == Tab.INVALID_TAB_ID) {
        return;
    }
    LayoutTab layoutTab = tabs[0];
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;

    mSceneLayer.update(dpToPx, contentViewport, layerTitleCache, tabContentManager,
            fullscreenManager, layoutTab);

    // TODO(dtrainor): Find the best way to properly track this metric for cold starts.
    // We should probably erase the thumbnail when we select a tab that we need to restore.
    if (tabContentManager != null
            && tabContentManager.hasFullCachedThumbnail(layoutTab.getId())) {
        TabModelImpl.logPerceivedTabSwitchLatencyMetric();
    }
}
 
Example #13
Source File: Layout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Build a {@link SceneLayer} if it hasn't already been built, and update it and return it.
 *
 * @param viewport          A viewport in which to display content in px.
 * @param visibleViewport   The visible section of the viewport in px.
 * @param layerTitleCache   A layer title cache.
 * @param tabContentManager A tab content manager.
 * @param resourceManager   A resource manager.
 * @param fullscreenManager A fullscreen manager.
 * @return                  A {@link SceneLayer} that represents the content for this
 *                          {@link Layout}.
 */
public final SceneLayer getUpdatedSceneLayer(RectF viewport, RectF visibleViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    updateSceneLayer(viewport, visibleViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);

    float offsetPx = fullscreenManager != null ? fullscreenManager.getTopControlOffset() : 0.f;
    float dpToPx = getContext().getResources().getDisplayMetrics().density;
    float offsetDp = offsetPx / dpToPx;

    SceneLayer content = getSceneLayer();
    for (int i = 0; i < mSceneOverlays.size(); i++) {
        // If the SceneOverlay is not showing, don't bother adding it to the tree.
        if (!mSceneOverlays.get(i).isSceneOverlayTreeShowing()) continue;

        SceneOverlayLayer overlayLayer = mSceneOverlays.get(i).getUpdatedSceneOverlayTree(
                viewport, visibleViewport, layerTitleCache, resourceManager, offsetDp);

        overlayLayer.setContentTree(content);
        content = overlayLayer;
    }

    return content;
}
 
Example #14
Source File: LayoutManagerDocumentTabSwitcher.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void init(TabModelSelector selector, TabCreatorManager creator,
        TabContentManager content, ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchDelegate,
        ReaderModeManagerDelegate readerModeManagerDelegate,
        DynamicResourceLoader dynamicResourceLoader) {
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate,
            readerModeManagerDelegate, dynamicResourceLoader);

    mTitleCache = mHost.getTitleCache();
    TabModelSelector documentTabSelector = ChromeApplication.getDocumentTabModelSelector();
    mOverviewListLayout.setTabModelSelector(documentTabSelector, content);
    mOverviewLayout.setTabModelSelector(documentTabSelector, content);

    // TODO(changwan): do we really need this?
    startShowing(getDefaultLayout(), false);
}
 
Example #15
Source File: CompositorViewHolder.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * This is called when the native library are ready.
 */
public void onNativeLibraryReady(
        WindowAndroid windowAndroid, TabContentManager tabContentManager) {
    assert mLayerTitleCache == null : "Should be called once";

    if (DeviceClassManager.enableLayerDecorationCache()) {
        mLayerTitleCache = new LayerTitleCache(getContext());
    }

    mCompositorView.initNativeCompositor(
            SysUtils.isLowEndDevice(), windowAndroid, mLayerTitleCache, tabContentManager);

    if (mLayerTitleCache != null) {
        mLayerTitleCache.setResourceManager(getResourceManager());
    }

    if (mControlContainer != null) {
        mCompositorView.getResourceManager().getDynamicResourceLoader().registerResource(
                R.id.control_container, mControlContainer.getToolbarResourceAdapter());
    }
}
 
Example #16
Source File: CompositorView.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link CompositorView}'s native parts (e.g. the rendering parts).
 * @param lowMemDevice         If this is a low memory device.
 * @param windowAndroid        A {@link WindowAndroid} instance.
 * @param layerTitleCache      A {@link LayerTitleCache} instance.
 * @param tabContentManager    A {@link TabContentManager} instance.
 */
public void initNativeCompositor(boolean lowMemDevice, WindowAndroid windowAndroid,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager) {
    mWindowAndroid = windowAndroid;
    mLayerTitleCache = layerTitleCache;
    mTabContentManager = tabContentManager;

    mNativeCompositorView = nativeInit(lowMemDevice,
            windowAndroid.getNativePointer(), layerTitleCache, tabContentManager);

    assert !getHolder().getSurface().isValid()
        : "Surface created before native library loaded.";
    getHolder().addCallback(this);

    // Cover the black surface before it has valid content.
    setBackgroundColor(Color.WHITE);
    setVisibility(View.VISIBLE);

    // Grab the Resource Manager
    mResourceManager = nativeGetResourceManager(mNativeCompositorView);
}
 
Example #17
Source File: CustomTabLayoutManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void init(TabModelSelector selector, TabCreatorManager creator,
        TabContentManager content, ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchDelegate,
        ReaderModeManagerDelegate readerModeDelegate,
        DynamicResourceLoader dynamicResourceLoader) {
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate,
            readerModeDelegate, dynamicResourceLoader);
    for (TabModel model : selector.getModels()) model.addObserver(mTabModelObserver);
}
 
Example #18
Source File: LayoutManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public SceneLayer getUpdatedActiveSceneLayer(Rect viewport, LayerTitleCache layerTitleCache,
        TabContentManager tabContentManager, ResourceManager resourceManager,
        ChromeFullscreenManager fullscreenManager) {
    getViewportPixel(mCachedVisibleViewport);
    // TODO(mdjones): The concept of visible viewport is pretty confising since |viewport| can
    // also take the browser controls into consideration; this should be made more clear.
    // Furthermore, the below adjustments should not be necessary.
    mCachedVisibleViewport.right = mCachedVisibleViewport.left + mHost.getWidth();
    mCachedVisibleViewport.bottom = mCachedVisibleViewport.top + mHost.getHeight();
    return mActiveLayout.getUpdatedSceneLayer(viewport, mCachedVisibleViewport, layerTitleCache,
            tabContentManager, resourceManager, fullscreenManager);
}
 
Example #19
Source File: SimpleAnimationLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;
    mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, layerTitleCache,
            tabContentManager, resourceManager, fullscreenManager);
}
 
Example #20
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void setTabModelSelector(TabModelSelector modelSelector, TabContentManager manager) {
    super.setTabModelSelector(modelSelector, manager);
    mStacks[0].setTabModel(modelSelector.getModel(false));
    mStacks[1].setTabModel(modelSelector.getModel(true));
    resetScrollData();
}
 
Example #21
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;
    mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, layerTitleCache,
            tabContentManager, resourceManager, fullscreenManager);
}
 
Example #22
Source File: ChromeTabCreator.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the tab model and tab content manager to use.
 * @param model           The new {@link TabModel} to use.
 * @param orderController The controller for determining the order of tabs.
 * @param manager         The new {@link TabContentManager} to use.
 */
public void setTabModel(
        TabModel model, TabModelOrderController orderController, TabContentManager manager) {
    mTabModel = model;
    mOrderController = orderController;
    mTabContentManager = manager;
}
 
Example #23
Source File: CustomTabLayoutManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void init(TabModelSelector selector, TabCreatorManager creator,
        TabContentManager content, ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchDelegate,
        ReaderModeManagerDelegate readerModeDelegate,
        DynamicResourceLoader dynamicResourceLoader) {
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate,
            readerModeDelegate, dynamicResourceLoader);
    for (TabModel model : selector.getModels()) model.addObserver(mTabModelObserver);
}
 
Example #24
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the appropriate objects this class should represent.
 * @param tabModelSelector        The {@link TabModelSelector} this View should hold and
 *                                represent.
 * @param tabCreatorManager       The {@link TabCreatorManager} for this view.
 * @param tabContentManager       The {@link TabContentManager} for the tabs.
 * @param androidContentContainer The {@link ViewGroup} the {@link LayoutManager} should bind
 *                                Android content to.
 * @param contextualSearchManager A {@link ContextualSearchManagementDelegate} instance.
 * @param readerModeManager       A {@link ReaderModeManagerDelegate} instance.
 */
public void onFinishNativeInitialization(TabModelSelector tabModelSelector,
        TabCreatorManager tabCreatorManager, TabContentManager tabContentManager,
        ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchManager,
        ReaderModeManagerDelegate readerModeManager) {
    assert mLayoutManager != null;
    mLayoutManager.init(tabModelSelector, tabCreatorManager, tabContentManager,
            androidContentContainer, contextualSearchManager, readerModeManager,
            mCompositorView.getResourceManager().getDynamicResourceLoader());

    attachToTabModelSelector(tabModelSelector);

    onContentChanged();
}
 
Example #25
Source File: LayoutManagerChromePhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void init(TabModelSelector selector, TabCreatorManager creator,
        TabContentManager content, ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchDelegate,
        ReaderModeManagerDelegate readerModeDelegate,
        DynamicResourceLoader dynamicResourceLoader) {
    // Initialize Layouts
    mSimpleAnimationLayout.setTabModelSelector(selector, content);

    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate,
            readerModeDelegate, dynamicResourceLoader);
}
 
Example #26
Source File: LayoutManagerChromePhone.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void init(TabModelSelector selector, TabCreatorManager creator,
        TabContentManager content, ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchDelegate,
        ReaderModeManagerDelegate readerModeDelegate,
        DynamicResourceLoader dynamicResourceLoader) {
    // Initialize Layouts
    mSimpleAnimationLayout.setTabModelSelector(selector, content);

    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate,
            readerModeDelegate, dynamicResourceLoader);
}
 
Example #27
Source File: CompositorView.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the {@link CompositorView}'s native parts (e.g. the rendering parts).
 * @param lowMemDevice         If this is a low memory device.
 * @param windowAndroid        A {@link WindowAndroid} instance.
 * @param layerTitleCache      A {@link LayerTitleCache} instance.
 * @param tabContentManager    A {@link TabContentManager} instance.
 */
public void initNativeCompositor(boolean lowMemDevice, WindowAndroid windowAndroid,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager) {
    mWindowAndroid = windowAndroid;
    mLayerTitleCache = layerTitleCache;
    mTabContentManager = tabContentManager;

    mNativeCompositorView = nativeInit(lowMemDevice,
            windowAndroid.getNativePointer(), layerTitleCache, tabContentManager);

    assert !getHolder().getSurface().isValid()
        : "Surface created before native library loaded.";
    getHolder().addCallback(this);

    // Cover the black surface before it has valid content.
    setBackgroundColor(Color.WHITE);
    setVisibility(View.VISIBLE);

    mFramePresentationDelay = 0;
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        Display display =
                ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay();
        long presentationDeadline = display.getPresentationDeadlineNanos()
                / NANOSECONDS_PER_MILLISECOND;
        long vsyncPeriod = mWindowAndroid.getVsyncPeriodInMillis();
        mFramePresentationDelay = Math.min(3 * vsyncPeriod,
                ((presentationDeadline + vsyncPeriod - 1) / vsyncPeriod) * vsyncPeriod);
    }

    // Grab the Resource Manager
    mResourceManager = nativeGetResourceManager(mNativeCompositorView);
}
 
Example #28
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the appropriate objects this class should represent.
 * @param tabModelSelector        The {@link TabModelSelector} this View should hold and
 *                                represent.
 * @param tabCreatorManager       The {@link TabCreatorManager} for this view.
 * @param tabContentManager       The {@link TabContentManager} for the tabs.
 * @param androidContentContainer The {@link ViewGroup} the {@link LayoutManager} should bind
 *                                Android content to.
 * @param contextualSearchManager A {@link ContextualSearchManagementDelegate} instance.
 * @param readerModeManager       A {@link ReaderModeManagerDelegate} instance.
 */
public void onFinishNativeInitialization(TabModelSelector tabModelSelector,
        TabCreatorManager tabCreatorManager, TabContentManager tabContentManager,
        ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchManager,
        ReaderModeManagerDelegate readerModeManager) {
    assert mLayoutManager != null;
    mLayoutManager.init(tabModelSelector, tabCreatorManager, tabContentManager,
            androidContentContainer, contextualSearchManager, readerModeManager,
            mCompositorView.getResourceManager().getDynamicResourceLoader());
    mTabModelSelector = tabModelSelector;
    tabModelSelector.addObserver(new EmptyTabModelSelectorObserver() {
        @Override
        public void onChange() {
            onContentChanged();
        }

        @Override
        public void onNewTabCreated(Tab tab) {
            initializeTab(tab);
        }
    });

    mLayerTitleCache.setTabModelSelector(mTabModelSelector);

    onContentChanged();
}
 
Example #29
Source File: OverviewListLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void setTabModelSelector(
        TabModelSelector tabModelSelector, TabContentManager tabContentManager) {
    super.setTabModelSelector(tabModelSelector, tabContentManager);

    if (mTabModelWrapper == null) return;
    mTabModelWrapper.setTabModelSelector(tabModelSelector);
}
 
Example #30
Source File: ToolbarSwipeLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateSceneLayer(RectF viewport, RectF contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    // Use the default theme colors if the browser controls are at the bottom.
    if (fullscreenManager.areBrowserControlsAtBottom()) {
        for (LayoutTab t : mLayoutTabs) t.setForceDefaultThemeColor(true);
    }
    assert mSceneLayer != null;
    // contentViewport is intentionally passed for both parameters below.
    mSceneLayer.pushLayers(getContext(), contentViewport, contentViewport, this,
            layerTitleCache, tabContentManager, resourceManager, fullscreenManager);
}