#ifndef CHROME_BROWSER_APPS_BROWSER_INSTANCE_BROWSER_APP_INSTANCE_TRACKER_H_
#define CHROME_BROWSER_APPS_BROWSER_INSTANCE_BROWSER_APP_INSTANCE_TRACKER_H_
#include <map>
#include <memory>
#include <set>
#include "base/check.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/scoped_multi_source_observation.h"
#include "base/unguessable_token.h"
#include "chrome/browser/apps/browser_instance/browser_app_instance.h"
#include "chrome/browser/apps/browser_instance/browser_app_instance_map.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/browser_tab_strip_tracker.h"
#include "chrome/browser/ui/browser_tab_strip_tracker_delegate.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "components/app_constants/constants.h"
#include "components/services/app_service/public/cpp/app_registry_cache.h"
#include "content/public/browser/web_contents.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "ui/wm/public/activation_change_observer.h"
#include "ui/wm/public/activation_client.h"
#endif
class Browser;
class Profile;
namespace aura {
class Window;
}
namespace apps {
class BrowserAppInstanceObserver;
class BrowserAppInstanceTracker : public TabStripModelObserver,
public BrowserTabStripTrackerDelegate,
public AppRegistryCache::Observer,
public BrowserListObserver { … };
#if BUILDFLAG(IS_CHROMEOS_LACROS)
class BrowserAppInstanceTrackerLacros : public BrowserAppInstanceTracker,
public wm::ActivationChangeObserver {
public:
BrowserAppInstanceTrackerLacros(Profile* profile,
AppRegistryCache& app_registry_cache);
~BrowserAppInstanceTrackerLacros() override;
BrowserAppInstanceTrackerLacros(const BrowserAppInstanceTrackerLacros&) =
delete;
BrowserAppInstanceTrackerLacros& operator=(
const BrowserAppInstanceTrackerLacros&) = delete;
void OnWindowActivated(ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;
private:
void MaybeUpdateBrowserWindowInstance(BrowserWindowInstance& instance,
Browser* browser);
void OnBrowserWindowUpdated(Browser* browser);
bool IsActivationClientTracked(wm::ActivationClient* client) const;
void OnBrowserFirstTabAttached(Browser* browser) override;
void OnBrowserLastTabDetached(Browser* browser) override;
base::ScopedMultiSourceObservation<wm::ActivationClient,
wm::ActivationChangeObserver>
activation_client_observations_{this};
};
#endif
}
#endif