Java Code Examples for org.chromium.chrome.browser.tabmodel.TabModel

The following examples show how to use org.chromium.chrome.browser.tabmodel.TabModel. These examples are extracted from open source projects. 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 Project: delion   Source File: ChromeTabbedActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onDestroyInternal() {
    if (mLayoutManager != null) mLayoutManager.removeOverviewModeObserver(this);

    if (mTabModelSelectorTabObserver != null) {
        mTabModelSelectorTabObserver.destroy();
        mTabModelSelectorTabObserver = null;
    }

    if (mTabModelObserver != null) {
        for (TabModel model : mTabModelSelectorImpl.getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }

    if (mUndoBarPopupController != null) {
        mUndoBarPopupController.destroy();
        mUndoBarPopupController = null;
    }

    super.onDestroyInternal();
}
 
Example 2
Source Project: delion   Source File: StaticLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void setStaticTab(final int id) {
    if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
        if (!mLayoutTabs[0].shouldStall()) setPostHideState();
        return;
    }
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model == null) return;
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    if (mLayoutTabs == null || mLayoutTabs.length != 1) mLayoutTabs = new LayoutTab[1];
    mLayoutTabs[0] = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
    mLayoutTabs[0].setDrawDecoration(false);
    if (mLayoutTabs[0].shouldStall()) {
        setPreHideState();
        mHandler.postDelayed(mUnstallRunnable, HIDE_TIMEOUT_MS);
    } else {
        setPostHideState();
    }
    requestRender();
}
 
Example 3
Source Project: 365browser   Source File: TileGroupDelegateImpl.java    License: Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private boolean switchToExistingTab(String url) {
    String matchPattern =
            CommandLine.getInstance().getSwitchValue(ChromeSwitches.NTP_SWITCH_TO_EXISTING_TAB);
    boolean matchByHost;
    if ("url".equals(matchPattern)) {
        matchByHost = false;
    } else if ("host".equals(matchPattern)) {
        matchByHost = true;
    } else {
        return false;
    }

    TabModel tabModel = mTabModelSelector.getModel(false);
    for (int i = tabModel.getCount() - 1; i >= 0; --i) {
        if (matchURLs(tabModel.getTabAt(i).getUrl(), url, matchByHost)) {
            TabModelUtils.setIndex(tabModel, i);
            return true;
        }
    }
    return false;
}
 
Example 4
Source Project: delion   Source File: StackViewAnimation.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The wrapper method responsible for delegating animation requests to the appropriate helper
 * method.
 * @param type       The type of animation to be created.  This is what determines which helper
 *                   method is called.
 * @param tabs       The tabs that make up the current stack.
 * @param container  The {@link ViewGroup} that {@link View}s can be added to/removed from.
 * @param model      The {@link TabModel} that this animation will influence.
 * @param focusIndex The index of the tab that is the focus of this animation.
 * @return           The resulting {@link Animator} that will animate the Android views.
 */
public Animator createAnimatorForType(OverviewAnimationType type, StackTab[] tabs,
        ViewGroup container, TabModel model, int focusIndex) {
    Animator animator = null;

    if (model != null) {
        switch (type) {
            case NEW_TAB_OPENED:
                animator = createNewTabOpenedAnimator(tabs, container, model, focusIndex);
                break;
            default:
                break;
        }
    }

    return animator;
}
 
Example 5
Source Project: 365browser   Source File: UmaSessionStats.java    License: Apache License 2.0 6 votes vote down vote up
private void recordPageLoadStats(Tab tab) {
    WebContents webContents = tab.getWebContents();
    boolean isDesktopUserAgent = webContents != null
            && webContents.getNavigationController().getUseDesktopUserAgent();
    nativeRecordPageLoaded(isDesktopUserAgent);
    if (mKeyboardConnected) {
        nativeRecordPageLoadedWithKeyboard();
    }

    // If the session has ended (i.e. chrome is in the background), escape early. Ideally we
    // could track this number as part of either the previous or next session but this isn't
    // possible since the TabSelector is needed to figure out the current number of open tabs.
    if (mTabModelSelector == null) return;

    TabModel regularModel = mTabModelSelector.getModel(false);
    nativeRecordTabCountPerLoad(getTabCountFromModel(regularModel));
}
 
