1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
// 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_WEBUI_H_
#define COMPONENTS_USER_EDUCATION_WEBUI_HELP_BUBBLE_WEBUI_H_
#include <memory>
#include "components/user_education/common/help_bubble/help_bubble.h"
#include "components/user_education/common/help_bubble/help_bubble_factory.h"
#include "components/user_education/common/help_bubble/help_bubble_params.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/framework_specific_implementation.h"
namespace content {
class WebContents;
}
namespace user_education {
class HelpBubbleHandlerBase;
// This is a thin wrapper around HelpBubbleHandler that implements the
// HelpBubble interaface.
class HelpBubbleWebUI : public HelpBubble {
public:
~HelpBubbleWebUI() override;
// Retrieves the `WebContents` that hosts this help bubble, if any, or null if
// none. Will return null if the bubble is closed.
content::WebContents* GetWebContents();
// HelpBubble:
bool ToggleFocusForAccessibility() override;
gfx::Rect GetBoundsInScreen() const override;
ui::ElementContext GetContext() const override;
DECLARE_FRAMEWORK_SPECIFIC_METADATA()
private:
friend class HelpBubbleHandlerBase;
HelpBubbleWebUI(HelpBubbleHandlerBase* handler,
ui::ElementIdentifier anchor_id);
// HelpBubble:
void CloseBubbleImpl() override;
const raw_ptr<HelpBubbleHandlerBase> handler_;
const ui::ElementIdentifier anchor_id_;
};
// This factory uses HelpBubbleHandler to show a help bubble and create a
// HelpBubbleWebUI wrapper.
class HelpBubbleFactoryWebUI : public HelpBubbleFactory {
public:
HelpBubbleFactoryWebUI();
~HelpBubbleFactoryWebUI() override;
DECLARE_FRAMEWORK_SPECIFIC_METADATA()
// HelpBubbleFactory:
std::unique_ptr<HelpBubble> CreateBubble(ui::TrackedElement* element,
HelpBubbleParams params) override;
bool CanBuildBubbleForTrackedElement(
const ui::TrackedElement* element) const override;
};
} // namespace user_education
#endif // COMPONENTS_USER_EDUCATION_WEBUI_HELP_BUBBLE_WEBUI_H_
|