#include "chrome/browser/extensions/api/tabs/windows_event_router.h"
#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/extensions/api/tabs/app_base_window.h"
#include "chrome/browser/extensions/api/tabs/app_window_controller.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/api/tabs/windows_util.h"
#include "chrome/browser/extensions/extension_browser_window.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/windows.h"
#include "chrome/common/extensions/extension_constants.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_util.h"
#include "extensions/common/constants.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "extensions/common/mojom/event_dispatcher.mojom.h"
BrowserContext;
namespace extensions {
windows;
namespace {
bool ControllerVisibleToListener(WindowController* window_controller,
const Extension* extension,
const base::Value::Dict* listener_filter) { … }
bool WillDispatchWindowEvent(
WindowController* window_controller,
BrowserContext* browser_context,
mojom::ContextType target_context,
const Extension* extension,
const base::Value::Dict* listener_filter,
std::optional<base::Value::List>& event_args_out,
mojom::EventFilteringInfoPtr& event_filtering_info_out) { … }
bool WillDispatchWindowFocusedEvent(
WindowController* window_controller,
BrowserContext* browser_context,
mojom::ContextType target_context,
const Extension* extension,
const base::Value::Dict* listener_filter,
std::optional<base::Value::List>& event_args_out,
mojom::EventFilteringInfoPtr& event_filtering_info_out) { … }
}
WindowsEventRouter::WindowsEventRouter(Profile* profile)
: … { … }
WindowsEventRouter::~WindowsEventRouter() { … }
void WindowsEventRouter::OnAppWindowAdded(extensions::AppWindow* app_window) { … }
void WindowsEventRouter::OnAppWindowRemoved(extensions::AppWindow* app_window) { … }
void WindowsEventRouter::OnAppWindowActivated(
extensions::AppWindow* app_window) { … }
void WindowsEventRouter::OnWindowControllerAdded(
WindowController* window_controller) { … }
void WindowsEventRouter::OnWindowControllerRemoved(
WindowController* window_controller) { … }
void WindowsEventRouter::OnWindowBoundsChanged(
WindowController* window_controller) { … }
#if defined(TOOLKIT_VIEWS) && !BUILDFLAG(IS_MAC)
void WindowsEventRouter::OnNativeFocusChanged(gfx::NativeView focused_now) { … }
#endif
#if BUILDFLAG(IS_MAC)
void WindowsEventRouter::OnNoKeyWindow() {
OnActiveWindowChanged(nullptr);
}
#endif
void WindowsEventRouter::OnActiveWindowChanged(
WindowController* window_controller) { … }
void WindowsEventRouter::DispatchEvent(events::HistogramValue histogram_value,
const std::string& event_name,
WindowController* window_controller,
base::Value::List args) { … }
bool WindowsEventRouter::HasEventListener(const std::string& event_name) { … }
void WindowsEventRouter::AddAppWindow(extensions::AppWindow* app_window) { … }
}