Commit 7e2f030d authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

Add empty Chrome Kaleidoscope NTP module

Adds empty Chrome Kaleidoscope NTP module as
a placeholder.

BUG=1114862

Change-Id: Iee00259b9848394ead7d6b80cb1d311f07a5abcd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347909
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796969}
parent 8d2c055e
......@@ -236,6 +236,7 @@ js_library("modules") {
deps = [
":module_registry",
"modules/dummy:module",
"modules/kaleidoscope:module",
]
}
......@@ -272,6 +273,7 @@ group("web_components") {
public_deps = [
":web_components_local",
"modules/dummy:web_components",
"modules/kaleidoscope:web_components",
]
}
......
# 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.
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/polymer/html_to_js.gni")
js_library("module") {
deps = [
"../..:grid",
"../..:module_descriptor",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
html_to_js("web_components") {
js_files = [ "module.js" ]
}
file://chrome/browser/media/kaleidoscope/OWNERS
# COMPONENT: Internals>Media>UI>Kaleidoscope
<style>
.tile-item {
background-color: var(--ntp-active-background-color);
border-color: var(--ntp-border-color);
border-radius: 8px;
border-style: solid;
border-width: thin;
color: var(--cr-primary-text-color);
height: 85px;
line-height: 85px;
margin: 10px;
text-align: center;
width: 170px;
}
</style>
<ntp-grid id="tiles" columns="4">
<template id="tileList" is="dom-repeat" items="[[tiles]]">
<div class="tile-item" title="[[item.label]]">[[item.value]]</div>
</template>
</ntp-grid>
// 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.
import '../../grid.js';
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {ModuleDescriptor} from '../module_descriptor.js';
/**
* @fileoverview The Kaleidoscope module which will serve Kaleidoscope
* recommendations to the user through the NTP.
*/
class KaleidoscopeModuleElement extends PolymerElement {
static get is() {
return 'ntp-kaleidoscope-module';
}
static get template() {
return html`{__html_template__}`;
}
static get properties() {
return {
tiles: {
type: Array,
value: () => ([
{label: 'item1', value: 'foo'},
{label: 'item2', value: 'bar'},
{label: 'item3', value: 'baz'},
{label: 'item4', value: 'boo'},
]),
}
};
}
}
customElements.define(KaleidoscopeModuleElement.is, KaleidoscopeModuleElement);
/** @type {!ModuleDescriptor} */
export const kaleidoscopeDescriptor = {
id: 'kaleidoscope',
create: () => Promise.resolve(new KaleidoscopeModuleElement()),
};
......@@ -6,8 +6,16 @@
* @fileoverview Registers all NTP modules given their respective descriptors.
*/
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {dummyDescriptor} from './dummy/module.js';
import {kaleidoscopeDescriptor} from './kaleidoscope/module.js';
import {ModuleRegistry} from './module_registry.js';
const descriptors = [dummyDescriptor];
if (loadTimeData.getBoolean('kaleidoscopeModuleEnabled')) {
descriptors.push(kaleidoscopeDescriptor);
}
/** @type {!ModuleRegistry} */
export const registry = new ModuleRegistry([dummyDescriptor]);
export const registry = new ModuleRegistry(descriptors);
......@@ -3,4 +3,7 @@
<include name="IDR_NEW_TAB_PAGE_MODULES_DUMMY_MODULE_JS"
file="${root_gen_dir}/chrome/browser/resources/new_tab_page/modules/dummy/module.js"
use_base_dir="false" type="BINDATA" compress="false" />
<include name="IDR_NEW_TAB_PAGE_MODULES_KALEIDOSCOPE_MODULE_JS"
file="${root_gen_dir}/chrome/browser/resources/new_tab_page/modules/kaleidoscope/module.js"
use_base_dir="false" type="BINDATA" compress="false" />
</grit-part>
......@@ -16,6 +16,7 @@ export {BackgroundManager} from './background_manager.js';
export {BrowserProxy} from './browser_proxy.js';
export {BackgroundSelectionType} from './customize_dialog.js';
export {dummyDescriptor} from './modules/dummy/module.js';
export {kaleidoscopeDescriptor} from './modules/kaleidoscope/module.js';
export {ModuleRegistry} from './modules/module_registry.js';
export {PromoBrowserCommandProxy} from './promo_browser_command_proxy.js';
export {$$, createScrollBorders, decodeString16, hexColorToSkColor, mojoString16, skColorToRgba} from './utils.js';
......@@ -31,6 +31,7 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui_data_source.h"
#include "media/base/media_switches.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -86,6 +87,8 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
base::FeatureList::IsEnabled(ntp_features::kWebUIThemeModeDoodles));
source->AddBoolean("modulesEnabled",
base::FeatureList::IsEnabled(ntp_features::kModules));
source->AddBoolean("kaleidoscopeModuleEnabled",
base::FeatureList::IsEnabled(media::kKaleidoscopeModule));
static constexpr webui::LocalizedString kStrings[] = {
{"doneButton", IDS_DONE},
......
file://chrome/browser/media/kaleidoscope/OWNERS
# COMPONENT: Internals>Media>UI>Kaleidoscope
// 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.
import {$$, kaleidoscopeDescriptor} from 'chrome://new-tab-page/new_tab_page.js';
import {isVisible} from 'chrome://test/test_util.m.js';
suite('NewTabPageModulesKaleidoscopeModuleTest', () => {
test('creates module', async () => {
// Act.
const module = await kaleidoscopeDescriptor.create();
document.body.append(module);
module.$.tileList.render();
// Assert.
assertTrue(isVisible(module.$.tiles));
const tiles = module.shadowRoot.querySelectorAll('#tiles .tile-item');
assertEquals(4, tiles.length);
assertEquals('item3', tiles[2].getAttribute('title'));
assertEquals('baz', tiles[2].textContent);
});
});
......@@ -220,3 +220,15 @@ var NewTabPageModulesDummyModuleTest = class extends NewTabPageBrowserTest {
TEST_F('NewTabPageModulesDummyModuleTest', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var NewTabPageModulesKaleidoscopeModuleTest = class extends NewTabPageBrowserTest {
/** @override */
get browsePreload() {
return 'chrome://new-tab-page/test_loader.html?module=new_tab_page/modules/kaleidoscope/module_test.js';
}
};
TEST_F('NewTabPageModulesKaleidoscopeModuleTest', 'All', function() {
mocha.run();
});
......@@ -761,6 +761,9 @@ const base::Feature kInternalMediaSession {
const base::Feature kKaleidoscope{"Kaleidoscope",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kKaleidoscopeModule{"KaleidoscopeModule",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kUseFakeDeviceForMediaStream{
"use-fake-device-for-media-stream", base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -133,6 +133,7 @@ MEDIA_EXPORT extern const base::Feature kHardwareMediaKeyHandling;
MEDIA_EXPORT extern const base::Feature kHardwareSecureDecryption;
MEDIA_EXPORT extern const base::Feature kInternalMediaSession;
MEDIA_EXPORT extern const base::Feature kKaleidoscope;
MEDIA_EXPORT extern const base::Feature kKaleidoscopeModule;
MEDIA_EXPORT extern const base::Feature kLiveCaption;
MEDIA_EXPORT extern const base::Feature kLowDelayVideoRenderingOnLiveStream;
MEDIA_EXPORT extern const base::Feature kMediaCapabilitiesQueryGpuFactories;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment