예제 #1
0
 private void updateLoadProgress(int progress) {
   mLoadProgressSimulator.cancel();
   progress = Math.max(progress, MINIMUM_LOAD_PROGRESS);
   Tab tab = mToolbarModel.getTab();
   if (tab != null && NativePageFactory.isNativePageUrl(tab.getUrl(), tab.isIncognito())) {
     progress = 0;
   }
   updateLoadProgressInternal(progress);
   if (progress == 100 || progress == 0) {
     updateButtonStatus();
   } else {
     // Update the reload state regardless or whether or not the progress is 100.
     updateReloadState(false);
   }
 }
  @Override
  public void setUrlToPageUrl() {
    if (getCurrentTab() == null) {
      mUrlBar.setUrl("", null);
      return;
    }

    String url = getCurrentTab().getUrl().trim();

    if (NativePageFactory.isNativePageUrl(url, getCurrentTab().isIncognito())) {
      // Don't show anything for Chrome URLs.
      mUrlBar.setUrl("", null);
      return;
    }
    String displayText = getToolbarDataProvider().getText();
    Pair<String, String> urlText = LocationBarLayout.splitPathFromUrlDisplayText(displayText);
    displayText = urlText.first;

    if (DomDistillerUrlUtils.isDistilledPage(url)) {
      if (isStoredArticle(url)) {
        Profile profile = getCurrentTab().getProfile();
        DomDistillerService domDistillerService = DomDistillerServiceFactory.getForProfile(profile);
        String originalUrl =
            domDistillerService.getUrlForEntry(
                DomDistillerUrlUtils.getValueForKeyInUrl(url, "entry_id"));
        displayText = DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl);
      } else if (DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url) != null) {
        String originalUrl = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
        displayText = DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl);
      }
    }

    if (mUrlBar.setUrl(url, displayText)) {
      mUrlBar.deEmphasizeUrl();
      mUrlBar.emphasizeUrl();
    }
  }