@Override
 public Tab getTabById(int id) {
   for (int i = 0; i < getModels().size(); i++) {
     Tab tab = TabModelUtils.getTabById(getModelAt(i), id);
     if (tab != null) return tab;
   }
   return null;
 }
 @Override
 public TabModel getModelForTabId(int id) {
   for (int i = 0; i < mTabModels.size(); i++) {
     TabModel model = mTabModels.get(i);
     if (TabModelUtils.getTabById(model, id) != null || model.isClosurePending(id)) {
       return model;
     }
   }
   return null;
 }
  @Override
  public void selectModel(boolean incognito) {
    TabModel oldModel = getCurrentModel();
    super.selectModel(incognito);
    TabModel newModel = getCurrentModel();
    if (oldModel != newModel) {
      TabModelUtils.setIndex(newModel, newModel.index());

      // Make the call to notifyDataSetChanged() after any delayed events
      // have had a chance to fire. Otherwise, this may result in some
      // drawing to occur before animations have a chance to work.
      new Handler()
          .post(
              new Runnable() {
                @Override
                public void run() {
                  notifyChanged();
                }
              });
    }
  }
  @Override
  public ChromeTab createTabWithWebContents(
      WebContents webContents, int parentId, TabLaunchType type, String url) {
    TabModel model = mTabModel;

    // The parent tab was already closed.  Do not open child tabs.
    if (model.isClosurePending(parentId)) return null;

    int index = TabModelUtils.getTabIndexById(model, parentId);

    // If we have a valid parent index increment by one so we add this tab directly after
    // the parent tab.
    if (index >= 0) index++;

    boolean selectTab = mOrderController.willOpenInForeground(type, mIncognito);
    ChromeTab tab =
        ChromeTab.createLiveTab(
            Tab.INVALID_TAB_ID, mActivity, mIncognito, mNativeWindow, type, parentId, !selectTab);
    tab.initialize(webContents, mTabContentManager, !selectTab);
    model.addTab(tab, index, type);
    return tab;
  }
 @Override
 public Tab getCurrentTab() {
   return getCurrentModel() == null ? null : TabModelUtils.getCurrentTab(getCurrentModel());
 }