Disable “chrome is out of date” notification

前端 未结 6 444
天涯浪人
天涯浪人 2021-01-31 20:16

I have a touchscreen application optimised and running in a Chrome kiosk mode. It runs totally offline and due to some updates to Chrome breaking the application I\'ve had to lo

6条回答
  •  悲哀的现实
    2021-01-31 20:50

    You may want to try editing sources: https://chromium.googlesource.com/chromium/src.git/+/lkcr/chrome/browser/ui/views/outdated_upgrade_bubble_view.cc (or just read them to get the logic of the notification)

    // static
    void OutdatedUpgradeBubbleView::ShowBubble
    

    Don't show notification bubble if there is already bubble shown:

    // The currently showing bubble.
    OutdatedUpgradeBubbleView* g_upgrade_bubble = nullptr;
    ...
      if (g_upgrade_bubble)
        return;
    

    The widget is not available on some OS (desktop Chrome OS based on linux) and available on Windows, MacOSX and non-ChromeOS Linux:

    bool OutdatedUpgradeBubbleView::IsAvailable() {
    // This should only work on non-Chrome OS desktop platforms.
    #if defined(OS_WIN) || defined(OS_MACOSX) || \
        (defined(OS_LINUX) && !defined(OS_CHROMEOS))
      return true;
    #else
      return false;
    #endif
    

    They have maximum count for bubble ignores, but this is used only in telemetry (metrics), not to disable bubble:

    // The maximum number of ignored bubble we track in the NumLaterPerReinstall
    // histogram.
    const int kMaxIgnored = 50;
    

    And https://chromium.googlesource.com/chromium/src.git/+/lkcr/chrome/browser/ui/views/outdated_upgrade_bubble_view.h file

    // OutdatedUpgradeBubbleView warns the user that an upgrade is long overdue.
    // It is intended to be used as the content of a bubble anchored off of the
    // Chrome toolbar. Don't create an OutdatedUpgradeBubbleView directly,
    // instead use the static ShowBubble method.
    

    Easiest edit is to set g_upgrade_bubble to non-zero value. Either with code editing or with runtime memory editing with debugger or possibly, game trainer like Cheat Engine or smth or with "chrome.dll" patching.

    The bubble is started from src/chrome/browser/ui/views/toolbar/toolbar_view.cc https://cs.chromium.org/chromium/src/chrome/browser/ui/views/toolbar/toolbar_view.cc?q=OutdatedUpgradeBubbleView

      if (OutdatedUpgradeBubbleView::IsAvailable()) {
        registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL,
                       content::NotificationService::AllSources());
        registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU,
                       content::NotificationService::AllSources());
    
    void ToolbarView::Observe(...
      switch (type) {
        case chrome::NOTIFICATION_OUTDATED_INSTALL:
          ShowOutdatedInstallNotification(true);
          break;
        case chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU:
          ShowOutdatedInstallNotification(false);
          break;
    
    void ToolbarView::ShowOutdatedInstallNotification(bool auto_update_enabled) {
      if (OutdatedUpgradeBubbleView::IsAvailable()) {
        OutdatedUpgradeBubbleView::ShowBubble(app_menu_button_, browser_,
                                              auto_update_enabled);
      }
    }
    

    Triggered by src/chrome/browser/upgrade_detector.cc with "NOTIFICATION_OUTDATED_INSTALL" https://cs.chromium.org/chromium/src/chrome/browser/upgrade_detector.cc?q=NOTIFICATION_OUTDATED_INSTALL&sq=package:chromium&dr=C

    void UpgradeDetector::NotifyUpgradeRecommended() {
      notify_upgrade_ = true;
    
      TriggerNotification(chrome::NOTIFICATION_UPGRADE_RECOMMENDED);
      if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL) {
        TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL);
      } else if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU) {
        TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU);
      } else if (upgrade_available_ == UPGRADE_AVAILABLE_CRITICAL ||
                 critical_experiment_updates_available_) {
        TriggerCriticalUpdate();
      }
    }
    

    called from void UpgradeDetectorImpl::NotifyOnUpgradeWithTimePassed https://cs.chromium.org/chromium/src/chrome/browser/upgrade_detector_impl.cc?rcl=0&l=455

        const base::TimeDelta multiplier = IsTesting() ?
            base::TimeDelta::FromSeconds(10) : base::TimeDelta::FromDays(1);
    
        // 14 days when not testing, otherwise 140 seconds.
        const base::TimeDelta severe_threshold = 14 * multiplier;
        const base::TimeDelta high_threshold = 7 * multiplier;
        const base::TimeDelta elevated_threshold = 4 * multiplier;
        const base::TimeDelta low_threshold = 2 * multiplier;
    
        // These if statements must be sorted (highest interval first).
        if (time_passed >= severe_threshold || is_critical_or_outdated) {
          set_upgrade_notification_stage(
              is_critical_or_outdated ? UPGRADE_ANNOYANCE_CRITICAL :
                                        UPGRADE_ANNOYANCE_SEVERE);
    
          // We can't get any higher, baby.
          upgrade_notification_timer_.Stop();
        } else if (time_passed >= high_threshold) {
          set_upgrade_notification_stage(UPGRADE_ANNOYANCE_HIGH);
        } else if (time_passed >= elevated_threshold) {
          set_upgrade_notification_stage(UPGRADE_ANNOYANCE_ELEVATED);
        } else if (time_passed >= low_threshold) {
          set_upgrade_notification_stage(UPGRADE_ANNOYANCE_LOW);
        } else {
          return;  // Not ready to recommend upgrade.
        }
      }
    
      NotifyUpgradeRecommended();
    

提交回复
热议问题