Пример #1
0
  @Override
  public void updateSecurityIcon(int securityLevel) {
    if (mSecurityIconType == securityLevel) return;
    mSecurityIconType = securityLevel;

    if (securityLevel == ConnectionSecurityLevel.NONE) {
      mAnimDelegate.hideSecurityButton();
    } else {
      // ImageView#setImageResource is no-op if given resource is the current one.
      mSecurityButton.setImageResource(
          LocationBarLayout.getSecurityIconResource(securityLevel, !shouldEmphasizeHttpsScheme()));
      mAnimDelegate.showSecurityButton();
    }
    mUrlBar.emphasizeUrl();
    mUrlBar.invalidate();
  }
  @Override
  public void updateSecurityIcon(int securityLevel) {
    // ImageView#setImageResource is no-op if given resource is the current one.
    mSecurityButton.setImageResource(
        LocationBarLayout.getSecurityIconResource(securityLevel, !shouldEmphasizeHttpsScheme()));

    if (mSecurityIconType == securityLevel) return;
    mSecurityIconType = securityLevel;

    if (securityLevel == ConnectionSecurityLevel.NONE) {
      // TODO(yusufo): Add an animator for hiding as well.
      mSecurityButton.setVisibility(GONE);
    } else if (mSecurityButton.getVisibility() != View.VISIBLE) {
      if (mSecurityButtonShowAnimator.isRunning()) mSecurityButtonShowAnimator.cancel();
      mSecurityButtonShowAnimator.start();
      mUrlBar.deEmphasizeUrl();
    }
    mUrlBar.emphasizeUrl();
    mUrlBar.invalidate();
  }
  @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();
    }
  }