#include "chrome/browser/ui/commerce/product_specifications_entry_point_controller.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/commerce/shopping_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/views/commerce/product_specifications_button.h"
#include "chrome/browser/ui/webui/commerce/product_specifications_disclosure_dialog.h"
#include "components/commerce/core/commerce_constants.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/commerce_types.h"
#include "components/commerce/core/commerce_utils.h"
#include "components/commerce/core/feature_utils.h"
#include "components/commerce/core/pref_names.h"
#include "components/commerce/core/shopping_service.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/webui/resources/cr_components/commerce/shopping_service.mojom.h"
namespace {
constexpr int kEligibleWindowUrlCountForValidation = …;
constexpr int kEligibleWindowUrlCountForNavigationTriggering = …;
constexpr int kEntryPointTitleMaxLength = …;
bool CheckWindowContainsEntryPointURLs(
TabStripModel* tab_strip_model,
commerce::EntryPointInfo entry_point_info,
size_t threshold) { … }
bool IsWindowValidForEntryPoint(TabStripModel* tab_strip_model,
commerce::EntryPointInfo entry_point_info) { … }
bool IsNavigationEligibleForEntryPoint(
TabStripModel* tab_strip_model,
commerce::EntryPointInfo entry_point_info) { … }
}
namespace commerce {
ProductSpecificationsEntryPointController::
ProductSpecificationsEntryPointController(Browser* browser)
: … { … }
ProductSpecificationsEntryPointController::
~ProductSpecificationsEntryPointController() = default;
void ProductSpecificationsEntryPointController::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) { … }
void ProductSpecificationsEntryPointController::TabChangedAt(
content::WebContents* contents,
int index,
TabChangeType change_type) { … }
void ProductSpecificationsEntryPointController::AddObserver(
Observer* observer) { … }
void ProductSpecificationsEntryPointController::RemoveObserver(
Observer* observer) { … }
void ProductSpecificationsEntryPointController::OnEntryPointExecuted() { … }
void ProductSpecificationsEntryPointController::OnEntryPointDismissed() { … }
void ProductSpecificationsEntryPointController::OnEntryPointHidden() { … }
bool ProductSpecificationsEntryPointController::ShouldExecuteEntryPointShow() { … }
void ProductSpecificationsEntryPointController::OnClusterFinishedForNavigation(
const GURL& url) { … }
void ProductSpecificationsEntryPointController::CheckEntryPointInfoForSelection(
const GURL old_url,
const GURL new_url,
std::optional<EntryPointInfo> entry_point_info) { … }
void ProductSpecificationsEntryPointController::
ShowEntryPointWithTitleForSelection(
const GURL old_url,
const GURL new_url,
std::optional<EntryPointInfo> entry_point_info) { … }
void ProductSpecificationsEntryPointController::
CheckEntryPointInfoForNavigation(
std::optional<EntryPointInfo> entry_point_info) { … }
void ProductSpecificationsEntryPointController::
ShowEntryPointWithTitleForNavigation(
std::optional<EntryPointInfo> entry_point_info) { … }
void ProductSpecificationsEntryPointController::ShowEntryPointWithTitle(
std::optional<EntryPointInfo> entry_point_info) { … }
void ProductSpecificationsEntryPointController::MaybeHideEntryPoint() { … }
}