Commit 4734ca1a authored by John Lee's avatar John Lee Committed by Commit Bot

Tab Strip WebUI: Update tabs when blocked state changes

Bug: 1011064
Change-Id: If407517819759f380cd8fc2a2b74338f96902f0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1854821Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: John Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705643}
parent b79ec515
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
margin-inline-end: 8px; margin-inline-end: 8px;
margin-inline-start: 12px; margin-inline-start: 12px;
max-width: var(--favicon-size); max-width: var(--favicon-size);
overflow: hidden;
position: relative; position: relative;
/* When transitioning to the default visible state, the margin and max-width /* When transitioning to the default visible state, the margin and max-width
* transitions should finish first, then the opacity should be set to 1. * transitions should finish first, then the opacity should be set to 1.
...@@ -164,6 +163,10 @@ ...@@ -164,6 +163,10 @@
display: block; display: block;
} }
:host([active][blocked_]) #blocked {
display: none;
}
#titleText { #titleText {
font-size: 100%; font-size: 100%;
font-weight: normal; font-weight: normal;
......
...@@ -73,8 +73,8 @@ export class TabElement extends CustomElement { ...@@ -73,8 +73,8 @@ export class TabElement extends CustomElement {
'loading_', 'loading_',
!tab.shouldHideThrobber && !tab.shouldHideThrobber &&
tab.networkState === TabNetworkState.LOADING); tab.networkState === TabNetworkState.LOADING);
this.toggleAttribute('pinned_', tab.pinned); this.toggleAttribute('pinned_', tab.pinned);
this.toggleAttribute('blocked_', tab.blocked);
this.setAttribute('draggable', tab.pinned); this.setAttribute('draggable', tab.pinned);
this.toggleAttribute('crashed', tab.crashed); this.toggleAttribute('crashed', tab.crashed);
......
...@@ -19,6 +19,7 @@ export const TabNetworkState = { ...@@ -19,6 +19,7 @@ export const TabNetworkState = {
/** /**
* @typedef {{ * @typedef {{
* active: boolean, * active: boolean,
* blocked: boolean,
* crashed: boolean, * crashed: boolean,
* favIconUrl: (string|undefined), * favIconUrl: (string|undefined),
* id: number, * id: number,
......
...@@ -184,6 +184,11 @@ class TabStripUIHandler : public content::WebUIMessageHandler, ...@@ -184,6 +184,11 @@ class TabStripUIHandler : public content::WebUIMessageHandler,
FireWebUIListener("tab-updated", GetTabData(contents, index)); FireWebUIListener("tab-updated", GetTabData(contents, index));
} }
void TabBlockedStateChanged(content::WebContents* contents,
int index) override {
FireWebUIListener("tab-updated", GetTabData(contents, index));
}
protected: protected:
// content::WebUIMessageHandler: // content::WebUIMessageHandler:
void RegisterMessages() override { void RegisterMessages() override {
...@@ -235,6 +240,7 @@ class TabStripUIHandler : public content::WebUIMessageHandler, ...@@ -235,6 +240,7 @@ class TabStripUIHandler : public content::WebUIMessageHandler,
static_cast<int>(tab_renderer_data.network_state)); static_cast<int>(tab_renderer_data.network_state));
tab_data.SetBoolean("shouldHideThrobber", tab_data.SetBoolean("shouldHideThrobber",
tab_renderer_data.should_hide_throbber); tab_renderer_data.should_hide_throbber);
tab_data.SetBoolean("blocked", tab_renderer_data.blocked);
tab_data.SetBoolean("crashed", tab_renderer_data.IsCrashed()); tab_data.SetBoolean("crashed", tab_renderer_data.IsCrashed());
// TODO(johntlee): Add the rest of TabRendererData // TODO(johntlee): Add the rest of TabRendererData
...@@ -292,6 +298,10 @@ class TabStripUIHandler : public content::WebUIMessageHandler, ...@@ -292,6 +298,10 @@ class TabStripUIHandler : public content::WebUIMessageHandler,
colors.SetString("--tabstrip-indicator-capturing-color", colors.SetString("--tabstrip-indicator-capturing-color",
color_utils::SkColorToRgbaString(tp.GetColor( color_utils::SkColorToRgbaString(tp.GetColor(
ThemeProperties::COLOR_TAB_ALERT_CAPTURING))); ThemeProperties::COLOR_TAB_ALERT_CAPTURING)));
colors.SetString("--tabstrip-tab-blocked-color",
color_utils::SkColorToRgbaString(
ui::NativeTheme::GetInstanceForWeb()->GetSystemColor(
ui::NativeTheme::kColorId_ProminentButtonColor)));
ResolveJavascriptCallback(callback_id, colors); ResolveJavascriptCallback(callback_id, colors);
} }
......
...@@ -59,7 +59,8 @@ suite('Tab', function() { ...@@ -59,7 +59,8 @@ suite('Tab', function() {
}); });
test( test(
'toggles a [hide-icon] attribute when the icon container should be shown', 'toggles a [hide-icon_] attribute when the icon container should be ' +
'shown',
() => { () => {
tabElement.tab = Object.assign({}, tab, {showIcon: true}); tabElement.tab = Object.assign({}, tab, {showIcon: true});
assertFalse(tabElement.hasAttribute('hide-icon_')); assertFalse(tabElement.hasAttribute('hide-icon_'));
...@@ -67,14 +68,14 @@ suite('Tab', function() { ...@@ -67,14 +68,14 @@ suite('Tab', function() {
assertTrue(tabElement.hasAttribute('hide-icon_')); assertTrue(tabElement.hasAttribute('hide-icon_'));
}); });
test('toggles a [pinned] attribute when pinned', () => { test('toggles a [pinned_] attribute when pinned', () => {
tabElement.tab = Object.assign({}, tab, {pinned: true}); tabElement.tab = Object.assign({}, tab, {pinned: true});
assertTrue(tabElement.hasAttribute('pinned_')); assertTrue(tabElement.hasAttribute('pinned_'));
tabElement.tab = Object.assign({}, tab, {pinned: false}); tabElement.tab = Object.assign({}, tab, {pinned: false});
assertFalse(tabElement.hasAttribute('pinned_')); assertFalse(tabElement.hasAttribute('pinned_'));
}); });
test('toggles a [loading] attribute when loading', () => { test('toggles a [loading_] attribute when loading', () => {
tabElement.tab = tabElement.tab =
Object.assign({}, tab, {networkState: TabNetworkState.LOADING}); Object.assign({}, tab, {networkState: TabNetworkState.LOADING});
assertTrue(tabElement.hasAttribute('loading_')); assertTrue(tabElement.hasAttribute('loading_'));
...@@ -83,7 +84,7 @@ suite('Tab', function() { ...@@ -83,7 +84,7 @@ suite('Tab', function() {
assertFalse(tabElement.hasAttribute('loading_')); assertFalse(tabElement.hasAttribute('loading_'));
}); });
test('toggles a [waiting] attribute when waiting', () => { test('toggles a [waiting_] attribute when waiting', () => {
tabElement.tab = tabElement.tab =
Object.assign({}, tab, {networkState: TabNetworkState.WAITING}); Object.assign({}, tab, {networkState: TabNetworkState.WAITING});
assertTrue(tabElement.hasAttribute('waiting_')); assertTrue(tabElement.hasAttribute('waiting_'));
...@@ -92,6 +93,13 @@ suite('Tab', function() { ...@@ -92,6 +93,13 @@ suite('Tab', function() {
assertFalse(tabElement.hasAttribute('waiting_')); assertFalse(tabElement.hasAttribute('waiting_'));
}); });
test('toggles a [blocked_] attribute when blocked', () => {
tabElement.tab = Object.assign({}, tab, {blocked: true});
assertTrue(tabElement.hasAttribute('blocked_'));
tabElement.tab = Object.assign({}, tab, {blocked: false});
assertFalse(tabElement.hasAttribute('blocked_'));
});
test('toggles a [crashed] attribute when crashed', () => { test('toggles a [crashed] attribute when crashed', () => {
tabElement.tab = Object.assign({}, tab, {crashed: true}); tabElement.tab = Object.assign({}, tab, {crashed: true});
assertTrue(tabElement.hasAttribute('crashed')); assertTrue(tabElement.hasAttribute('crashed'));
......
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