// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module commerce.mojom;
import "ui/webui/resources/cr_components/commerce/shopping_service.mojom";
import "url/mojom/url.mojom";
// This contains the current state and the expected state of a feature.
struct EligibleEntry {
// The current state of the feature, enabled or disabled.
bool value;
// The expected state of the feature. This can be either enabled(true) or
// disabled(false);
bool expected_value;
};
// This outlines each factor that contributes to whether a user is eligible
// for the shopping-list feature.
struct ShoppingListEligibleDetail {
EligibleEntry is_region_locked_feature_enabled;
EligibleEntry is_shopping_list_allowed_for_enterprise;
EligibleEntry is_account_checker_valid;
EligibleEntry is_signed_in;
EligibleEntry is_syncing_bookmarks;
EligibleEntry is_anonymized_url_data_collection_enabled;
EligibleEntry is_subject_to_parental_controls;
};
// Used by the WebUI to bootstrap bidirectional communication.
interface CommerceInternalsHandlerFactory {
// The WebUI calls this method when the page is first initialized.
CreateCommerceInternalsHandler(
pending_remote<CommerceInternalsPage> page,
pending_receiver<CommerceInternalsHandler> handler);
};
struct Subscription {
uint64 cluster_id;
array<shopping_service.mojom.BookmarkProductInfo> product_infos;
};
// TODO(crbug.com/359684270) add more comments and investigate
// mojo_base.mojom.Time or mojo_base.mojom.JSTime for creation_time
// and update_time.
struct ProductSpecificationsSet {
string uuid;
string name;
string creation_time;
string update_time;
// Information about each item in the ProductSpecificationsSet
// such as URL and title.
array<shopping_service.mojom.UrlInfo> url_infos;
};
// Browser-side handler for requests from WebUI page.
interface CommerceInternalsHandler {
// Returns whether the user is eligible to use the shopping list feature.
GetIsShoppingListEligible() => (bool eligible);
// Returns the ShoppingListEligibleDetail.
GetShoppingListEligibleDetails() =>(ShoppingListEligibleDetail detail);
// Resets the user preference for receiving price tracking emails so that the
// default value is used (e.g. no value is stored). This helps test UI flows
// that depend on that preference not being set.
ResetPriceTrackingEmailPref();
// Returns the product info for the provided URL if it exists.
GetProductInfoForUrl(url.mojom.Url url) =>
(shopping_service.mojom.ProductInfo info);
// Returns the products the user has subscribed to.
GetSubscriptionDetails() =>
(array<Subscription> subscriptions);
// Return product specifications the user has synced.
GetProductSpecificationsDetails() =>
(array<ProductSpecificationsSet> product_specifications_set);
// Reset all statuses related to product specification feature. This includes
// removing all existing product specification sets of the current user.
ResetProductSpecifications();
};
// WebUI-side handler for requests from the browser.
interface CommerceInternalsPage {
// A notification that the eligibility status for the shopping list feature
// changed.
OnShoppingListEligibilityChanged(bool eligible);
};