Commit d1420ce2 authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

Revert "[NTP] Remove UI MD flag"

This reverts commit 5d112920.

Reason for revert: Broke old UI and we probably won't be able to
completely remove the old UI in M71.

Original change's description:
> [NTP] Remove UI MD flag
> 
> Remove flag for ntp md ui. Change the new styling to be the
> default and remove the md class, this mainly affects the fakebox
> as the icons are styled via md-icons.
> 
> Bug: 864673
> Change-Id: I7eb5da522a657417c527e3aa666bab14f8485bef
> Reviewed-on: https://chromium-review.googlesource.com/1255600
> Reviewed-by: Ilya Sherman <isherman@chromium.org>
> Reviewed-by: Kristi Park <kristipark@chromium.org>
> Commit-Queue: Kyle Milka <kmilka@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#595953}

TBR=isherman@chromium.org,kristipark@chromium.org,kmilka@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 864673
Change-Id: I5ef13705787953e96b7e4b0ead21e1e8aeb558d1
Reviewed-on: https://chromium-review.googlesource.com/c/1265024Reviewed-by: default avatarKyle Milka <kmilka@chromium.org>
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597206}
parent 2915e022
...@@ -4101,6 +4101,10 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -4101,6 +4101,10 @@ const FeatureEntry kFeatureEntries[] = {
{"ntp-icons", flag_descriptions::kNtpIconsName, {"ntp-icons", flag_descriptions::kNtpIconsName,
flag_descriptions::kNtpIconsDescription, kOsDesktop, flag_descriptions::kNtpIconsDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kNtpIcons)}, FEATURE_VALUE_TYPE(features::kNtpIcons)},
{"ntp-ui-md", flag_descriptions::kNtpUIMdName,
flag_descriptions::kNtpUIMdDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kNtpUIMd)},
#endif // OS_WIN || OS_MACOSX || OS_LINUX #endif // OS_WIN || OS_MACOSX || OS_LINUX
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
......
...@@ -1233,6 +1233,10 @@ const char kNtpIconsDescription[] = ...@@ -1233,6 +1233,10 @@ const char kNtpIconsDescription[] =
"Show Material Design icons on the New Tab Page, instead of Most Visited " "Show Material Design icons on the New Tab Page, instead of Most Visited "
"tiles. Implicitly enables 'ntp-ui-md'."; "tiles. Implicitly enables 'ntp-ui-md'.";
const char kNtpUIMdName[] = "New Tab Page Material Design UI";
const char kNtpUIMdDescription[] =
"Updates the New Tab Page with Material Design elements.";
const char kNumRasterThreadsName[] = "Number of raster threads"; const char kNumRasterThreadsName[] = "Number of raster threads";
const char kNumRasterThreadsDescription[] = const char kNumRasterThreadsDescription[] =
"Specify the number of raster threads."; "Specify the number of raster threads.";
......
...@@ -770,6 +770,9 @@ extern const char kNtpCustomLinksDescription[]; ...@@ -770,6 +770,9 @@ extern const char kNtpCustomLinksDescription[];
extern const char kNtpIconsName[]; extern const char kNtpIconsName[];
extern const char kNtpIconsDescription[]; extern const char kNtpIconsDescription[];
extern const char kNtpUIMdName[];
extern const char kNtpUIMdDescription[];
extern const char kNumRasterThreadsName[]; extern const char kNumRasterThreadsName[];
extern const char kNumRasterThreadsDescription[]; extern const char kNumRasterThreadsDescription[];
extern const char kNumRasterThreadsOne[]; extern const char kNumRasterThreadsOne[];
......
...@@ -292,22 +292,32 @@ body.alternate-logo #logo-non-white { ...@@ -292,22 +292,32 @@ body.alternate-logo #logo-non-white {
} }
#fakebox { #fakebox {
background-color: rgb(241, 243, 244); background-color: #fff;
border-radius: 22px; border-radius: 2px;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08);
cursor: text; cursor: text;
font-size: 18px; font-size: 18px;
height: 44px; height: 44px;
line-height: 36px; line-height: 36px;
margin: 0 calc(var(--tile-margin) / 2 + 1px) 0 calc(var(--tile-margin) / 2);
outline: none;
position: relative;
transition: box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1);
}
.md #fakebox {
background-color: rgb(241, 243, 244);
border-radius: 22px;
box-shadow: none;
margin: 0 auto; margin: 0 auto;
max-width: 560px; max-width: 560px;
opacity: 1; opacity: 1;
position: relative;
transition: background-color 300ms ease-in-out; transition: background-color 300ms ease-in-out;
/* Transition should be similar to .mv-tile/.md-tile opacity transition. */ /* Transition should be similar to .mv-tile/.md-tile opacity transition. */
transition: opacity 200ms; transition: opacity 200ms;
} }
#fakebox:hover { .md #fakebox:hover {
background-color: rgb(232, 234, 237); background-color: rgb(232, 234, 237);
} }
...@@ -315,33 +325,50 @@ body.alternate-logo #logo-non-white { ...@@ -315,33 +325,50 @@ body.alternate-logo #logo-non-white {
display: none; display: none;
} }
#fakebox:hover,
body.fakebox-focused #fakebox {
box-shadow: 0 3px 8px 0 rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.md #fakebox:hover,
body.md.fakebox-focused #fakebox {
box-shadow: none;
}
#fakebox > input { #fakebox > input {
bottom: 0; bottom: 0;
box-sizing: border-box; box-sizing: border-box;
left: 0; left: 0;
margin: 0; margin: 0;
opacity: 0; opacity: 0;
padding-left: 20px; padding-left: 8px;
position: absolute; position: absolute;
top: 0; top: 0;
width: 100%; width: 100%;
} }
.md #fakebox > input {
padding-left: 20px;
}
html[dir=rtl] #fakebox > input { html[dir=rtl] #fakebox > input {
padding-left: 0; padding-left: 0;
padding-right: 20px; padding-right: 8px;
right: 0; right: 0;
} }
html[dir=rtl] .md #fakebox > input {
padding-right: 20px;
}
#fakebox-text { #fakebox-text {
bottom: 4px; bottom: 4px;
color: rgb(128, 134, 139); color: rgba(0, 0, 0, 0.42);
font-family: 'Roboto', arial, sans-serif; font-family: arial, sans-serif;
font-size: 14px; font-size: 16px;
left: 0; left: 13px;
margin-top: 1px; margin-top: 1px;
overflow: hidden; overflow: hidden;
padding-left: 20px;
position: absolute; position: absolute;
right: 13px; right: 13px;
text-align: initial; text-align: initial;
...@@ -352,7 +379,20 @@ html[dir=rtl] #fakebox > input { ...@@ -352,7 +379,20 @@ html[dir=rtl] #fakebox > input {
white-space: nowrap; white-space: nowrap;
} }
.md #fakebox-text {
color: rgb(128, 134, 139);
font-family: 'Roboto', arial, sans-serif;
font-size: 14px;
left: 0;
padding-left: 20px;
}
html[dir=rtl] #fakebox-text { html[dir=rtl] #fakebox-text {
left: auto;
right: 13px;
}
html[dir=rtl] .md #fakebox-text {
padding-right: 20px; padding-right: 20px;
right: 0; right: 0;
} }
...@@ -360,15 +400,23 @@ html[dir=rtl] #fakebox-text { ...@@ -360,15 +400,23 @@ html[dir=rtl] #fakebox-text {
#fakebox-cursor { #fakebox-cursor {
background: #333; background: #333;
bottom: 12px; bottom: 12px;
left: 20px; left: 13px;
position: absolute; position: absolute;
top: 12px; top: 12px;
visibility: hidden; visibility: hidden;
width: 1px; width: 1px;
} }
.md #fakebox-cursor {
left: 20px;
}
html[dir=rtl] #fakebox-cursor { html[dir=rtl] #fakebox-cursor {
left: auto; left: auto;
right: 13px;
}
html[dir=rtl] .md #fakebox-cursor {
right: 20px; right: 20px;
} }
...@@ -377,20 +425,27 @@ html[dir=rtl] #fakebox-cursor { ...@@ -377,20 +425,27 @@ html[dir=rtl] #fakebox-cursor {
background-size: 24px 24px; background-size: 24px 24px;
bottom: 0; bottom: 0;
cursor: pointer; cursor: pointer;
margin-right: 12px;
padding: 22px 12px 0; padding: 22px 12px 0;
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
width: 41px;
}
.md #fakebox-microphone {
margin-right: 12px;
width: 28px; width: 28px;
} }
html[dir=rtl] #fakebox-microphone { html[dir=rtl] #fakebox-microphone {
left: 0; left: 0;
margin-left: 12px;
right: auto; right: auto;
} }
html[dir=rtl] .md #fakebox-microphone {
margin-left: 12px;
}
@keyframes blink { @keyframes blink {
0% { 0% {
opacity: 1; opacity: 1;
......
...@@ -111,6 +111,7 @@ var CLASSES = { ...@@ -111,6 +111,7 @@ var CLASSES = {
HIDE_NOTIFICATION: 'notice-hide', HIDE_NOTIFICATION: 'notice-hide',
INITED: 'inited', // Reveals the <body> once init() is done. INITED: 'inited', // Reveals the <body> once init() is done.
LEFT_ALIGN_ATTRIBUTION: 'left-align-attribution', LEFT_ALIGN_ATTRIBUTION: 'left-align-attribution',
MATERIAL_DESIGN: 'md', // Applies Material Design styles to the page
MATERIAL_DESIGN_ICONS: MATERIAL_DESIGN_ICONS:
'md-icons', // Applies Material Design styles to Most Visited. 'md-icons', // Applies Material Design styles to Most Visited.
// Vertically centers the most visited section for a non-Google provided page. // Vertically centers the most visited section for a non-Google provided page.
...@@ -938,9 +939,19 @@ function handlePostMessage(event) { ...@@ -938,9 +939,19 @@ function handlePostMessage(event) {
function enableMDIcons() { function enableMDIcons() {
$(IDS.MOST_VISITED).classList.add(CLASSES.MATERIAL_DESIGN_ICONS); $(IDS.MOST_VISITED).classList.add(CLASSES.MATERIAL_DESIGN_ICONS);
$(IDS.TILES).classList.add(CLASSES.MATERIAL_DESIGN_ICONS); $(IDS.TILES).classList.add(CLASSES.MATERIAL_DESIGN_ICONS);
enableMD();
addRippleAnimations(); addRippleAnimations();
} }
/**
* Enables Material Design styles for all NTP components except Most Visited.
*/
function enableMD() {
document.body.classList.add(CLASSES.MATERIAL_DESIGN);
}
/** /**
* Enables ripple animations for elements with CLASSES.RIPPLE. The target * Enables ripple animations for elements with CLASSES.RIPPLE. The target
* element must have position relative or absolute. * element must have position relative or absolute.
...@@ -1080,6 +1091,8 @@ function init() { ...@@ -1080,6 +1091,8 @@ function init() {
if (configData.isGooglePage) { if (configData.isGooglePage) {
if (configData.isMDIconsEnabled || configData.isCustomLinksEnabled) { if (configData.isMDIconsEnabled || configData.isCustomLinksEnabled) {
enableMDIcons(); enableMDIcons();
} else if (configData.isMDUIEnabled) {
enableMD();
} }
if (configData.isCustomLinksEnabled) { if (configData.isCustomLinksEnabled) {
......
...@@ -53,19 +53,36 @@ a:visited { ...@@ -53,19 +53,36 @@ a:visited {
} }
#most-visited { #most-visited {
margin: 10px 0; margin: 0;
text-align: -webkit-center; text-align: -webkit-center;
user-select: none; user-select: none;
}
.md #most-visited {
margin: 10px 0;
width: 100% width: 100%
} }
#mv-tiles { #mv-tiles,
display: flex; .mv-tiles-old {
flex-wrap: wrap;
font-size: 0; font-size: 0;
/* Two rows of tiles of 128px each, and 16px of spacing between the rows. /* Two rows of tiles of 128px each, and 16px of spacing between the rows.
* If you change this, also change the corresponding values in * If you change this, also change the corresponding values in
* local_ntp.css. */ * local_ntp.css. */
height: calc(2*var(--tile-height) + var(--tile-margin));
line-height: calc(var(--tile-height) + var(--tile-margin));
margin: 4px 0 8px 0;
opacity: 0;
position: absolute;
/* This align correctly for both LTR and RTL */
text-align: -webkit-auto;
transition: opacity 1s;
user-select: none;
}
.md #mv-tiles {
display: flex;
flex-wrap: wrap;
height: auto; height: auto;
justify-content: center; justify-content: center;
line-height: normal; line-height: normal;
...@@ -73,15 +90,10 @@ a:visited { ...@@ -73,15 +90,10 @@ a:visited {
/* 5 88px tiles per row. If you change this, also change the corresponding /* 5 88px tiles per row. If you change this, also change the corresponding
* values in local_ntp.css. */ * values in local_ntp.css. */
max-width: calc(var(--md-tile-width) * var(--md-max-tiles-row)); max-width: calc(var(--md-tile-width) * var(--md-max-tiles-row));
opacity: 0;
position: static; position: static;
/* This align correctly for both LTR and RTL */
text-align: -webkit-auto;
transition: opacity 1s;
user-select: none;
} }
.mv-tiles-old { .md .mv-tiles-old {
display: none; display: none;
} }
......
...@@ -43,6 +43,7 @@ const IDS = { ...@@ -43,6 +43,7 @@ const IDS = {
const CLASSES = { const CLASSES = {
FAILED_FAVICON: 'failed-favicon', // Applied when the favicon fails to load. FAILED_FAVICON: 'failed-favicon', // Applied when the favicon fails to load.
// Material Design classes. // Material Design classes.
MATERIAL_DESIGN: 'md', // Applies Material Design styles to the page.
MD_EMPTY_TILE: 'md-empty-tile', MD_EMPTY_TILE: 'md-empty-tile',
MD_FALLBACK_BACKGROUND: 'md-fallback-background', MD_FALLBACK_BACKGROUND: 'md-fallback-background',
MD_FALLBACK_LETTER: 'md-fallback-letter', MD_FALLBACK_LETTER: 'md-fallback-letter',
...@@ -975,6 +976,7 @@ var init = function() { ...@@ -975,6 +976,7 @@ var init = function() {
// Enable Material Design. // Enable Material Design.
if (queryArgs['enableMD'] == '1') { if (queryArgs['enableMD'] == '1') {
isMDEnabled = true; isMDEnabled = true;
document.body.classList.add(CLASSES.MATERIAL_DESIGN);
} }
// Enable custom links. // Enable custom links.
......
...@@ -152,7 +152,8 @@ std::unique_ptr<base::DictionaryValue> GetTranslatedStrings(bool is_google) { ...@@ -152,7 +152,8 @@ std::unique_ptr<base::DictionaryValue> GetTranslatedStrings(bool is_google) {
if (is_google) { if (is_google) {
AddString(translated_strings.get(), "searchboxPlaceholder", AddString(translated_strings.get(), "searchboxPlaceholder",
IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT_MD); features::IsMDUIEnabled() ? IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT_MD
: IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT);
// Custom Backgrounds // Custom Backgrounds
AddString(translated_strings.get(), "customizeBackground", AddString(translated_strings.get(), "customizeBackground",
...@@ -504,6 +505,8 @@ class LocalNtpSource::SearchConfigurationProvider ...@@ -504,6 +505,8 @@ class LocalNtpSource::SearchConfigurationProvider
content::BrowserAccessibilityState::GetInstance() content::BrowserAccessibilityState::GetInstance()
->IsAccessibleBrowser()); ->IsAccessibleBrowser());
config_data.SetBoolean("isMDUIEnabled", features::IsMDUIEnabled());
config_data.SetBoolean("isMDIconsEnabled", features::IsMDIconsEnabled()); config_data.SetBoolean("isMDIconsEnabled", features::IsMDIconsEnabled());
if (is_google) { if (is_google) {
......
...@@ -11,15 +11,20 @@ ...@@ -11,15 +11,20 @@
namespace features { namespace features {
// If enabled, the user will see a configuration UI, and be able to select // If enabled, the user will see a configuration UI, and be able to select
// background images to set on the New Tab Page. // background images to set on the New Tab Page. Implicitly enables |kNtpIcons|.
const base::Feature kNtpBackgrounds{"NewTabPageBackgrounds", const base::Feature kNtpBackgrounds{"NewTabPageBackgrounds",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the user will see the Most Visited tiles updated with Material // If enabled, the user will see the Most Visited tiles updated with Material
// Design elements. // Design elements. Implicitly enables |kNtpUIMd|.
const base::Feature kNtpIcons{"NewTabPageIcons", const base::Feature kNtpIcons{"NewTabPageIcons",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the user will see the New Tab Page updated with Material Design
// elements.
const base::Feature kNtpUIMd{"NewTabPageUIMd",
base::FEATURE_DISABLED_BY_DEFAULT};
bool IsCustomLinksEnabled() { bool IsCustomLinksEnabled() {
return ntp_tiles::IsCustomLinksEnabled(); return ntp_tiles::IsCustomLinksEnabled();
} }
...@@ -36,4 +41,14 @@ bool IsMDIconsEnabled() { ...@@ -36,4 +41,14 @@ bool IsMDIconsEnabled() {
base::FeatureList::IsEnabled(features::kExperimentalUi); base::FeatureList::IsEnabled(features::kExperimentalUi);
} }
bool IsMDUIEnabled() {
return base::FeatureList::IsEnabled(kNtpUIMd) ||
// MD UI changes are implicitly enabled if Material Design icons,
// custom link, or custom backgrounds are enabled.
base::FeatureList::IsEnabled(kNtpIcons) ||
base::FeatureList::IsEnabled(kNtpBackgrounds) ||
base::FeatureList::IsEnabled(ntp_tiles::kNtpCustomLinks) ||
base::FeatureList::IsEnabled(features::kExperimentalUi);
}
} // namespace features } // namespace features
...@@ -14,6 +14,7 @@ namespace features { ...@@ -14,6 +14,7 @@ namespace features {
extern const base::Feature kNtpBackgrounds; extern const base::Feature kNtpBackgrounds;
extern const base::Feature kNtpIcons; extern const base::Feature kNtpIcons;
extern const base::Feature kNtpUIMd;
// Returns whether New Tab Page custom links are enabled. // Returns whether New Tab Page custom links are enabled.
bool IsCustomLinksEnabled(); bool IsCustomLinksEnabled();
...@@ -24,6 +25,9 @@ bool IsCustomBackgroundsEnabled(); ...@@ -24,6 +25,9 @@ bool IsCustomBackgroundsEnabled();
// Returns whether the Material Design UI for Most Visited is enabled. // Returns whether the Material Design UI for Most Visited is enabled.
bool IsMDIconsEnabled(); bool IsMDIconsEnabled();
// Returns whether the Material Design UI is enabled on the New Tab Page.
bool IsMDUIEnabled();
} // namespace features } // namespace features
#endif // CHROME_BROWSER_SEARCH_NTP_FEATURES_H_ #endif // CHROME_BROWSER_SEARCH_NTP_FEATURES_H_
...@@ -602,7 +602,7 @@ class LocalNTPCustomLinksTest : public LocalNTPTest { ...@@ -602,7 +602,7 @@ class LocalNTPCustomLinksTest : public LocalNTPTest {
LocalNTPCustomLinksTest() LocalNTPCustomLinksTest()
: LocalNTPTest( : LocalNTPTest(
/*enabled_features=*/{features::kUseGoogleLocalNtp, /*enabled_features=*/{features::kUseGoogleLocalNtp,
features::kNtpIcons, features::kNtpUIMd, features::kNtpIcons,
ntp_tiles::kNtpCustomLinks}, ntp_tiles::kNtpCustomLinks},
/*disabled_features=*/{}) {} /*disabled_features=*/{}) {}
...@@ -768,9 +768,9 @@ class LocalNTPNonMDTest : public LocalNTPTest { ...@@ -768,9 +768,9 @@ class LocalNTPNonMDTest : public LocalNTPTest {
LocalNTPNonMDTest() LocalNTPNonMDTest()
: LocalNTPTest( : LocalNTPTest(
/*enabled_features=*/{features::kUseGoogleLocalNtp}, /*enabled_features=*/{features::kUseGoogleLocalNtp},
/*disabled_features=*/{features::kNtpBackgrounds, /*disabled_features=*/{
features::kNtpIcons, features::kNtpUIMd, features::kNtpBackgrounds,
ntp_tiles::kNtpCustomLinks}) {} features::kNtpIcons, ntp_tiles::kNtpCustomLinks}) {}
}; };
IN_PROC_BROWSER_TEST_F(LocalNTPNonMDTest, LoadsNonMDIframe) { IN_PROC_BROWSER_TEST_F(LocalNTPNonMDTest, LoadsNonMDIframe) {
......
...@@ -73,6 +73,32 @@ test.localNtp.testMostVisitedContents = function() { ...@@ -73,6 +73,32 @@ test.localNtp.testMostVisitedContents = function() {
window.chrome.embeddedSearch.newTabPage.mostVisited[0].rid)); window.chrome.embeddedSearch.newTabPage.mostVisited[0].rid));
}; };
/**
* Tests that the GM2 style is applied when the flag is enabled.
*/
test.localNtp.testMDApplied = function() {
// Turn off voice search to avoid reinitializing the speech object
configData.isVoiceSearchEnabled = false;
configData.isMDUIEnabled = true;
initLocalNTP(/*isGooglePage=*/true);
assertTrue(document.body.classList.contains('md'));
}
/**
* Tests that the GM2 style is not applied when the flag is disabled.
*/
test.localNtp.testMDNotApplied = function() {
// Turn off voice search to avoid reinitializing the speech object
configData.isVoiceSearchEnabled = false;
configData.isMDUIEnabled = false;
configData.isMDIconsEnabled = false;
configData.isCustomLinksEnabled = false;
initLocalNTP(/*isGooglePage=*/true);
assertFalse(document.body.classList.contains('md'));
}
// ****************************** ADVANCED TESTS ****************************** // ****************************** ADVANCED TESTS ******************************
// Advanced tests are controlled from the native side. The helpers here are // Advanced tests are controlled from the native side. The helpers here are
......
...@@ -2534,7 +2534,8 @@ ...@@ -2534,7 +2534,8 @@
"enable_features": [ "enable_features": [
"NewTabPageBackgrounds", "NewTabPageBackgrounds",
"NewTabPageCustomLinks", "NewTabPageCustomLinks",
"NewTabPageIcons" "NewTabPageIcons",
"NewTabPageUIMd"
] ]
} }
] ]
......
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