Exemplo n.º 1
0
  private void updateSiteIdentity(Tab tab, EnumSet<UpdateFlags> flags) {
    final SiteIdentity siteIdentity;
    if (tab == null) {
      siteIdentity = null;
    } else {
      siteIdentity = tab.getSiteIdentity();
    }

    mSiteIdentityPopup.setSiteIdentity(siteIdentity);

    final SecurityMode securityMode;
    final MixedMode activeMixedMode;
    final MixedMode displayMixedMode;
    final TrackingMode trackingMode;
    if (siteIdentity == null) {
      securityMode = SecurityMode.UNKNOWN;
      activeMixedMode = MixedMode.UNKNOWN;
      displayMixedMode = MixedMode.UNKNOWN;
      trackingMode = TrackingMode.UNKNOWN;
    } else {
      securityMode = siteIdentity.getSecurityMode();
      activeMixedMode = siteIdentity.getMixedModeActive();
      displayMixedMode = siteIdentity.getMixedModeDisplay();
      trackingMode = siteIdentity.getTrackingMode();
    }

    // This is a bit tricky, but we have one icon and three potential indicators.
    // Default to the identity level
    int imageLevel = securityMode.ordinal();

    // Check to see if any protection was overridden first
    if (trackingMode == TrackingMode.TRACKING_CONTENT_LOADED) {
      imageLevel = LEVEL_SHIELD_DISABLED;
    } else if (trackingMode == TrackingMode.TRACKING_CONTENT_BLOCKED) {
      imageLevel = LEVEL_SHIELD_ENABLED;
    } else if (activeMixedMode == MixedMode.MIXED_CONTENT_LOADED) {
      imageLevel = LEVEL_LOCK_DISABLED;
    } else if (displayMixedMode == MixedMode.MIXED_CONTENT_LOADED) {
      imageLevel = LEVEL_WARNING_MINOR;
    }

    if (mSecurityImageLevel != imageLevel) {
      mSecurityImageLevel = imageLevel;
      mSiteSecurity.setImageLevel(mSecurityImageLevel);
      updatePageActions(flags);
    }

    mTrackingProtectionEnabled = trackingMode == TrackingMode.TRACKING_CONTENT_BLOCKED;
  }