chromium/chrome/browser/ui/webui/top_chrome/webui_contents_wrapper_service.h

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

#ifndef CHROME_BROWSER_UI_WEBUI_TOP_CHROME_WEBUI_CONTENTS_WRAPPER_SERVICE_H_
#define CHROME_BROWSER_UI_WEBUI_TOP_CHROME_WEBUI_CONTENTS_WRAPPER_SERVICE_H_

#include <memory>
#include <string>

#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/webui/top_chrome/webui_contents_wrapper.h"
#include "components/keyed_service/core/keyed_service.h"

class GURL;
class Profile;

// This service maintains a 1-to-1 mapping of WebUIContentsWrapper to WebUI URL
// hostname for a given profile. This allows multiple WebUI bubbles across
// profile windows to share the same WebUIContentsWrapper instance, minimizing
// the resource cost of persisting the wrapped WebContents. Persisting a
// WebContents is done to improve initialization delays for WebUI bubbles.
// A KeyedService is used to ensure any references to the Profile from the
// wrapped WebContents instances are removed before Profile destruction.
class WebUIContentsWrapperService : public KeyedService {};

#endif  // CHROME_BROWSER_UI_WEBUI_TOP_CHROME_WEBUI_CONTENTS_WRAPPER_SERVICE_H_