2
2
ze,useShadow}from"chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js";i
mport"chrome://new-tab-
page/strings.m.js";import{loadTimeData}from"chrome://resources/js/load_time_data.m.
js";import"chrome://resources/mojo/skia/public/mojom/skcolor.mojom-
webui.js";import"chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js";impo
rt"chrome://resources/mojo/mojo/public/mojom/base/big_buffer.mojom-
lite.js";import"chrome://resources/mojo/mojo/public/mojom/base/string16.mojom-
lite.js";import"chrome://resources/mojo/mojo/public/mojom/base/time.mojom-
lite.js";import"chrome://resources/mojo/skia/public/mojom/skcolor.mojom-
lite.js";import"chrome://resources/mojo/url/mojom/url.mojom-
lite.js";import"chrome://new-tab-page/realbox/realbox.mojom-
lite.js";import{isIOS,isWindows,isMac}from"chrome://resources/js/cr.m.js";import"ch
rome://resources/mojo/mojo/public/mojom/base/text_direction.mojom-
lite.js";import"chrome://resources/cr_components/most_visited/most_visited.mojom-
lite.js";import"chrome://new-tab-page/new_tab_page.mojom-
lite.js";import"chrome://new-tab-page/modules/cart/chrome_cart.mojom-
lite.js";import"chrome://new-tab-page/modules/drive/drive.mojom-
lite.js";import"chrome://new-tab-page/modules/task_module/task_module.mojom-
lite.js";import{CommandHandlerRemote,CommandHandlerFactory}from"chrome://new-tab-
page/promo_browser_command.mojom-webui.js";// Copyright (c) 2013 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.
function assert(condition,opt_message){if(!condition){let message="Assertion
failed";if(opt_message){message=message+": "+opt_message}const error=new
Error(message);const global=function(){const thisOrSelf=this||
self;thisOrSelf.traceAssertionsForTesting;return thisOrSelf}
();if(global.traceAssertionsForTesting){console.warn(error.stack)}throw
error}return condition}function assertNotReached(opt_message)
{assert(false,opt_message||"Unreachable code hit")}function
assertInstanceof(value,type,opt_message){if(!(value instanceof type))
{assertNotReached(opt_message||"Value "+value+" is not a[n] "+(type.name||typeof
type))}return value}// Copyright 2020 The Chromium Authors. All rights reserved.
function createScrollBorders(container,topBorder,bottomBorder,showAttribute){const
topProbe=document.createElement("div");container.prepend(topProbe);const
bottomProbe=document.createElement("div");container.append(bottomProbe);const
observer=new
IntersectionObserver((entries=>{entries.forEach((({target:target,intersectionRatio:
intersectionRatio})=>{const show=intersectionRatio===0;if(target===topProbe)
{topBorder.toggleAttribute(showAttribute,show)}else if(target===bottomProbe)
{bottomBorder.toggleAttribute(showAttribute,show)}}))}),
{root:container});observer.observe(topProbe);observer.observe(bottomProbe);return
observer}function decodeString16(str){return str?
str.data.map((ch=>String.fromCodePoint(ch))).join(""):""}function mojoString16(str)
{const array=new Array(str.length);for(let i=0;i<str.length;++i)
{array[i]=str.charCodeAt(i)}return{data:array}}function mojoTimeDelta(timeDelta)
{return{microseconds:BigInt(Math.floor(timeDelta*1e3))}}function $$
(element,selector){return element.shadowRoot.querySelector(selector)}function
strictQuery(root,selector,type){const
element=root.querySelector(selector);assert(element&&element instanceof
type);return element}// Copyright 2021 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.
let instance=null;class WindowProxy{static getInstance(){return instance||
(instance=new WindowProxy)}static setInstance(newInstance)
{instance=newInstance}navigate(href){window.location.href=href}open(url)
{window.open(url,"_blank")}setTimeout(callback,duration){return
window.setTimeout(callback,duration)}clearTimeout(id)
{window.clearTimeout(id)}random(){return Math.random()}createIframeSrc(src){return
src}matchMedia(query){return window.matchMedia(query)}now(){return
Date.now()}waitForLazyRender(){return new
Promise(((resolve,reject)=>{requestIdleCallback(resolve,
{timeout:500})}))}postMessage(iframe,message,targetOrigin)
{iframe.contentWindow.postMessage(message,targetOrigin)}}// Copyright 2020 The
Chromium Authors. All rights reserved.
/**
* @fileoverview Wrapper around <iframe> element that lets us mock out loading
* and postMessaging in tests.
*/class IframeElement extends PolymerElement{static get is(){return"ntp-
iframe"}static get template(){return html`<!--css-build:shadow--><!--
_html_template_start_--><style scope="ntp-iframe">:host(:not([hidden])) {
display: block;
}
#iframe {
border: none;
border-radius: inherit;
height: inherit;
max-height: inherit;
max-width: inherit;
width: inherit;
}
@media (prefers-color-scheme: dark) {
:host {
--cr-toggle-checked-bar-color: var(--google-blue-refresh-300);
--cr-toggle-checked-button-color: var(--google-blue-refresh-300);
--cr-toggle-checked-ripple-color:
rgba(var(--google-blue-refresh-300-rgb), .4);
--cr-toggle-unchecked-bar-color: var(--google-grey-refresh-500);
--cr-toggle-unchecked-button-color: var(--google-grey-refresh-300);
--cr-toggle-unchecked-ripple-color:
rgba(var(--google-grey-refresh-300-rgb), .4);
}
:host([dark]) {
--cr-toggle-checked-bar-color: var(--google-blue-refresh-300);
--cr-toggle-checked-button-color: var(--google-blue-refresh-300);
--cr-toggle-checked-ripple-color:
rgba(var(--google-blue-refresh-300-rgb), .4);
--cr-toggle-unchecked-bar-color: var(--google-grey-refresh-500);
--cr-toggle-unchecked-button-color: var(--google-grey-refresh-300);
--cr-toggle-uw