Commit 004f26fd authored by huangs@chromium.org's avatar huangs@chromium.org

[Local NTP] Implementing Material Design styling

We also want the "classical" NTP to coexist with the new design, and
switchable via Finch. Key changes:
- Adding classes to #ntp-content, then using CSS to control styling.
  - .classical for old NTP
  - .md for Material Design
  - .default-theme for values that will be overriden by themes. This is
    needed so dynamic CSS changes in setCustomThemeStyle() are not
    subsumed by specialized .classical and .md.
  - .dark: for dark background.
- The .mv-mask <div> is promoted to handle tile effects, including
  border, shadow, and background. Borders are drawn differently now.
  This lead to fix of 1px offset of .mv-title .

Some new designs are still in flux. Our goal is to get a reasonable bulk
committed for m38, then worry about some tune-ups later.

TEST=Run "chrome.exe --force-fieldtrials=MaterialDesignNTP/Enabled/",
visit chrome-search://local-ntp/local-ntp.html . If chrome.exe is run
without the switch, the local NTP should be identical to before, except
for 1px .mv-title shift.

BUG=400332

Review URL: https://codereview.chromium.org/473583002

Cr-Commit-Position: refs/heads/master@{#289682}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289682 0039d316-1c4b-4281-b951-d872f2087c98
parent cf44ce93
...@@ -17,7 +17,7 @@ body { ...@@ -17,7 +17,7 @@ body {
.non-google-page #ntp-contents { .non-google-page #ntp-contents {
position: absolute; position: absolute;
top: -webkit-calc(50% - 155px); top: calc(50% - 155px);
width: 100%; width: 100%;
} }
...@@ -57,10 +57,10 @@ body.alternate-logo #logo { ...@@ -57,10 +57,10 @@ body.alternate-logo #logo {
border: 1px solid rgb(185, 185, 185); border: 1px solid rgb(185, 185, 185);
border-radius: 1px; border-radius: 1px;
border-top-color: rgb(160, 160, 160); border-top-color: rgb(160, 160, 160);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
cursor: text; cursor: text;
font-size: 18px; font-size: 18px;
height: 36px; height: 36px;
line-height: 36px;
max-width: 620px; max-width: 620px;
position: relative; position: relative;
/* #fakebox width (here and below) should be 2px less than #mv-tiles /* #fakebox width (here and below) should be 2px less than #mv-tiles
...@@ -73,6 +73,10 @@ body.alternate-logo #logo { ...@@ -73,6 +73,10 @@ body.alternate-logo #logo {
border-top-color: rgb(144, 144, 144); border-top-color: rgb(144, 144, 144);
} }
.classical #fakebox {
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}
body.fakebox-focused #fakebox { body.fakebox-focused #fakebox {
border: 1px solid rgb(77, 144, 254); border: 1px solid rgb(77, 144, 254);
} }
...@@ -89,12 +93,29 @@ body.fakebox-focused #fakebox { ...@@ -89,12 +93,29 @@ body.fakebox-focused #fakebox {
width: 100%; width: 100%;
} }
body.rtl #fakebox > input { body[dir=rtl] #fakebox > input {
padding-left: 0; padding-left: 0;
padding-right: 8px; padding-right: 8px;
right: 0; right: 0;
} }
#fakebox-text {
color: #bbb;
font-family: arial, sans-serif;
font-size: 16px;
height: 16px;
left: 9px;
margin-top: 1px;
position: absolute;
vertical-align: middle;
visibility: hidden;
}
body[dir=rtl] #fakebox-text {
left: auto;
right: 9px;
}
#cursor { #cursor {
background: #333; background: #333;
bottom: 5px; bottom: 5px;
...@@ -105,7 +126,7 @@ body.rtl #fakebox > input { ...@@ -105,7 +126,7 @@ body.rtl #fakebox > input {
width: 1px; width: 1px;
} }
body.rtl #cursor { body[dir=rtl] #cursor {
left: auto; left: auto;
right: 9px; right: 9px;
} }
...@@ -119,6 +140,11 @@ body.rtl #cursor { ...@@ -119,6 +140,11 @@ body.rtl #cursor {
} }
} }
body.fakebox-drag-focused #fakebox-text,
body.fakebox-focused #fakebox-text {
visibility: inherit;
}
body.fakebox-drag-focused #cursor { body.fakebox-drag-focused #cursor {
visibility: inherit; visibility: inherit;
} }
...@@ -130,80 +156,276 @@ body.fakebox-focused #cursor { ...@@ -130,80 +156,276 @@ body.fakebox-focused #cursor {
#most-visited { #most-visited {
-webkit-user-select: none; -webkit-user-select: none;
margin-top: 51px;
text-align: -webkit-center; text-align: -webkit-center;
} }
.classical #most-visited {
margin-top: 51px;
}
.md #most-visited {
margin-top: 50px;
}
#mv-tiles { #mv-tiles {
height: calc(2 * 138px);
line-height: 138px;
margin: 0; margin: 0;
position: relative; position: relative;
text-align: left;
}
body[dir=rtl] #mv-tiles {
text-align: right;
}
.classical #mv-tiles {
height: calc(2 * 138px);
line-height: 138px;
}
.md #mv-tiles {
height: calc(2 * 126px);
line-height: 126px;
} }
.mv-tile { .mv-tile {
-webkit-transition-duration: 200ms; display: inline-block;
-webkit-transition-property: -webkit-transform, margin, opacity, width; position: relative;
background: -webkit-linear-gradient(#f2f2f2, #e8e8e8); vertical-align: top;
border: 1px solid transparent; }
.mv-page-ready {
cursor: pointer;
outline: none;
}
.classical .mv-tile {
background: linear-gradient(#f2f2f2, #e8e8e8);
border-radius: 3px; border-radius: 3px;
box-shadow: inset 0 2px 3px rgba(0, 0, 0, .09); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .09);
display: inline-block; height: 85px;
height: 83px;
margin-left: 10px; margin-left: 10px;
margin-right: 10px; /* Total horizontal margins add to TILE_MARGIN. */ margin-right: 10px; /* Total horizontal margins add to TILE_MARGIN. */
position: relative; width: 140px;
vertical-align: top; }
width: 138px;
.classical .mv-page-ready {
-webkit-transition-duration: 200ms;
-webkit-transition-property: -webkit-transform, margin, opacity, width;
}
.md .mv-tile {
background: #f2f2f2;
border-radius: 1px;
height: 114px;
margin-left: 6px;
margin-right: 6px;
width: 146px;
}
.md .mv-page-ready {
-webkit-transition-duration: 200ms;
-webkit-transition-property: -webkit-transform, margin, opacity, width;
}
.md.dark .mv-tile {
background: #333;
}
.mv-tile-inner {
visibility: hidden;
}
.mv-page-ready .mv-tile-inner {
visibility: visible;
} }
/* Class applied to tiles to trigger the blacklist animation. */ /* Class applied to tiles to trigger the blacklist animation. */
.mv-tile.mv-blacklist { .mv-tile.mv-blacklist {
-webkit-transform: scale(0.5);
opacity: 0; opacity: 0;
} }
.mv-page-ready { .classical .mv-tile.mv-blacklist {
border: 1px solid #c0c0c0; -webkit-transform: scale(0.5);
cursor: pointer;
outline: none;
} }
.mv-page-ready:hover, .md .mv-tile.mv-blacklist {
.mv-page-ready:focus { -webkit-transform: scale(0, 0);
border-color: #7f7f7f -webkit-transform-origin: 0 41px;
margin-left: 0;
margin-right: 0;
width: 0;
} }
.mv-thumb, /* .mv-mask is used to alter tile appearance, including borders, shadows, */
/* and backgrounds. */
.mv-mask { .mv-mask {
border: none; background: transparent;
border-style: solid;
border-width: 1px;
cursor: pointer; cursor: pointer;
height: 83px; pointer-events: none;
left: 0;
position: absolute; position: absolute;
top: 0; }
width: 138px;
.classical .mv-mask {
box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.09);
}
.md .mv-mask {
border-color: transparent;
border-radius: 2px;
height: 112px;
width: 144px;
}
/* Styling border. */
.classical .mv-page-ready .mv-mask {
border-style: solid;
}
.default-theme.classical .mv-page-ready .mv-mask {
border-color: #c0c0c0;
}
.default-theme.classical .mv-page-ready:hover .mv-mask,
.default-theme.classical .mv-page-ready:focus .mv-mask {
border-color: #7f7f7f;
}
.default-theme.md.old-hover .mv-page-ready:hover .mv-mask,
.default-theme.md.old-hover .mv-page-ready:focus .mv-mask {
border-color: #999;
}
.default-theme.md.dark .mv-page-ready:hover .mv-mask,
.default-theme.md.dark .mv-page-ready:focus .mv-mask,
.default-theme.md.old-hover.dark .mv-page-ready:hover .mv-mask {
border-color: #888;
}
/* Styling shadow. */
.md .mv-page-ready .mv-mask {
-webkit-transition: box-shadow 200ms, border 200ms;
}
.default-theme.md .mv-page-ready:hover .mv-mask {
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.default-theme..md.dark .mv-page-ready:hover .mv-mask,
.default-theme..md.old-hover .mv-page-ready:hover .mv-mask {
box-shadow: none;
}
/* Styling background. */
.classical .mv-page:focus .mv-mask {
-webkit-transition: background-color 100ms ease-in-out;
background: linear-gradient(rgba(255, 255, 255, 0),
rgba(255, 255, 255, 0) 80%, rgba(255, 255, 255, 0.9));
background-color: rgba(0, 0, 0, 0.35);
}
.md .mv-page:focus .mv-mask {
-webkit-transition: box-shadow 200ms, border 200ms,
background-color 100ms ease-in-out, ;
background: rgba(0, 0, 0, 0.3);
border-color: rgba(0, 0, 0, 0.3);
} }
.mv-title { .mv-title {
border: none; border: none;
bottom: -28px; position: absolute;
}
.classical .mv-title {
bottom: -27px;
height: 18px; height: 18px;
left: 0; left: 0;
position: absolute;
width: 140px; width: 140px;
} }
.mv-mask { .md .mv-title {
opacity: 0.35; bottom: auto;
pointer-events: none; height: 15px;
left: 28px;
top: 7px;
width: 112px;
} }
.mv-page:focus .mv-mask { @media (-webkit-min-device-pixel-ratio: 2) {
-webkit-transition: background-color 100ms ease-in-out; .md .mv-title {
background: -webkit-linear-gradient(rgba(255, 255, 255, 0), top: 6px;
rgba(255, 255, 255, 0) 80%, rgba(255, 255, 255, 0.9)); }
background-color: black; }
body[dir=rtl] .md .mv-title {
left: auto;
right: 28px;
}
.mv-thumb {
border: none;
cursor: pointer;
position: absolute;
}
.classical .mv-thumb,
.classical .mv-mask {
height: 83px;
width: 138px;
}
.classical .mv-thumb {
border-radius: 2px;
left: 1px;
top: 1px;
}
.classical .mv-mask {
border-radius: 3px;
left: 0;
top: 0;
}
.md .mv-thumb,
.md .mv-thumb-fallback {
border-radius: 0;
height: 82px;
left: 4px;
top: 28px;
width: 138px;
}
body[dir=rtl] .md .mv-thumb,
body[dir=rtl] .md .mv-thumb-fallback {
left: auto;
right: 4px;
}
.md .mv-thumb-fallback {
background: #fff;
padding: none;
position: absolute;
}
.md.dark .mv-thumb-fallback {
background: #555;
}
.md .mv-thumb-fallback .dot {
background: #f2f2f2;
border-radius: 16px;
display: block;
height: 32px;
left: 50%;
margin-left: -16px;
margin-top: -16px;
position: absolute;
top: 50%;
width: 32px;
}
.md.dark .mv-thumb-fallback .dot {
background: #333;
} }
.mv-x-hide .mv-x { .mv-x-hide .mv-x {
...@@ -212,35 +434,58 @@ body.fakebox-focused #cursor { ...@@ -212,35 +434,58 @@ body.fakebox-focused #cursor {
/* An X button to blacklist a tile or hide the notification. */ /* An X button to blacklist a tile or hide the notification. */
.mv-x { .mv-x {
background: transparent url(images/close_2.png); background-color: transparent;
background-image: url(images/close_2.png);
border: none; border: none;
cursor: default; cursor: default;
height: 16px; height: 16px;
width: 16px; width: 16px;
} }
.mv-page .mv-x {
-webkit-transition: opacity 150ms;
opacity: 0;
position: absolute;
}
.mv-x:hover, .mv-x:hover,
#mv-notice-x:focus { #mv-notice-x:focus {
background: transparent url(images/close_2_hover.png); background-image: url(images/close_2_hover.png);
} }
.mv-x:active { .mv-x:active {
background: transparent url(images/close_2_active.png); background-image: url(images/close_2_active.png);
} }
.mv-page .mv-x { .classical .mv-page .mv-x {
-webkit-transition: opacity 150ms;
opacity: 0;
position: absolute;
right: 2px; right: 2px;
top: 2px; top: 2px;
} }
body.rtl .mv-page .mv-x { .md .mv-x {
background-color: rgba(187,187,187,0.8);
border-radius: 8px;
}
.md.dark .mv-x {
background-color: rgba(119,119,119,0.8);
}
.md .mv-page .mv-x {
right: 4px;
top: 5px;
}
body[dir=rtl] .classical .mv-page .mv-x {
left: 2px; left: 2px;
right: auto; right: auto;
} }
body[dir=rtl] .md .mv-page .mv-x {
left: 4px;
right: auto;
}
.mv-page-ready:hover .mv-x { .mv-page-ready:hover .mv-x {
-webkit-transition-delay: 500ms; -webkit-transition-delay: 500ms;
opacity: 1; opacity: 1;
...@@ -252,14 +497,28 @@ body.rtl .mv-page .mv-x { ...@@ -252,14 +497,28 @@ body.rtl .mv-page .mv-x {
.mv-favicon { .mv-favicon {
background-size: 16px; background-size: 16px;
bottom: -8px;
height: 16px; height: 16px;
left: 61px;
pointer-events: none; pointer-events: none;
position: absolute; position: absolute;
width: 16px; width: 16px;
} }
.classical .mv-favicon {
bottom: -7px;
left: 62px;
}
.md .mv-favicon {
left: 6px;
top: 6px;
}
body[dir=rtl] .md .mv-favicon {
left: auto;
right: 6px;
top: 6px;
}
/* The notification shown when a tile is blacklisted. */ /* The notification shown when a tile is blacklisted. */
#mv-notice { #mv-notice {
font-size: 12px; font-size: 12px;
...@@ -287,6 +546,10 @@ body.rtl .mv-page .mv-x { ...@@ -287,6 +546,10 @@ body.rtl .mv-page .mv-x {
text-decoration: underline; text-decoration: underline;
} }
.default-theme.dark #mv-msg {
color: #fff;
}
#mv-notice-links .mv-x { #mv-notice-links .mv-x {
-webkit-margin-start: 8px; -webkit-margin-start: 8px;
outline: none; outline: none;
...@@ -316,7 +579,7 @@ body.rtl .mv-page .mv-x { ...@@ -316,7 +579,7 @@ body.rtl .mv-page .mv-x {
z-index: -1; z-index: -1;
} }
body.rtl #attribution { body[dir=rtl] #attribution {
text-align: right; text-align: right;
} }
...@@ -335,7 +598,7 @@ body.rtl #attribution { ...@@ -335,7 +598,7 @@ body.rtl #attribution {
right: 8px; right: 8px;
} }
body.rtl #attribution,body.rtl #recent-tabs { body[dir=rtl] #attribution,body[dir=rtl] #recent-tabs {
left: 8px; left: 8px;
right: auto; right: auto;
} }
...@@ -28,12 +28,16 @@ var CLASSES = { ...@@ -28,12 +28,16 @@ var CLASSES = {
ALTERNATE_LOGO: 'alternate-logo', // Shows white logo if required by theme ALTERNATE_LOGO: 'alternate-logo', // Shows white logo if required by theme
BLACKLIST: 'mv-blacklist', // triggers tile blacklist animation BLACKLIST: 'mv-blacklist', // triggers tile blacklist animation
BLACKLIST_BUTTON: 'mv-x', BLACKLIST_BUTTON: 'mv-x',
DARK: 'dark',
DEFAULT_THEME: 'default-theme',
DELAYED_HIDE_NOTIFICATION: 'mv-notice-delayed-hide', DELAYED_HIDE_NOTIFICATION: 'mv-notice-delayed-hide',
DOT: 'dot',
FAKEBOX_DISABLE: 'fakebox-disable', // Makes fakebox non-interactive FAKEBOX_DISABLE: 'fakebox-disable', // Makes fakebox non-interactive
FAKEBOX_FOCUS: 'fakebox-focused', // Applies focus styles to the fakebox FAKEBOX_FOCUS: 'fakebox-focused', // Applies focus styles to the fakebox
// Applies drag focus style to the fakebox // Applies drag focus style to the fakebox
FAKEBOX_DRAG_FOCUS: 'fakebox-drag-focused', FAKEBOX_DRAG_FOCUS: 'fakebox-drag-focused',
FAVICON: 'mv-favicon', FAVICON: 'mv-favicon',
FAVICON_FALLBACK: 'mv-favicon-fallback',
HIDE_BLACKLIST_BUTTON: 'mv-x-hide', // hides blacklist button during animation HIDE_BLACKLIST_BUTTON: 'mv-x-hide', // hides blacklist button during animation
HIDE_FAKEBOX_AND_LOGO: 'hide-fakebox-logo', HIDE_FAKEBOX_AND_LOGO: 'hide-fakebox-logo',
HIDE_NOTIFICATION: 'mv-notice-hide', HIDE_NOTIFICATION: 'mv-notice-hide',
...@@ -43,8 +47,10 @@ var CLASSES = { ...@@ -43,8 +47,10 @@ var CLASSES = {
PAGE_READY: 'mv-page-ready', // page tile when ready PAGE_READY: 'mv-page-ready', // page tile when ready
RTL: 'rtl', // Right-to-left language text. RTL: 'rtl', // Right-to-left language text.
THUMBNAIL: 'mv-thumb', THUMBNAIL: 'mv-thumb',
THUMBNAIL_FALLBACK: 'mv-thumb-fallback',
THUMBNAIL_MASK: 'mv-mask', THUMBNAIL_MASK: 'mv-mask',
TILE: 'mv-tile', TILE: 'mv-tile',
TILE_INNER: 'mv-tile-inner',
TITLE: 'mv-title' TITLE: 'mv-title'
}; };
...@@ -60,6 +66,7 @@ var IDS = { ...@@ -60,6 +66,7 @@ var IDS = {
CUSTOM_THEME_STYLE: 'ct-style', CUSTOM_THEME_STYLE: 'ct-style',
FAKEBOX: 'fakebox', FAKEBOX: 'fakebox',
FAKEBOX_INPUT: 'fakebox-input', FAKEBOX_INPUT: 'fakebox-input',
FAKEBOX_TEXT: 'fakebox-text',
LOGO: 'logo', LOGO: 'logo',
NOTIFICATION: 'mv-notice', NOTIFICATION: 'mv-notice',
NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x', NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x',
...@@ -168,6 +175,13 @@ var lastBlacklistedTile = null; ...@@ -168,6 +175,13 @@ var lastBlacklistedTile = null;
var isBlacklisting = false; var isBlacklisting = false;
/**
* Stores whether the current theme has a dark background.
* @type {boolean}
*/
var isBackgroundDark = false;
/** /**
* Current number of tiles columns shown based on the window width, including * Current number of tiles columns shown based on the window width, including
* those that just contain filler. * those that just contain filler.
...@@ -266,16 +280,20 @@ var MOST_VISITED_PAINT_TIMEOUT_MSEC = 500; ...@@ -266,16 +280,20 @@ var MOST_VISITED_PAINT_TIMEOUT_MSEC = 500;
* pad out the section when not enough pages exist. * pad out the section when not enough pages exist.
* *
* @param {Element} elem The element for rendering the tile. * @param {Element} elem The element for rendering the tile.
* @param {Element=} opt_innerElem The element for contents of tile.
* @param {Element=} opt_titleElem The element for rendering the title. * @param {Element=} opt_titleElem The element for rendering the title.
* @param {Element=} opt_thumbnailElem The element for rendering the thumbnail. * @param {Element=} opt_thumbnailElem The element for rendering the thumbnail.
* @param {number=} opt_rid The RID for the corresponding Most Visited page. * @param {number=} opt_rid The RID for the corresponding Most Visited page.
* Should only be left unspecified when creating a filler tile. * Should only be left unspecified when creating a filler tile.
* @constructor * @constructor
*/ */
function Tile(elem, opt_titleElem, opt_thumbnailElem, opt_rid) { function Tile(elem, opt_innerElem, opt_titleElem, opt_thumbnailElem, opt_rid) {
/** @type {Element} */ /** @type {Element} */
this.elem = elem; this.elem = elem;
/** @type {Element|undefined} */
this.innerElem = opt_innerElem;
/** @type {Element|undefined} */ /** @type {Element|undefined} */
this.titleElem = opt_titleElem; this.titleElem = opt_titleElem;
...@@ -287,14 +305,34 @@ function Tile(elem, opt_titleElem, opt_thumbnailElem, opt_rid) { ...@@ -287,14 +305,34 @@ function Tile(elem, opt_titleElem, opt_thumbnailElem, opt_rid) {
} }
/**
* Determines whether a theme should be considered to have dark background.
* @param {ThemeBackgroundInfo} info Theme background information.
* @return {boolean} Whether the theme has dark background.
* @private
*/
function getIsBackgroundDark(info) {
if (info.imageUrl)
return true;
var rgba = info.backgroundColorRgba;
var luminance = 0.3 * rgba[0] + 0.59 * rgba[1] + 0.11 * rgba[2];
return luminance < 128;
}
/** /**
* Updates the NTP based on the current theme. * Updates the NTP based on the current theme.
* @private * @private
*/ */
function onThemeChange() { function renderTheme() {
var info = ntpApiHandle.themeBackgroundInfo; var info = ntpApiHandle.themeBackgroundInfo;
if (!info) if (!info) {
isBackgroundDark = false;
return; return;
}
isBackgroundDark = getIsBackgroundDark(info);
ntpContents.classList.toggle(CLASSES.DARK, isBackgroundDark);
var background = [convertToRGBAColor(info.backgroundColorRgba), var background = [convertToRGBAColor(info.backgroundColorRgba),
info.imageUrl, info.imageUrl,
...@@ -305,7 +343,15 @@ function onThemeChange() { ...@@ -305,7 +343,15 @@ function onThemeChange() {
document.body.classList.toggle(CLASSES.ALTERNATE_LOGO, info.alternateLogo); document.body.classList.toggle(CLASSES.ALTERNATE_LOGO, info.alternateLogo);
updateThemeAttribution(info.attributionUrl); updateThemeAttribution(info.attributionUrl);
setCustomThemeStyle(info); setCustomThemeStyle(info);
}
/**
* Updates the NTP based on the current theme, then rerenders all tiles.
* @private
*/
function onThemeChange() {
renderTheme();
tilesContainer.innerHTML = ''; tilesContainer.innerHTML = '';
renderAndShowTiles(); renderAndShowTiles();
} }
...@@ -322,6 +368,7 @@ function setCustomThemeStyle(opt_themeInfo) { ...@@ -322,6 +368,7 @@ function setCustomThemeStyle(opt_themeInfo) {
var head = document.head; var head = document.head;
if (opt_themeInfo && !opt_themeInfo.usingDefaultTheme) { if (opt_themeInfo && !opt_themeInfo.usingDefaultTheme) {
ntpContents.classList.remove(CLASSES.DEFAULT_THEME);
var themeStyle = var themeStyle =
'#attribution {' + '#attribution {' +
' color: ' + convertToRGBAColor(opt_themeInfo.textColorLightRgba) + ';' + ' color: ' + convertToRGBAColor(opt_themeInfo.textColorLightRgba) + ';' +
...@@ -336,11 +383,11 @@ function setCustomThemeStyle(opt_themeInfo) { ...@@ -336,11 +383,11 @@ function setCustomThemeStyle(opt_themeInfo) {
' -webkit-filter: drop-shadow(0 0 0 ' + ' -webkit-filter: drop-shadow(0 0 0 ' +
convertToRGBAColor(opt_themeInfo.textColorRgba) + ');' + convertToRGBAColor(opt_themeInfo.textColorRgba) + ');' +
'}' + '}' +
'.mv-page-ready {' + '.mv-page-ready .mv-mask {' +
' border: 1px solid ' + ' border: 1px solid ' +
convertToRGBAColor(opt_themeInfo.sectionBorderColorRgba) + ';' + convertToRGBAColor(opt_themeInfo.sectionBorderColorRgba) + ';' +
'}' + '}' +
'.mv-page-ready:hover, .mv-page-ready:focus {' + '.mv-page-ready:hover .mv-mask, .mv-page-ready:focus .mv-mask {' +
' border-color: ' + ' border-color: ' +
convertToRGBAColor(opt_themeInfo.headerColorRgba) + ';' + convertToRGBAColor(opt_themeInfo.headerColorRgba) + ';' +
'}'; '}';
...@@ -355,8 +402,10 @@ function setCustomThemeStyle(opt_themeInfo) { ...@@ -355,8 +402,10 @@ function setCustomThemeStyle(opt_themeInfo) {
head.appendChild(customStyleElement); head.appendChild(customStyleElement);
} }
} else if (customStyleElement) { } else {
head.removeChild(customStyleElement); ntpContents.classList.add(CLASSES.DEFAULT_THEME);
if (customStyleElement)
head.removeChild(customStyleElement);
} }
} }
...@@ -412,10 +461,10 @@ function convertToRGBAColor(color) { ...@@ -412,10 +461,10 @@ function convertToRGBAColor(color) {
function onMostVisitedChange() { function onMostVisitedChange() {
if (isBlacklisting) { if (isBlacklisting) {
// Trigger the blacklist animation, which then triggers reloadAllTiles(). // Trigger the blacklist animation, which then triggers reloadAllTiles().
var lastBlacklistedTileElement = lastBlacklistedTile.elem; var lastBlacklistedTileElem = lastBlacklistedTile.elem;
lastBlacklistedTileElement.addEventListener( lastBlacklistedTileElem.addEventListener(
'webkitTransitionEnd', blacklistAnimationDone); 'webkitTransitionEnd', blacklistAnimationDone);
lastBlacklistedTileElement.classList.add(CLASSES.BLACKLIST); lastBlacklistedTileElem.classList.add(CLASSES.BLACKLIST);
} else { } else {
reloadAllTiles(); reloadAllTiles();
} }
...@@ -457,22 +506,19 @@ function reloadAllTiles() { ...@@ -457,22 +506,19 @@ function reloadAllTiles() {
/** /**
* Binds onload events for a tile's internal <iframe> elements. * Binds onload events for a tile's internal <iframe> elements.
* @param {Tile} tile The main tile to bind events to. * @param {Tile} tile The main tile to bind events to.
* @param {Barrier} tileVisibilityBarrier A barrier to make tile visible the * @param {Barrier} tileVisibilityBarrier A barrier to make all tiles visible
* moment all tiles are loaded. * the moment all tiles are loaded.
*/ */
function bindTileOnloadEvents(tile, tileVisibilityBarrier) { function bindTileOnloadEvents(tile, tileVisibilityBarrier) {
if (tile.titleElem) { if (tile.titleElem) {
tileVisibilityBarrier.add(); tileVisibilityBarrier.add();
tile.titleElem.onload = function() { tile.titleElem.onload = function() {
tile.titleElem.hidden = false;
tileVisibilityBarrier.remove(); tileVisibilityBarrier.remove();
}; };
} }
if (tile.thumbnailElem) { if (tile.thumbnailElem) {
tileVisibilityBarrier.add(); tileVisibilityBarrier.add();
tile.thumbnailElem.onload = function() { tile.thumbnailElem.onload = function() {
tile.thumbnailElem.hidden = false;
tile.elem.classList.add(CLASSES.PAGE_READY); tile.elem.classList.add(CLASSES.PAGE_READY);
tileVisibilityBarrier.remove(); tileVisibilityBarrier.remove();
}; };
...@@ -494,18 +540,21 @@ function renderAndShowTiles() { ...@@ -494,18 +540,21 @@ function renderAndShowTiles() {
// If we need to render new tiles, manage the visibility to hide intermediate // If we need to render new tiles, manage the visibility to hide intermediate
// load states of the <iframe>s. // load states of the <iframe>s.
if (numExisting < numDesired) { if (numExisting < numDesired) {
var tileVisibilityBarrier = new Barrier(function() { var showAll = function() {
tilesContainer.style.visibility = 'visible'; for (var i = 0; i < numDesired; ++i) {
}); if (tiles[i].titleElem || tiles[i].thumbnailElem)
tiles[i].elem.classList.add(CLASSES.PAGE_READY);
}
};
var tileVisibilityBarrier = new Barrier(showAll);
if (!userInitiatedMostVisitedChange) { if (!userInitiatedMostVisitedChange) {
// Make titleContainer invisible, but still taking up space. // Make titleContainer invisible, but still taking up space.
// titleContainer becomes visible again (1) on timeout, or (2) when all // titleContainer becomes visible again (1) on timeout, or (2) when all
// tiles finish loading (using tileVisibilityBarrier). // tiles finish loading (using tileVisibilityBarrier).
tilesContainer.style.visibility = 'hidden';
window.setTimeout(function() { window.setTimeout(function() {
tileVisibilityBarrier.cancel(); tileVisibilityBarrier.cancel();
tilesContainer.style.visibility = 'visible'; showAll();
}, MOST_VISITED_PAINT_TIMEOUT_MSEC); }, MOST_VISITED_PAINT_TIMEOUT_MSEC);
} }
userInitiatedMostVisitedChange = false; userInitiatedMostVisitedChange = false;
...@@ -516,8 +565,8 @@ function renderAndShowTiles() { ...@@ -516,8 +565,8 @@ function renderAndShowTiles() {
} }
} }
// Show only the desired tiles. Not using .hidden because it does not work for // Show only the desired tiles. Note that .hidden does not work for
// inline-block elements. // inline-block elements like tiles[i].elem.
for (var i = 0; i < numDesired; ++i) for (var i = 0; i < numDesired; ++i)
tiles[i].elem.style.display = 'inline-block'; tiles[i].elem.style.display = 'inline-block';
// If |numDesired| < |numExisting| then hide extra tiles (e.g., this occurs // If |numDesired| < |numExisting| then hide extra tiles (e.g., this occurs
...@@ -536,11 +585,13 @@ function renderAndShowTiles() { ...@@ -536,11 +585,13 @@ function renderAndShowTiles() {
function getMostVisitedTitleIframeUrl(rid, position) { function getMostVisitedTitleIframeUrl(rid, position) {
var url = 'chrome-search://most-visited/' + var url = 'chrome-search://most-visited/' +
encodeURIComponent(MOST_VISITED_TITLE_IFRAME); encodeURIComponent(MOST_VISITED_TITLE_IFRAME);
var titleColor = isBackgroundDark ? NTP_DESIGN.titleColorAgainstDark :
NTP_DESIGN.titleColor;
var params = [ var params = [
'rid=' + encodeURIComponent(rid), 'rid=' + encodeURIComponent(rid),
'f=' + encodeURIComponent(NTP_DESIGN.fontFamily), 'f=' + encodeURIComponent(NTP_DESIGN.fontFamily),
'fs=' + encodeURIComponent(NTP_DESIGN.fontSize), 'fs=' + encodeURIComponent(NTP_DESIGN.fontSize),
'c=' + encodeURIComponent(NTP_DESIGN.titleColor), 'c=' + encodeURIComponent(titleColor),
'pos=' + encodeURIComponent(position)]; 'pos=' + encodeURIComponent(position)];
if (NTP_DESIGN.titleTextAlign) if (NTP_DESIGN.titleTextAlign)
params.push('ta=' + encodeURIComponent(NTP_DESIGN.titleTextAlign)); params.push('ta=' + encodeURIComponent(NTP_DESIGN.titleTextAlign));
...@@ -565,6 +616,8 @@ function getMostVisitedThumbnailIframeUrl(rid, position) { ...@@ -565,6 +616,8 @@ function getMostVisitedThumbnailIframeUrl(rid, position) {
'fs=' + encodeURIComponent(NTP_DESIGN.fontSize), 'fs=' + encodeURIComponent(NTP_DESIGN.fontSize),
'c=' + encodeURIComponent(NTP_DESIGN.thumbnailTextColor), 'c=' + encodeURIComponent(NTP_DESIGN.thumbnailTextColor),
'pos=' + encodeURIComponent(position)]; 'pos=' + encodeURIComponent(position)];
if (NTP_DESIGN.thumbnailFallback)
params.push('etfb=1');
return url + '?' + params.join('&'); return url + '?' + params.join('&');
} }
...@@ -577,12 +630,13 @@ function getMostVisitedThumbnailIframeUrl(rid, position) { ...@@ -577,12 +630,13 @@ function getMostVisitedThumbnailIframeUrl(rid, position) {
* @return {Tile} The new Tile. * @return {Tile} The new Tile.
*/ */
function createTile(page, position) { function createTile(page, position) {
var tileElement = document.createElement('div'); var tileElem = document.createElement('div');
tileElement.classList.add(CLASSES.TILE); tileElem.classList.add(CLASSES.TILE);
var innerElem = createAndAppendElement(tileElem, 'div', CLASSES.TILE_INNER);
if (page) { if (page) {
var rid = page.rid; var rid = page.rid;
tileElement.classList.add(CLASSES.PAGE); tileElem.classList.add(CLASSES.PAGE);
var navigateFunction = function(e) { var navigateFunction = function(e) {
e.preventDefault(); e.preventDefault();
...@@ -590,15 +644,15 @@ function createTile(page, position) { ...@@ -590,15 +644,15 @@ function createTile(page, position) {
}; };
// The click handler for navigating to the page identified by the RID. // The click handler for navigating to the page identified by the RID.
tileElement.addEventListener('click', navigateFunction); tileElem.addEventListener('click', navigateFunction);
// Make thumbnails tab-accessible. // Make thumbnails tab-accessible.
tileElement.setAttribute('tabindex', '1'); tileElem.setAttribute('tabindex', '1');
registerKeyHandler(tileElement, KEYCODE.ENTER, navigateFunction); registerKeyHandler(tileElem, KEYCODE.ENTER, navigateFunction);
// The iframe which renders the page title. // The iframe which renders the page title.
var titleElement = document.createElement('iframe'); var titleElem = document.createElement('iframe');
titleElement.tabIndex = '-1'; titleElem.tabIndex = '-1';
// Why iframes have IDs: // Why iframes have IDs:
// //
...@@ -615,45 +669,53 @@ function createTile(page, position) { ...@@ -615,45 +669,53 @@ function createTile(page, position) {
// TODO(jered): Find and fix the root (probably Blink) bug. // TODO(jered): Find and fix the root (probably Blink) bug.
// Keep this ID here. See comment above. // Keep this ID here. See comment above.
titleElement.id = 'title-' + rid; titleElem.id = 'title-' + rid;
titleElement.className = CLASSES.TITLE; titleElem.className = CLASSES.TITLE;
titleElement.hidden = true; titleElem.src = getMostVisitedTitleIframeUrl(rid, position);
titleElement.src = getMostVisitedTitleIframeUrl(rid, position); innerElem.appendChild(titleElem);
tileElement.appendChild(titleElement);
// A fallback element for missing thumbnails.
if (NTP_DESIGN.thumbnailFallback) {
var fallbackElem = createAndAppendElement(
innerElem, 'div', CLASSES.THUMBNAIL_FALLBACK);
if (NTP_DESIGN.thumbnailFallback === THUMBNAIL_FALLBACK.DOT)
createAndAppendElement(fallbackElem, 'div', CLASSES.DOT);
}
// The iframe which renders either a thumbnail or domain element. // The iframe which renders either a thumbnail or domain element.
var thumbnailElement = document.createElement('iframe'); var thumbnailElem = document.createElement('iframe');
thumbnailElement.tabIndex = '-1'; thumbnailElem.tabIndex = '-1';
// Keep this ID here. See comment above. // Keep this ID here. See comment above.
thumbnailElement.id = 'thumb-' + rid; thumbnailElem.id = 'thumb-' + rid;
thumbnailElement.className = CLASSES.THUMBNAIL; thumbnailElem.className = CLASSES.THUMBNAIL;
thumbnailElement.hidden = true; thumbnailElem.src = getMostVisitedThumbnailIframeUrl(rid, position);
thumbnailElement.src = getMostVisitedThumbnailIframeUrl(rid, position); innerElem.appendChild(thumbnailElem);
tileElement.appendChild(thumbnailElement);
// A mask to darken the thumbnail on focus.
var maskElement = createAndAppendElement(
tileElement, 'div', CLASSES.THUMBNAIL_MASK);
// The button used to blacklist this page. // The button used to blacklist this page.
var blacklistButton = createAndAppendElement( var blacklistButton = createAndAppendElement(
tileElement, 'div', CLASSES.BLACKLIST_BUTTON); innerElem, 'div', CLASSES.BLACKLIST_BUTTON);
var blacklistFunction = generateBlacklistFunction(rid); var blacklistFunction = generateBlacklistFunction(rid);
blacklistButton.addEventListener('click', blacklistFunction); blacklistButton.addEventListener('click', blacklistFunction);
blacklistButton.title = configData.translatedStrings.removeThumbnailTooltip; blacklistButton.title = configData.translatedStrings.removeThumbnailTooltip;
// A helper mask on top of the tile that is used to create hover border
// and/or to darken the thumbnail on focus.
var maskElement = createAndAppendElement(
innerElem, 'div', CLASSES.THUMBNAIL_MASK);
// When a tile is focused, have delete also blacklist the page. // When a tile is focused, have delete also blacklist the page.
registerKeyHandler(tileElement, KEYCODE.DELETE, blacklistFunction); registerKeyHandler(tileElem, KEYCODE.DELETE, blacklistFunction);
// The page favicon, if any. // The page favicon, or a fallback.
var faviconUrl = page.faviconUrl; var favicon = createAndAppendElement(innerElem, 'div', CLASSES.FAVICON);
if (faviconUrl) { if (page.faviconUrl) {
var favicon = createAndAppendElement(tileElement, 'div', CLASSES.FAVICON); favicon.style.backgroundImage = 'url(' + page.faviconUrl + ')';
favicon.style.backgroundImage = 'url(' + faviconUrl + ')'; } else {
favicon.classList.add(CLASSES.FAVICON_FALLBACK);
} }
return new Tile(tileElement, titleElement, thumbnailElement, rid); return new Tile(tileElem, innerElem, titleElem, thumbnailElem, rid);
} else { } else {
return new Tile(tileElement); return new Tile(tileElem);
} }
} }
...@@ -747,8 +809,7 @@ function onResize() { ...@@ -747,8 +809,7 @@ function onResize() {
var tilesContainerWidth = numColumnsShown * tileRequiredWidth; var tilesContainerWidth = numColumnsShown * tileRequiredWidth;
tilesContainer.style.width = tilesContainerWidth + 'px'; tilesContainer.style.width = tilesContainerWidth + 'px';
if (fakebox) { if (fakebox) {
// -2 to account for border. fakebox.style.width = // -2 to account for border.
fakebox.style.width =
(tilesContainerWidth - NTP_DESIGN.tileMargin - 2) + 'px'; (tilesContainerWidth - NTP_DESIGN.tileMargin - 2) + 'px';
} }
// Render without clearing tiles. // Render without clearing tiles.
...@@ -936,10 +997,15 @@ function init() { ...@@ -936,10 +997,15 @@ function init() {
fakebox = document.createElement('div'); fakebox = document.createElement('div');
fakebox.id = IDS.FAKEBOX; fakebox.id = IDS.FAKEBOX;
fakebox.innerHTML = var fakeboxHtml = [];
'<input id="' + IDS.FAKEBOX_INPUT + fakeboxHtml.push('<input id="' + IDS.FAKEBOX_INPUT +
'" autocomplete="off" tabindex="-1" aria-hidden="true">' + '" autocomplete="off" tabindex="-1" aria-hidden="true">');
'<div id="cursor"></div>'; if (NTP_DESIGN.showFakeboxHint && configData.searchboxPlaceholder) {
fakeboxHtml.push('<div id="' + IDS.FAKEBOX_TEXT + '">' +
configData.searchboxPlaceholder + '</div>');
}
fakeboxHtml.push('<div id="cursor"></div>');
fakebox.innerHTML = fakeboxHtml.join('');
ntpContents.insertBefore(fakebox, ntpContents.firstChild); ntpContents.insertBefore(fakebox, ntpContents.firstChild);
ntpContents.insertBefore(logo, ntpContents.firstChild); ntpContents.insertBefore(logo, ntpContents.firstChild);
...@@ -983,7 +1049,7 @@ function init() { ...@@ -983,7 +1049,7 @@ function init() {
if (ntpApiHandle.isInputInProgress) if (ntpApiHandle.isInputInProgress)
onInputStart(); onInputStart();
onThemeChange(); renderTheme();
onMostVisitedChange(); onMostVisitedChange();
searchboxApiHandle = topLevelHandle.searchBox; searchboxApiHandle = topLevelHandle.searchBox;
......
...@@ -4,26 +4,33 @@ ...@@ -4,26 +4,33 @@
/** /**
* @fileoverview Specifications for the NTP design, and an accessor to presets. * @fileoverview Specifications for NTP design, and an accessor to presets.
*/ */
var THUMBNAIL_FALLBACK = {
DOT: 'dot' // Draw single dot.
};
/** /**
* Specifications for an NTP design (not comprehensive). * Specifications for an NTP design (not comprehensive).
* *
* name: A unique identifier for the style. * name: A unique identifier for the style.
* appropriate CSS will take effect.
* fontFamily: Font family to use for title and thumbnail <iframe>s. * fontFamily: Font family to use for title and thumbnail <iframe>s.
* fontSize: Font size to use for the <iframe>s, in px. * fontSize: Font size to use for the <iframe>s, in px.
* tileWidth: The width of each suggestion tile, in px. * tileWidth: The width of each suggestion tile, in px.
* tileMargin: Spacing between successive tiles, in px. * tileMargin: Spacing between successive tiles, in px.
* titleColor: The RRGGBB color of title text. * titleColor: The RRGGBB color of title text.
* titleColorAgainstDark: The RRGGBB color of title text against a dark theme.
* titleTextAlign: (Optional) The alignment of title text. If unspecified, the * titleTextAlign: (Optional) The alignment of title text. If unspecified, the
* default value is 'center'. * default value is 'center'.
* titleTextFade: (Optional) The number of pixels beyond which title * titleTextFade: (Optional) The number of pixels beyond which title
* text begins to fade. This overrides the default ellipsis style. * text begins to fade. This overrides the default ellipsis style.
* thumbnailTextColor: The RRGGBB color that thumbnail <iframe> may use to * thumbnailTextColor: The RRGGBB color that thumbnail <iframe> may use to
* display text message in place of missing thumbnail. * display text message in place of missing thumbnail.
* thumbnailFallback: (Optional) A value in THUMBNAIL_FALLBACK to specify the
* thumbnail fallback strategy. If unassigned, then the thumbnail.html
* <iframe> would handle the fallback.
* showFakeboxHint: Whether to display text in the fakebox.
* *
* @typedef {{ * @typedef {{
* name: string, * name: string,
...@@ -32,9 +39,12 @@ ...@@ -32,9 +39,12 @@
* tileWidth: number, * tileWidth: number,
* tileMargin: number, * tileMargin: number,
* titleColor: string, * titleColor: string,
* titleColorAgainstDark: string,
* titleTextAlign: string|null|undefined, * titleTextAlign: string|null|undefined,
* titleTextFade: string|null|undefined, * titleTextFade: string|null|undefined,
* thumbnailTextColor: string * thumbnailTextColor: string,
* thumbnailFallback: string|null|undefined
* showFakeboxHint: string|null|undefined
* }} * }}
*/ */
var NtpDesign; var NtpDesign;
...@@ -46,16 +56,38 @@ var NtpDesign; ...@@ -46,16 +56,38 @@ var NtpDesign;
* @return {NtpDesign} The NTP design corresponding to name. * @return {NtpDesign} The NTP design corresponding to name.
*/ */
function getNtpDesign(opt_name) { function getNtpDesign(opt_name) {
// TODO(huangs): Add new style. var ntpDesign = null;
return {
name: 'classical', if (opt_name === 'md') {
fontFamily: 'arial, sans-serif', ntpDesign = {
fontSize: 11, name: opt_name,
tileWidth: 140, fontFamily: 'arial, sans-serif',
tileMargin: 20, fontSize: 12,
titleColor: '777777', tileWidth: 146,
// No titleTextAlign: defaults to 'center'. tileMargin: 12,
// No titleTextFade: by default we have ellipsis. titleColor: '000000',
thumbnailTextColor: '777777' titleColorAgainstDark: 'd2d2d2',
}; titleTextAlign: 'inherit',
titleTextFade: 112 - 24, // 112px wide title with 24 pixel fade at end.
thumbnailTextColor: '777777',
thumbnailFallback: THUMBNAIL_FALLBACK.DOT,
showFakeboxHint: true
};
} else {
ntpDesign = {
name: 'classical',
fontFamily: 'arial, sans-serif',
fontSize: 11,
tileWidth: 140,
tileMargin: 20,
titleColor: '777777',
titleColorAgainstDark: '777777',
titleTextAlign: 'center',
titleTextFade: null, // Default to ellipsis.
thumbnailTextColor: '777777',
thumbnailFallback: null, // Default to false.
showFakeboxHint: false
};
}
return ntpDesign;
} }
...@@ -23,14 +23,7 @@ div { ...@@ -23,14 +23,7 @@ div {
width: 90%; width: 90%;
} }
img, img {
.shadow {
border-radius: 2px;
height: 100%; height: 100%;
width: 100%; width: 100%;
} }
.shadow {
box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.09);
position: absolute;
}
\ No newline at end of file
...@@ -42,17 +42,15 @@ window.addEventListener('DOMContentLoaded', function() { ...@@ -42,17 +42,15 @@ window.addEventListener('DOMContentLoaded', function() {
function createThumbnail(src) { function createThumbnail(src) {
var image = document.createElement('img'); var image = document.createElement('img');
image.onload = function() { image.onload = function() {
var shadow = document.createElement('span');
shadow.className = 'shadow';
var link = createMostVisitedLink( var link = createMostVisitedLink(
params, data.url, data.title, undefined, data.direction, params, data.url, data.title, undefined, data.direction,
data.provider); data.provider);
link.appendChild(shadow);
link.appendChild(image); link.appendChild(image);
displayLink(link); displayLink(link);
}; };
image.onerror = function() { image.onerror = function() {
if (data.domain) { // If no external thumbnail fallback (etfb), and have domain.
if (!params.etfb && data.domain) {
showDomainElement(); showDomainElement();
logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK); logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK);
} else { } else {
......
...@@ -156,6 +156,9 @@ function createMostVisitedLink(params, href, title, text, direction, provider) { ...@@ -156,6 +156,9 @@ function createMostVisitedLink(params, href, title, text, direction, provider) {
} }
// Else follow <a> normally, so transition type would be LINK. // Else follow <a> normally, so transition type would be LINK.
}); });
link.addEventListener('mousedown', function(e) {
e.preventDefault(); // Prevent drag-select.
});
return link; return link;
} }
...@@ -163,11 +166,11 @@ function createMostVisitedLink(params, href, title, text, direction, provider) { ...@@ -163,11 +166,11 @@ function createMostVisitedLink(params, href, title, text, direction, provider) {
/** /**
* Decodes most visited styles from URL parameters. * Decodes most visited styles from URL parameters.
* - c: A hexadecimal number interpreted as a hex color code.
* - f: font-family. * - f: font-family.
* - fs: font-size as a number in pixels. * - fs: font-size as a number in pixels.
* - ta: text-align property, as a string. * - ta: text-align property, as a string.
* - tf: specifying a text fade starting position, in pixels. * - tf: specifying a text fade starting position, in pixels.
* - c: A hexadecimal number interpreted as a hex color code.
* @param {Object.<string, string>} params URL parameters specifying style. * @param {Object.<string, string>} params URL parameters specifying style.
* @param {boolean} isTitle if the style is for the Most Visited Title. * @param {boolean} isTitle if the style is for the Most Visited Title.
* @return {Object} Styles suitable for CSS interpolation. * @return {Object} Styles suitable for CSS interpolation.
......
...@@ -36,7 +36,8 @@ namespace { ...@@ -36,7 +36,8 @@ namespace {
const char kMaterialDesignNTPFieldTrialName[] = "MaterialDesignNTP"; const char kMaterialDesignNTPFieldTrialName[] = "MaterialDesignNTP";
const char kMaterialDesignNTPFieldTrialEnabledPrefix[] = "Enabled"; const char kMaterialDesignNTPFieldTrialEnabledPrefix[] = "Enabled";
// Name to be used for the new design in local resources. // Names of NTP designs in local resources, also used in CSS.
const char kClassicalNTPName[] = "classical";
const char kMaterialDesignNTPName[] = "md"; const char kMaterialDesignNTPName[] = "md";
// Signifies a locally constructed resource, i.e. not from grit/. // Signifies a locally constructed resource, i.e. not from grit/.
...@@ -188,7 +189,7 @@ void LocalNtpSource::StartDataRequest( ...@@ -188,7 +189,7 @@ void LocalNtpSource::StartDataRequest(
if (stripped_path == kLocalNTPFilename) { if (stripped_path == kLocalNTPFilename) {
SendResourceWithClass( SendResourceWithClass(
IDR_LOCAL_NTP_HTML, IDR_LOCAL_NTP_HTML,
IsMaterialDesignEnabled() ? kMaterialDesignNTPName : "", IsMaterialDesignEnabled() ? kMaterialDesignNTPName : kClassicalNTPName,
callback); callback);
return; return;
} }
......
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