// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_FAVICON_MODEL_FAVICON_BROWSER_AGENT_H_
#define IOS_CHROME_BROWSER_FAVICON_MODEL_FAVICON_BROWSER_AGENT_H_

#include "base/memory/raw_ptr.h"
#include "ios/chrome/browser/shared/model/browser/browser_user_data.h"
#include "ios/chrome/browser/tabs/model/tabs_dependency_installer.h"

// A BrowserAgent that prepares WebStates to fetch their favicon after
// a session restoration.
class FaviconBrowserAgent final : public BrowserUserData<FaviconBrowserAgent>,
                                  public TabsDependencyInstaller {
 public:
  ~FaviconBrowserAgent() final;

  // TabsDependencyInstaller implementation.
  void OnWebStateInserted(web::WebState* web_state) final;
  void OnWebStateRemoved(web::WebState* web_state) final;
  void OnWebStateDeleted(web::WebState* web_state) final;
  void OnActiveWebStateChanged(web::WebState* old_active,
                               web::WebState* new_active) final;

 private:
  friend class BrowserUserData<FaviconBrowserAgent>;

  explicit FaviconBrowserAgent(Browser* browser);
};

#endif  // IOS_CHROME_BROWSER_FAVICON_MODEL_FAVICON_BROWSER_AGENT_H_
