コード例 #1
0
 private boolean isStoredArticle(String url) {
   DomDistillerService domDistillerService =
       DomDistillerServiceFactory.getForProfile(Profile.getLastUsedProfile());
   String entryIdFromUrl = DomDistillerUrlUtils.getValueForKeyInUrl(url, "entry_id");
   if (TextUtils.isEmpty(entryIdFromUrl)) return false;
   return domDistillerService.hasEntry(entryIdFromUrl);
 }
コード例 #2
0
  @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();
    }
  }