Example 6
Source Project: delion   Source File: SimpleAnimationLayout.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set up for the tab closing animation
 */
@Override
public void onTabClosing(long time, int id) {
    reset();

    // Make sure any currently running animations can't influence tab if we are reusing it.
    forceAnimationToFinish();

    // Create the {@link LayoutTab} for the tab before it is destroyed.
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model != null) {
        mClosedTab = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
        mClosedTab.setBorderAlpha(0.0f);
        mLayoutTabs = new LayoutTab[] {mClosedTab};
        updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    } else {
        mLayoutTabs = null;
        mClosedTab = null;
    }
    // Only close the id at the end when we are done querying the model.
    super.onTabClosing(time, id);
}
 
Example 7
Source Project: 365browser   Source File: LayoutManagerDocument.java    License: Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void changeTabs() {
    DocumentTabModelSelector selector =
            ChromeApplication.getDocumentTabModelSelector();
    TabModel tabModel = selector.getCurrentModel();
    int currentIndex = tabModel.index();
    if (mLastScroll == ScrollDirection.LEFT) {
        if (currentIndex < tabModel.getCount() - 1) {
            TabModelUtils.setIndex(tabModel, currentIndex + 1);
        }
    } else {
        if (currentIndex > 0) {
            TabModelUtils.setIndex(tabModel, currentIndex - 1);
        }
    }
}
 
Example 8
Source Project: 365browser   Source File: StaticLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void setStaticTab(final int id) {
    if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
        if (!mLayoutTabs[0].shouldStall()) setPostHideState();
        return;
    }
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model == null) return;

    updateCacheVisibleIdsAndPrimary(new LinkedList<Integer>(Arrays.asList(id)), id);

    if (mLayoutTabs == null || mLayoutTabs.length != 1) mLayoutTabs = new LayoutTab[1];
    mLayoutTabs[0] = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
    mLayoutTabs[0].setDrawDecoration(false);
    if (mLayoutTabs[0].shouldStall()) {
        setPreHideState();
        mHandler.postDelayed(mUnstallRunnable, HIDE_TIMEOUT_MS);
    } else {
        setPostHideState();
    }
    requestRender();
}
 
Example 9
Source Project: 365browser   Source File: SimpleAnimationLayout.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set up for the tab closing animation
 */
@Override
public void onTabClosing(long time, int id) {
    reset();

    // Make sure any currently running animations can't influence tab if we are reusing it.
    forceAnimationToFinish();

    // Create the {@link LayoutTab} for the tab before it is destroyed.
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model != null) {
        mClosedTab = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
        mClosedTab.setBorderAlpha(0.0f);
        mLayoutTabs = new LayoutTab[] {mClosedTab};
        updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    } else {
        mLayoutTabs = null;
        mClosedTab = null;
    }
    // Only close the id at the end when we are done querying the model.
    super.onTabClosing(time, id);
}
 
Example 10
@Override
protected IntentHandlerDelegate createIntentHandlerDelegate() {
    return new IntentHandlerDelegate() {
        @Override
        public void processWebSearchIntent(String query) {
        }

        @Override
        public void processUrlViewIntent(String url, String referer, String headers,
                TabOpenType tabOpenType, String externalAppId, int tabIdToBringToFront,
                boolean hasUserGesture, Intent intent) {
            Tab currentTab = getTabCreator(false).launchUrlFromExternalApp(
                    url, referer, headers, externalAppId, true, intent, mIntentHandlingTimeMs);

            // Close all existing tabs from the previous session.
            TabModel tabModel = getTabModelSelector().getModel(false);
            for (int i = tabModel.getCount() - 1; i >= 0; i--) {
                if (tabModel.getTabAt(i).equals(currentTab)) continue;
                tabModel.closeTab(tabModel.getTabAt(i), false, false, false);
            }
        }
    };
}
 
