예제 #1
0
  private void onNativeLibraryReady() {
    mNativeLibraryReady = true;
    mToolbar.onNativeLibraryReady();

    final TemplateUrlService templateUrlService = TemplateUrlService.getInstance();
    TemplateUrlService.LoadListener mTemplateServiceLoadListener =
        new TemplateUrlService.LoadListener() {
          @Override
          public void onTemplateUrlServiceLoaded() {
            registerTemplateUrlObserver();
            templateUrlService.unregisterLoadListener(this);
          }
        };
    templateUrlService.registerLoadListener(mTemplateServiceLoadListener);
    if (templateUrlService.isLoaded()) {
      mTemplateServiceLoadListener.onTemplateUrlServiceLoaded();
    } else {
      templateUrlService.load();
    }

    mTabModelSelector.addObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) model.addObserver(mTabModelObserver);

    refreshSelectedTab();
    if (mTabModelSelector.isTabStateInitialized()) mTabRestoreCompleted = true;
    handleTabRestoreCompleted();
  }
  /**
   * 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.
   */
  public void onFinishNativeInitialization(
      TabModelSelector tabModelSelector,
      TabCreatorManager tabCreatorManager,
      TabContentManager tabContentManager,
      ViewGroup androidContentContainer,
      ContextualSearchManagementDelegate contextualSearchManager) {
    assert mLayoutManager != null;
    mLayoutManager.init(
        tabModelSelector,
        tabCreatorManager,
        tabContentManager,
        androidContentContainer,
        contextualSearchManager,
        mCompositorView.getResourceManager().getDynamicResourceLoader());
    mTabModelSelector = tabModelSelector;
    tabModelSelector.addObserver(
        new EmptyTabModelSelectorObserver() {
          @Override
          public void onChange() {
            onContentChanged();
          }

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

    onContentChanged();
  }