chromium/chrome/browser/ui/user_education/show_promo_in_page.h

// 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 CHROME_BROWSER_UI_USER_EDUCATION_SHOW_PROMO_IN_PAGE_H_
#define CHROME_BROWSER_UI_USER_EDUCATION_SHOW_PROMO_IN_PAGE_H_

#include <optional>
#include <string>

#include "base/callback_list.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "components/user_education/common/help_bubble_params.h"
#include "ui/base/interaction/element_identifier.h"
#include "url/gurl.h"

namespace user_education {
class HelpBubble;
}  // namespace user_education

class Browser;

// Utility for opening a page (optionally) and showing a help bubble on a
// predetermined element. The object exists only as long as the operation
// is in progress or the help bubble is visible. If a `target_url` is
// defined in the parameters, this page will be opened. If `target_url`
// is omitted, the current page will be used to look for the anchor.
//
// Example:
//
//    // Open security settings page and show a help bubble promoting the
//    // "Enhanced Protection" user setting.
//    ShowPromoInPage::Params params;
//
//    // This WebUI page must be instrumented for help bubbles; see
//    // components/user_education/webui/README.md
//    params.target_url = "chrome://settings/security";
//
//    // This specifies what will be shown in the help bubble and how and where
//    // it will be positioned.
//    params.bubble_anchor_id = kEnhancedSecuritySettingElementId;
//    params.bubble_arrow = user_education::HelpBubbleArrow::kBottomLeft;
//    params.bubble_text =
//        l10n_util::GetStringUTF16(IDS_ENABLE_ENHANCED_PROTECTION_PROMO);
//
//    // Log whenever a user actually sees the promo.
//    params.callback = base::BindOnce(&::MaybeLogEnhancedSecurityPromoShown);
//
//    // Shows the page and the bubble. Because we did not specify
//    // |params.overwrite_active_tab|, the settings page will be opened in a
//    // new tab in |browser_| rather than the current tab.
//    ShowPromoInPage::Start(browser_, std::move(params));
//
class ShowPromoInPage {};

#endif  // CHROME_BROWSER_UI_USER_EDUCATION_SHOW_PROMO_IN_PAGE_H_