Example 11
Source Project: delion   Source File: ContextReporter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Stops reporting context. Called when the app goes to the background.
 */
public void disable() {
    reportUsageEndedIfNecessary();

    if (mSelectorTabObserver != null) {
        mSelectorTabObserver.destroy();
        mSelectorTabObserver = null;
    }
    if (mModelObserver != null) {
        for (TabModel model : mActivity.getTabModelSelector().getModels()) {
            model.removeObserver(mModelObserver);
        }
        mModelObserver = null;
    }
    if (mContextualSearchObserver != null && mActivity.getContextualSearchManager() != null) {
        mActivity.getContextualSearchManager().removeObserver(mContextualSearchObserver);
        mContextualSearchObserver = null;
    }
}
 
Example 12
Source Project: 365browser   Source File: LayoutManagerChrome.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void destroy() {
    super.destroy();
    if (mTabModelSelectorObserver != null) {
        getTabModelSelector().removeObserver(mTabModelSelectorObserver);
    }
    if (mTabModelObserver != null) {
        for (TabModel model : getTabModelSelector().getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    if (mTabSelectorTabObserver != null) mTabSelectorTabObserver.destroy();
    mOverviewModeObservers.clear();

    if (mOverviewLayout != null) {
        mOverviewLayout.destroy();
        mOverviewLayout = null;
    }
    mOverviewListLayout.destroy();
    mToolbarSwipeLayout.destroy();
}
 
Example 13
Source Project: 365browser   Source File: NewTabPage.java    License: Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private boolean switchToExistingTab(String url) {
    String matchPattern = CommandLine.getInstance().getSwitchValue(
            ChromeSwitches.NTP_SWITCH_TO_EXISTING_TAB);
    boolean matchByHost;
    if ("url".equals(matchPattern)) {
        matchByHost = false;
    } else if ("host".equals(matchPattern)) {
        matchByHost = true;
    } else {
        return false;
    }

    TabModel tabModel = mTabModelSelector.getModel(false);
    for (int i = tabModel.getCount() - 1; i >= 0; --i) {
        if (matchURLs(tabModel.getTabAt(i).getUrl(), url, matchByHost)) {
            TabModelUtils.setIndex(tabModel, i);
            return true;
        }
    }
    return false;
}
 
Example 14
Source Project: AndroidChromium   Source File: LayoutManagerChrome.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void destroy() {
    super.destroy();
    if (mTabModelSelectorObserver != null) {
        getTabModelSelector().removeObserver(mTabModelSelectorObserver);
    }
    if (mTabModelObserver != null) {
        for (TabModel model : getTabModelSelector().getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    if (mTabSelectorTabObserver != null) mTabSelectorTabObserver.destroy();
    mOverviewModeObservers.clear();

    if (mOverviewLayout != null) {
        mOverviewLayout.destroy();
        mOverviewLayout = null;
    }
    mOverviewListLayout.destroy();
    mToolbarSwipeLayout.destroy();
}
 
Example 15
Source Project: AndroidChromium   Source File: StaticLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void setStaticTab(final int id) {
    if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
        if (!mLayoutTabs[0].shouldStall()) setPostHideState();
        return;
    }
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model == null) return;
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    if (mLayoutTabs == null || mLayoutTabs.length != 1) mLayoutTabs = new LayoutTab[1];
    mLayoutTabs[0] = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
    mLayoutTabs[0].setDrawDecoration(false);
    if (mLayoutTabs[0].shouldStall()) {
        setPreHideState();
        mHandler.postDelayed(mUnstallRunnable, HIDE_TIMEOUT_MS);
    } else {
        setPostHideState();
    }
    requestRender();
}
 
Example 16
@Override
protected IntentHandlerDelegate createIntentHandlerDelegate() {
    return new IntentHandlerDelegate() {
        @Override
        public void processWebSearchIntent(String query) {
        }

        @Override
        public void processUrlViewIntent(String url, String referer, String headers,
                TabOpenType tabOpenType, String externalAppId, int tabIdToBringToFront,
                boolean hasUserGesture, Intent intent) {
            Tab currentTab = getTabCreator(false).launchUrlFromExternalApp(
                    url, referer, headers, externalAppId, true, intent, mIntentHandlingTimeMs);

            // Close all existing tabs from the previous session.
            TabModel tabModel = getTabModelSelector().getModel(false);
            for (int i = tabModel.getCount() - 1; i >= 0; i--) {
                if (tabModel.getTabAt(i).equals(currentTab)) continue;
                tabModel.closeTab(tabModel.getTabAt(i), false, false, false);
            }
        }
    };
}
 
Example 17
Source Project: AndroidChromium   Source File: StackViewAnimation.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The wrapper method responsible for delegating animation requests to the appropriate helper
 * method.
 * @param type       The type of animation to be created.  This is what determines which helper
 *                   method is called.
 * @param tabs       The tabs that make up the current stack.
 * @param container  The {@link ViewGroup} that {@link View}s can be added to/removed from.
 * @param model      The {@link TabModel} that this animation will influence.
 * @param focusIndex The index of the tab that is the focus of this animation.
 * @return           The resulting {@link Animator} that will animate the Android views.
 */
public Animator createAnimatorForType(OverviewAnimationType type, StackTab[] tabs,
        ViewGroup container, TabModel model, int focusIndex) {
    Animator animator = null;

    if (model != null) {
        switch (type) {
            case NEW_TAB_OPENED:
                animator = createNewTabOpenedAnimator(tabs, container, model, focusIndex);
                break;
            default:
                break;
        }
    }

    return animator;
}
 
Example 18
Source Project: AndroidChromium   Source File: SimpleAnimationLayout.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set up for the tab closing animation
 */
@Override
public void onTabClosing(long time, int id) {
    reset();

    // Make sure any currently running animations can't influence tab if we are reusing it.
    forceAnimationToFinish();

    // Create the {@link LayoutTab} for the tab before it is destroyed.
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model != null) {
        mClosedTab = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
        mClosedTab.setBorderAlpha(0.0f);
        mLayoutTabs = new LayoutTab[] {mClosedTab};
        updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    } else {
        mLayoutTabs = null;
        mClosedTab = null;
    }
    // Only close the id at the end when we are done querying the model.
    super.onTabClosing(time, id);
}
 
Example 19
Source Project: AndroidChromium   Source File: UmaSessionStats.java    License: Apache License 2.0 6 votes vote down vote up
private void recordPageLoadStats(Tab tab) {
    WebContents webContents = tab.getWebContents();
    boolean isDesktopUserAgent = webContents != null
            && webContents.getNavigationController().getUseDesktopUserAgent();
    nativeRecordPageLoaded(isDesktopUserAgent);
    if (mKeyboardConnected) {
        nativeRecordPageLoadedWithKeyboard();
    }

    // If the session has ended (i.e. chrome is in the background), escape early. Ideally we
    // could track this number as part of either the previous or next session but this isn't
    // possible since the TabSelector is needed to figure out the current number of open tabs.
    if (mTabModelSelector == null) return;

    TabModel regularModel = mTabModelSelector.getModel(false);
    nativeRecordTabCountPerLoad(getTabCountFromModel(regularModel));
}
 
Example 20
@Override
protected IntentHandlerDelegate createIntentHandlerDelegate() {
    return new IntentHandlerDelegate() {
        @Override
        public void processWebSearchIntent(String query) {
        }

        @Override
        public void processUrlViewIntent(String url, String referer, String headers,
                TabOpenType tabOpenType, String externalAppId, int tabIdToBringToFront,
                boolean hasUserGesture, Intent intent) {
            Tab currentTab = getTabCreator(false).launchUrlFromExternalApp(
                    url, referer, headers, externalAppId, true, intent, mIntentHandlingTimeMs);

            // Close all existing tabs from the previous session.
            TabModel tabModel = getTabModelSelector().getModel(false);
            for (int i = tabModel.getCount() - 1; i >= 0; i--) {
                if (tabModel.getTabAt(i).equals(currentTab)) continue;
                tabModel.closeTab(tabModel.getTabAt(i), false, false, false);
            }
        }
    };
}
 
Example 21
Source Project: 365browser   Source File: ChromeActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void createContextualSearchTab(String searchUrl) {
    Tab currentTab = getActivityTab();
    if (currentTab == null) return;

    TabCreator tabCreator = getTabCreator(currentTab.isIncognito());
    if (tabCreator == null) return;

    tabCreator.createNewTab(
            new LoadUrlParams(searchUrl, PageTransition.LINK),
            TabModel.TabLaunchType.FROM_LINK, getActivityTab());
}
 
Example 22
Source Project: delion   Source File: StripLayoutHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Called on onDown event.
 * @param time      The time stamp in millisecond of the event.
 * @param x         The x position of the event.
 * @param y         The y position of the event.
 * @param fromMouse Whether the event originates from a mouse.
 * @param buttons   State of all buttons that are pressed.
 */
public void onDown(long time, float x, float y, boolean fromMouse, int buttons) {
    resetResizeTimeout(false);

    if (mNewTabButton.onDown(x, y)) {
        mRenderHost.requestRender();
        return;
    }

    final StripLayoutTab clickedTab = getTabAtPosition(x);
    final int index = clickedTab != null
            ? TabModelUtils.getTabIndexById(mModel, clickedTab.getId())
            : TabModel.INVALID_TAB_INDEX;
    // http://crbug.com/472186 : Needs to handle a case that index is invalid.
    // The case could happen when the current tab is touched while we're inflating the rest of
    // the tabs from disk.
    mInteractingTab = index != TabModel.INVALID_TAB_INDEX && index < mStripTabs.length
            ? mStripTabs[index]
            : null;
    boolean clickedClose = clickedTab != null
                           && clickedTab.checkCloseHitTest(x, y);
    if (clickedClose) {
        clickedTab.setClosePressed(true);
        mLastPressedCloseButton = clickedTab.getCloseButton();
        mRenderHost.requestRender();
    }

    if (!mScroller.isFinished()) {
        mScroller.forceFinished(true);
        mInteractingTab = null;
    }

    if (fromMouse && !clickedClose && clickedTab != null
            && clickedTab.getVisiblePercentage() >= 1.f
            && (buttons & MotionEvent.BUTTON_TERTIARY) == 0) {
        startReorderMode(time, x, x);
    }
}
 
Example 23
Source Project: 365browser   Source File: StackViewAnimation.java    License: Apache License 2.0 5 votes vote down vote up
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
Example 24
Source Project: delion   Source File: ToolbarSwipeLayout.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void show(long time, boolean animate) {
    super.show(time, animate);
    init();
    if (mTabModelSelector == null) return;
    Tab tab = mTabModelSelector.getCurrentTab();
    if (tab != null && tab.isNativePage()) mTabContentManager.cacheTabThumbnail(tab);

    TabModel model = mTabModelSelector.getCurrentModel();
    if (model == null) return;
    int fromTabId = mTabModelSelector.getCurrentTabId();
    if (fromTabId == TabModel.INVALID_TAB_INDEX) return;
    mFromTab = createLayoutTab(fromTabId, model.isIncognito(), NO_CLOSE_BUTTON, NEED_TITLE);
    prepareLayoutTabForSwipe(mFromTab, false);
}
 
Example 25
Source Project: delion   Source File: Stack.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Animates a new tab opening.
 *
 * @param time The current time of the app in ms.
 * @param id The id of the new tab to animate.
 */
public void tabCreated(long time, int id) {
    if (!createTabHelper(id)) return;

    mIsDying = false;
    finishAnimation(time);
    startAnimation(time, OverviewAnimationType.NEW_TAB_OPENED,
            TabModelUtils.getTabIndexById(mTabModel, id), TabModel.INVALID_TAB_INDEX, false);
}
 
Example 26
Source Project: 365browser   Source File: Layout.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * To be called when the transition out of the view mode is done.
 * This is currently called by the renderer when all the animation are done while hiding.
 */
public void doneHiding() {
    mIsHiding = false;
    if (mNextTabId != Tab.INVALID_TAB_ID) {
        TabModel model = mTabModelSelector.getModelForTabId(mNextTabId);
        if (model != null) {
            TabModelUtils.setIndex(model, TabModelUtils.getTabIndexById(model, mNextTabId));
        }
        mNextTabId = Tab.INVALID_TAB_ID;
    }
    mUpdateHost.doneHiding();
    if (mRenderHost != null && mRenderHost.getResourceManager() != null) {
        mRenderHost.getResourceManager().clearTintedResourceCache();
    }
}
 
Example 27
Source Project: 365browser   Source File: ToolbarSwipeLayout.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void show(long time, boolean animate) {
    super.show(time, animate);
    init();
    if (mTabModelSelector == null) return;
    Tab tab = mTabModelSelector.getCurrentTab();
    if (tab != null && tab.isNativePage()) mTabContentManager.cacheTabThumbnail(tab);

    TabModel model = mTabModelSelector.getCurrentModel();
    if (model == null) return;
    int fromTabId = mTabModelSelector.getCurrentTabId();
    if (fromTabId == TabModel.INVALID_TAB_INDEX) return;
    mFromTab = createLayoutTab(fromTabId, model.isIncognito(), NO_CLOSE_BUTTON, NEED_TITLE);
    prepareLayoutTabForSwipe(mFromTab, false);
}
 
Example 28
Source Project: 365browser   Source File: FindToolbar.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the find toolbar. Should be called just after the find toolbar is shown.
 * If the toolbar is already showing, this just focuses the toolbar.
 */
public void activate() {
    if (!isViewAvailable()) return;
    if (mActive) {
        requestQueryFocus();
        return;
    }

    mTabModelSelector.addObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.addObserver(mTabModelObserver);
    }
    mCurrentTab = mTabModelSelector.getCurrentTab();
    mCurrentTab.addObserver(mTabObserver);
    mFindInPageBridge = new FindInPageBridge(mCurrentTab.getWebContents());
    mCurrentTab.getTabWebContentsDelegateAndroid().setFindResultListener(this);
    mCurrentTab.getTabWebContentsDelegateAndroid().setFindMatchRectsListener(this);
    initializeFindText();
    mFindQuery.requestFocus();
    // The keyboard doesn't show itself automatically.
    showKeyboard();
    // Always show the bar to make the FindToolbar more distinct from the Omnibox.
    setResultsBarVisibility(true);
    mActive = true;
    updateVisualsForTabModel(mTabModelSelector.isIncognitoSelected());

    // Let everyone know that we've just updated.
    if (mObserver != null) mObserver.onFindToolbarShown();
}
 
Example 29
Source Project: 365browser   Source File: ReaderModeManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Open a link from the panel in a new tab.
 * @param url The URL to load.
 */
@Override
public void createNewTab(String url) {
    if (mChromeActivity == null) return;

    Tab currentTab = mTabModelSelector.getCurrentTab();
    if (currentTab == null) return;

    TabCreatorManager.TabCreator tabCreator =
            mChromeActivity.getTabCreator(currentTab.isIncognito());
    if (tabCreator == null) return;

    tabCreator.createNewTab(new LoadUrlParams(url, PageTransition.LINK),
            TabModel.TabLaunchType.FROM_LINK, mChromeActivity.getActivityTab());
}
 
Example 30
Source Project: 365browser   Source File: CustomTabLayoutManager.java    License: 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);
}