// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. module chrome_cart.mojom; import "url/mojom/url.mojom"; // Information needed to show cart for one merchant in chrome cart module. struct MerchantCart { // Merchant that this cart comes from. string merchant; // URL that directs to the cart page. It is used to identify carts. url.mojom.Url cart_url; // List of URLs for product image to show in the cart. array product_image_urls; // Text content of the discount on this cart (e.g. 15% off). string discount_text; }; // The current status of the consent. This is used when user has acted on the // consent. UNSPECIFIED is the default state. enum ConsentStatus { ACCEPTED = 0, DISMISSED = 1, REJECTED = 2 }; // Browser-side handler for requests from JS. interface CartHandler { // Returns the merchant carts in chrome cart. GetMerchantCarts() => (array carts); // Temporarily hide the cart module. HideCartModule(); // Restores the cart module that has been temporarily hidden. RestoreHiddenCartModule(); // Hides the cart for certain domain // and returns if the operation is successful. HideCart(url.mojom.Url cart_url) => (bool success); // Restores hidden cart for certain domain // and returns if the operation is successful. RestoreHiddenCart(url.mojom.Url cart_url) => (bool success); // Removes the cart for certain domain // and returns if the operation is successful. RemoveCart(url.mojom.Url cart_url) => (bool success); // Restores removed cart for certain domain // and returns if the operation is successful. RestoreRemovedCart(url.mojom.Url cart_url) => (bool success); // Returns whether to show welcome surface in the module. GetWarmWelcomeVisible() => (bool welcome_visible); // Passes |cart_url| to browser process to fetch discount URL. GetDiscountURL(url.mojom.Url cart_url) => (url.mojom.Url discount_url); // Returns whether to show discount consent card in the module. GetDiscountConsentCardVisible() => (bool consent_visible); // Returns whether to show the discount toggle in the customize setting page. GetDiscountToggleVisible() => (bool toggle_visible); // TODO(crbug.com/1298116): Merge OnDiscountConsentAcknowledged and // OnDiscountConsentDismissed. // Stores in profile prefs that user has acknowledged // discount consent and whether user has opted-in or opted-out // the feature. OnDiscountConsentAcknowledged(bool accept); // Stores in profile prefs that user has dismissed the consent. OnDiscountConsentDismissed(); // Stores in profile prefs that user has shown interest in the // consent. OnDiscountConsentContinued(); // Shows the native consent dialog and returns the consent status. ShowNativeConsentDialog() => (ConsentStatus consent_status); // Returns whether the rule-based discount feature is enabled. GetDiscountEnabled() => (bool enabled); // Sets whether the rule-based discount feature is enabled. SetDiscountEnabled(bool enabled); // Passes the |cart_url| that user is navigating or about to navigate // towards to browser process, in order to help identify navigations // originated from cart module. |is_navigating| indicates whether // the navigation is happening now (e.g. left click on cart item) // or not. PrepareForNavigation(url.mojom.Url cart_url, bool is_navigating); };