// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_USER_EDUCATION_WEBUI_HELP_BUBBLE_HANDLER_H_ #define COMPONENTS_USER_EDUCATION_WEBUI_HELP_BUBBLE_HANDLER_H_ #include <map> #include <memory> #include <string_view> #include <vector> #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "components/user_education/common/help_bubble.h" #include "components/user_education/common/help_bubble_params.h" #include "components/user_education/webui/tracked_element_webui.h" #include "content/public/browser/web_ui_controller.h" #include "mojo/public/cpp/bindings/receiver.h" #include "ui/base/interaction/element_identifier.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/webui/resources/cr_components/help_bubble/help_bubble.mojom.h" namespace content { class WebContents; } // namespace content namespace user_education { class HelpBubbleWebUI; // Base class abstracting away IPC so that handler functionality can be tested // entirely with mocks. class HelpBubbleHandlerBase : public help_bubble::mojom::HelpBubbleHandler { … }; // Handler for WebUI that support displaying help bubbles in Polymer. // The corresponding mojom and mixin files to support help bubbles on the WebUI // side are located in the project at: // //ui/webui/resources/cr_components/help_bubble/ // // Full usage recommendations can be found in README.md. // // SECURITY NOTE: a `HelpBubbleHandler` is owned by a `WebUIController` that // implements `HelpBubbleHandlerFactory`, and typically has a lifespan limited // to a subset of the corresponding WebUI page's lifespan. Reloading the page // can cause it to be discarded and recreated (and a common attack vector is // triggering a recreate). If a class has a raw_ptr to a // HelpBubbleHandler[Base], then a test MUST be added to ensure that the class // releases the reference when the HelpBubbleHandler is destroyed. Tests are // already provided for `HelpBubbleWebUI` and `TrackedElementWebUI` in // help_bubble_handler_unittest.cc. class HelpBubbleHandler : public HelpBubbleHandlerBase { … }; } // namespace user_education #endif // COMPONENTS_USER_EDUCATION_WEBUI_HELP_BUBBLE_HANDLER_H_