chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party.mojom

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module new_tab_page_third_party.mojom;

import "skia/public/mojom/skcolor.mojom";
import "ui/webui/resources/cr_components/most_visited/most_visited.mojom";

// A generic theme.
struct Theme {
  skia.mojom.SkColor text_color;
  // True if the theme is dark (e.g. NTP background color is dark).
  bool is_dark;
  // Used to show the theme extension background if one is set.
  string id;
  // Theme color ready to be set in CSS.
  string color_background;
  // The theme extension can set image tiling. This is ready to be set in CSS.
  string background_tiling;
  // Position CSS of background image.
  string background_position;
  // True if custom background is set.
  bool has_custom_background;

  // Theme settings for the NTP MV tiles.
  most_visited.mojom.MostVisitedTheme most_visited;
};

// Used by the WebUI page to bootstrap bidirectional communication.
interface PageHandlerFactory {
  // The WebUI page's |BrowserProxy| singleton calls this method when the page
  // is first initialized.
  CreatePageHandler(pending_remote<Page> page,
                    pending_receiver<PageHandler> handler);
};

// Browser-side handler for requests from WebUI page.
interface PageHandler {
  // Called to update the theme.
  UpdateTheme();
};

// WebUI-side handler for requests from the browser.
interface Page {
  // Sets the current theme.
  SetTheme(Theme theme);
};