Commit f09b8981 authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Refactor FrameHeaderOriginText to be reusable by GlassBrowserFrameView

This CL:
 - Renames FrameHeaderOriginText to HostedAppOriginText as it's not
   intended to be used for anything other than hosted app windows
   and for consistency with other HostedApp* views.
 - Moves HostedAppOriginText from ash/frame to
   chrome/browser/ui/views/frame.
 - Moves the animation timing logic from BrowserNonClientFrameViewAsh
   into HostedAppButtonContainer.

This is in preparation to add the origin text animation to
GlassBrowserFrameView (see https://chromium-review.googlesource.com/c/chromium/src/+/1136270).
There are no behavioural changes in this CL.

Bug: 854479
Change-Id: I69934e5b4595356d10e707011a231f9c095338db
Reviewed-on: https://chromium-review.googlesource.com/1134713
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577445}
parent 39ba6f46
......@@ -282,8 +282,6 @@ component("ash") {
"frame/frame_border_hit_test.h",
"frame/frame_header.cc",
"frame/frame_header.h",
"frame/frame_header_origin_text.cc",
"frame/frame_header_origin_text.h",
"frame/frame_header_util.cc",
"frame/frame_header_util.h",
"frame/header_view.cc",
......
......@@ -3212,6 +3212,8 @@ jumbo_split_static_library("ui") {
"views/frame/hosted_app_button_container.h",
"views/frame/hosted_app_menu_button.cc",
"views/frame/hosted_app_menu_button.h",
"views/frame/hosted_app_origin_text.cc",
"views/frame/hosted_app_origin_text.h",
"views/frame/immersive_mode_controller.cc",
"views/frame/immersive_mode_controller.h",
"views/frame/immersive_mode_controller_factory_views.cc",
......
......@@ -10,7 +10,6 @@
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h" // mash-ok
#include "ash/frame/default_frame_header.h" // mash-ok
#include "ash/frame/frame_border_hit_test.h" // mash-ok
#include "ash/frame/frame_header_origin_text.h" // mash-ok
#include "ash/frame/frame_header_util.h" // mash-ok
#include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/app_types.h"
......@@ -25,9 +24,6 @@
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/time/time.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
......@@ -39,6 +35,7 @@
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/hosted_app_button_container.h"
#include "chrome/browser/ui/views/frame/hosted_app_origin_text.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/browser/ui/views/profiles/profile_indicator_icon.h"
......@@ -133,9 +130,6 @@ int GetControlButtonSpacing() {
///////////////////////////////////////////////////////////////////////////////
// BrowserNonClientFrameViewAsh, public:
const base::TimeDelta BrowserNonClientFrameViewAsh::kTitlebarAnimationDelay =
base::TimeDelta::FromMilliseconds(750);
BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh(
BrowserFrame* frame,
BrowserView* browser_view)
......@@ -523,8 +517,8 @@ void BrowserNonClientFrameViewAsh::ActivationChanged(bool active) {
if (hosted_app_button_container_)
hosted_app_button_container_->SetPaintAsActive(should_paint_as_active);
if (frame_header_origin_text_)
frame_header_origin_text_->SetPaintAsActive(should_paint_as_active);
if (hosted_app_origin_text_)
hosted_app_origin_text_->SetPaintAsActive(should_paint_as_active);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -596,11 +590,11 @@ void BrowserNonClientFrameViewAsh::Layout() {
(tab_strip_visible || immersive) ? 0 : GetTopInset(/*restored=*/false);
frame()->GetNativeWindow()->SetProperty(aura::client::kTopViewInset, inset);
if (frame_header_origin_text_) {
if (hosted_app_origin_text_) {
// Align the right side of the text with the left side of the caption
// buttons.
gfx::Size origin_text_preferred_size =
frame_header_origin_text_->GetPreferredSize();
hosted_app_origin_text_->GetPreferredSize();
int origin_text_width =
std::min(width() - caption_button_container_->width(),
origin_text_preferred_size.width());
......@@ -608,7 +602,7 @@ void BrowserNonClientFrameViewAsh::Layout() {
origin_text_preferred_size.height());
SetRightSide(&text_bounds, caption_button_container_->x());
AlignVerticalCenterWith(&text_bounds, caption_button_container_->bounds());
frame_header_origin_text_->SetBoundsRect(text_bounds);
hosted_app_origin_text_->SetBoundsRect(text_bounds);
}
// The top right corner must be occupied by a caption button for easy mouse
......@@ -1020,17 +1014,17 @@ void BrowserNonClientFrameViewAsh::SetUpForHostedApp(
ash::FrameCaptionButton::ColorMode::kThemed, *theme_color);
}
// Add the container for extra hosted app buttons (e.g app menu button).
// Add the origin text.
const float inactive_alpha_ratio =
ash::FrameCaptionButton::GetInactiveButtonColorAlphaRatio();
SkColor inactive_color =
SkColorSetA(active_color, 255 * inactive_alpha_ratio);
hosted_app_button_container_ = new HostedAppButtonContainer(
browser_view(), active_color, inactive_color);
hosted_app_origin_text_ =
new HostedAppOriginText(browser, active_color, inactive_color);
// Add the origin text.
frame_header_origin_text_ = new ash::FrameHeaderOriginText(
browser->hosted_app_controller()->GetFormattedUrlOrigin(), active_color,
// Add the container for extra hosted app buttons (e.g app menu button).
hosted_app_button_container_ = new HostedAppButtonContainer(
frame(), browser_view(), hosted_app_origin_text_, active_color,
inactive_color);
if (IsMash()) {
......@@ -1044,25 +1038,12 @@ void BrowserNonClientFrameViewAsh::SetUpForHostedApp(
hosted_app_extras_container_->SetLayoutManager(std::move(layout));
AddChildView(hosted_app_extras_container_);
hosted_app_extras_container_->AddChildView(frame_header_origin_text_);
hosted_app_extras_container_->AddChildView(hosted_app_origin_text_);
hosted_app_extras_container_->AddChildView(hosted_app_button_container_);
} else {
caption_button_container_->AddChildViewAt(hosted_app_button_container_, 0);
AddChildView(frame_header_origin_text_);
AddChildView(hosted_app_origin_text_);
}
// Schedule the title bar animation.
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&BrowserNonClientFrameViewAsh::StartHostedAppAnimation,
weak_factory_.GetWeakPtr()),
kTitlebarAnimationDelay);
}
void BrowserNonClientFrameViewAsh::StartHostedAppAnimation() {
frame_header_origin_text_->StartSlideAnimation();
hosted_app_button_container_->StartTitlebarAnimation(
frame_header_origin_text_->AnimationDuration());
}
void BrowserNonClientFrameViewAsh::UpdateFrameColors() {
......
......@@ -28,6 +28,7 @@ namespace {
class HostedAppNonClientFrameViewAshTest;
}
class HostedAppOriginText;
class HostedAppButtonContainer;
class TabIconView;
......@@ -35,7 +36,6 @@ namespace ash {
class DefaultFrameHeader;
class FrameCaptionButton;
class FrameCaptionButtonContainerView;
class FrameHeaderOriginText;
}
// Provides the BrowserNonClientFrameView for Chrome OS.
......@@ -50,9 +50,6 @@ class BrowserNonClientFrameViewAsh
public aura::WindowObserver,
public ImmersiveModeController::Observer {
public:
// How long to delay the hosted app origin text animation from starting.
static const base::TimeDelta kTitlebarAnimationDelay;
BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view);
~BrowserNonClientFrameViewAsh() override;
......@@ -216,10 +213,10 @@ class BrowserNonClientFrameViewAsh
// URL origin text for hosted app windows.
// Owned by views hierarchy.
ash::FrameHeaderOriginText* frame_header_origin_text_ = nullptr;
HostedAppOriginText* hosted_app_origin_text_ = nullptr;
// A view that contains the extra views used for hosted apps
// (|hosted_app_button_container_| and |frame_header_origin_text_|).
// (|hosted_app_button_container_| and |hosted_app_origin_text_|).
// Only used in Mash.
views::View* hosted_app_extras_container_ = nullptr;
......@@ -248,8 +245,6 @@ class BrowserNonClientFrameViewAsh
scoped_refptr<ImageRegistration> active_frame_overlay_image_registration_;
scoped_refptr<ImageRegistration> inactive_frame_overlay_image_registration_;
base::WeakPtrFactory<BrowserNonClientFrameViewAsh> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh);
};
......
......@@ -118,11 +118,10 @@ GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame,
// here and call it on demand in
// HostedAppButtonContainer::UpdateIconsColor() via a delegate interface.
hosted_app_button_container_ = new HostedAppButtonContainer(
browser_view, GetTitlebarFeatureColor(true),
frame, browser_view, nullptr, GetTitlebarFeatureColor(true),
GetTitlebarFeatureColor(false));
AddChildView(hosted_app_button_container_);
// TODO(https://crbug.com/854479): Add FrameHeaderOriginText animation here.
hosted_app_button_container_->StartTitlebarAnimation(base::TimeDelta());
}
minimize_button_ =
......
......@@ -5,12 +5,15 @@
#include "chrome/browser/ui/views/frame/hosted_app_button_container.h"
#include "base/metrics/histogram_macros.h"
#include "base/task_runner.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/hosted_app_menu_button.h"
#include "chrome/browser/ui/views/frame/hosted_app_origin_text.h"
#include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_container_view.h"
#include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
......@@ -65,6 +68,9 @@ int HorizontalPaddingBetweenItems() {
} // namespace
const base::TimeDelta HostedAppButtonContainer::kTitlebarAnimationDelay =
base::TimeDelta::FromMilliseconds(750);
class HostedAppButtonContainer::ContentSettingsContainer
: public views::View,
public ContentSettingImageView::Delegate {
......@@ -83,7 +89,16 @@ class HostedAppButtonContainer::ContentSettingsContainer
v->SetIconColor(icon_color);
}
void SetUpForFadeIn() {
SetVisible(false);
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
layer()->SetOpacity(0);
}
void FadeIn() {
if (visible())
return;
SetVisible(true);
DCHECK_EQ(layer()->opacity(), 0);
ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
......@@ -91,6 +106,12 @@ class HostedAppButtonContainer::ContentSettingsContainer
layer()->SetOpacity(1);
}
void EnsureVisible() {
SetVisible(true);
if (layer())
layer()->SetOpacity(1);
}
const std::vector<ContentSettingImageView*>&
GetContentSettingViewsForTesting() const {
return content_setting_views_;
......@@ -125,10 +146,6 @@ class HostedAppButtonContainer::ContentSettingsContainer
DISALLOW_COPY_AND_ASSIGN(ContentSettingsContainer);
};
void HostedAppButtonContainer::DisableAnimationForTesting() {
g_animation_disabled_for_testing = true;
}
views::View* HostedAppButtonContainer::GetContentSettingContainerForTesting() {
return content_settings_container_;
}
......@@ -150,13 +167,6 @@ HostedAppButtonContainer::ContentSettingsContainer::ContentSettingsContainer(
views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_RELATED_CONTROL_HORIZONTAL)));
if (!g_animation_disabled_for_testing) {
SetVisible(false);
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
layer()->SetOpacity(0);
}
std::vector<std::unique_ptr<ContentSettingImageModel>> models =
ContentSettingImageModel::GenerateContentSettingImageModels();
for (auto& model : models) {
......@@ -173,10 +183,15 @@ HostedAppButtonContainer::ContentSettingsContainer::ContentSettingsContainer(
}
}
HostedAppButtonContainer::HostedAppButtonContainer(BrowserView* browser_view,
HostedAppButtonContainer::HostedAppButtonContainer(
views::Widget* widget,
BrowserView* browser_view,
HostedAppOriginText* hosted_app_origin_text,
SkColor active_icon_color,
SkColor inactive_icon_color)
: browser_view_(browser_view),
: scoped_widget_observer_(this),
browser_view_(browser_view),
hosted_app_origin_text_(hosted_app_origin_text),
active_icon_color_(active_icon_color),
inactive_icon_color_(inactive_icon_color),
content_settings_container_(new ContentSettingsContainer(browser_view)),
......@@ -211,6 +226,7 @@ HostedAppButtonContainer::HostedAppButtonContainer(BrowserView* browser_view,
browser_view_->SetToolbarButtonProvider(this);
browser_view_->immersive_mode_controller()->AddObserver(this);
scoped_widget_observer_.Add(widget);
}
HostedAppButtonContainer::~HostedAppButtonContainer() {
......@@ -231,6 +247,31 @@ void HostedAppButtonContainer::SetPaintAsActive(bool active) {
UpdateIconsColor();
}
bool HostedAppButtonContainer::ShouldAnimate() const {
return !g_animation_disabled_for_testing && hosted_app_origin_text_ &&
!browser_view_->immersive_mode_controller()->IsEnabled();
}
void HostedAppButtonContainer::StartTitlebarAnimation() {
if (!ShouldAnimate())
return;
hosted_app_origin_text_->StartSlideAnimation();
app_menu_button_->StartHighlightAnimation(
HostedAppOriginText::AnimationDuration());
icon_fade_in_delay_.Start(
FROM_HERE, HostedAppOriginText::AnimationDuration(), this,
&HostedAppButtonContainer::FadeInContentSettingIcons);
}
void HostedAppButtonContainer::FadeInContentSettingIcons() {
content_settings_container_->FadeIn();
}
void HostedAppButtonContainer::DisableAnimationForTesting() {
g_animation_disabled_for_testing = true;
}
void HostedAppButtonContainer::UpdateIconsColor() {
SkColor icon_color =
paint_as_active_ ? active_icon_color_ : inactive_icon_color_;
......@@ -239,31 +280,14 @@ void HostedAppButtonContainer::UpdateIconsColor() {
app_menu_button_->SetIconColor(icon_color);
}
void HostedAppButtonContainer::StartTitlebarAnimation(
base::TimeDelta origin_text_slide_duration) {
if (g_animation_disabled_for_testing ||
browser_view_->immersive_mode_controller()->IsEnabled()) {
return;
}
app_menu_button_->StartHighlightAnimation(origin_text_slide_duration);
fade_in_content_setting_buttons_timer_.Start(
FROM_HERE, origin_text_slide_duration, content_settings_container_,
&ContentSettingsContainer::FadeIn);
}
void HostedAppButtonContainer::ChildPreferredSizeChanged(views::View* child) {
PreferredSizeChanged();
}
void HostedAppButtonContainer::OnImmersiveRevealStarted() {
// Cancel the content setting animation as icons need immediately show in
// immersive mode.
if (fade_in_content_setting_buttons_timer_.IsRunning()) {
fade_in_content_setting_buttons_timer_.AbandonAndStop();
content_settings_container_->SetVisible(true);
}
// Don't wait for the fade in animation to make content setting icons visible
// once in immersive mode.
content_settings_container_->EnsureVisible();
}
void HostedAppButtonContainer::ChildVisibilityChanged(views::View* child) {
......@@ -339,3 +363,16 @@ void HostedAppButtonContainer::FocusToolbar() {
views::AccessiblePaneView* HostedAppButtonContainer::GetAsAccessiblePaneView() {
return this;
}
void HostedAppButtonContainer::OnWidgetVisibilityChanged(views::Widget* widget,
bool visibility) {
if (!visibility || !pending_widget_visibility_)
return;
pending_widget_visibility_ = false;
if (ShouldAnimate()) {
content_settings_container_->SetUpForFadeIn();
animation_start_delay_.Start(
FROM_HERE, kTitlebarAnimationDelay, this,
&HostedAppButtonContainer::StartTitlebarAnimation);
}
}
......@@ -8,6 +8,9 @@
#include <memory>
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
#include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
......@@ -17,6 +20,7 @@
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget_observer.h"
namespace {
class HostedAppNonClientFrameViewAshTest;
......@@ -24,10 +28,12 @@ class HostedAppNonClientFrameViewAshTest;
class AppMenuButton;
class BrowserView;
class HostedAppOriginText;
class HostedAppMenuButton;
namespace views {
class MenuButton;
class Widget;
}
// A container for hosted app buttons in the title bar.
......@@ -35,11 +41,14 @@ class HostedAppButtonContainer : public views::AccessiblePaneView,
public BrowserActionsContainer::Delegate,
public PageActionIconView::Delegate,
public ToolbarButtonProvider,
public ImmersiveModeController::Observer {
public ImmersiveModeController::Observer,
public views::WidgetObserver {
public:
// |active_icon_color| and |inactive_icon_color| indicate the colors to use
// for button icons when the window is focused and blurred respectively.
HostedAppButtonContainer(BrowserView* browser_view,
HostedAppButtonContainer(views::Widget* widget,
BrowserView* browser_view,
HostedAppOriginText* hosted_app_origin_text,
SkColor active_icon_color,
SkColor inactive_icon_color);
~HostedAppButtonContainer() override;
......@@ -49,15 +58,19 @@ class HostedAppButtonContainer : public views::AccessiblePaneView,
// Sets the container to paints its buttons the active/inactive color.
void SetPaintAsActive(bool active);
// Animates the menu button and content setting icons. Intended to run in sync
// with a FrameHeaderOriginText slide animation.
void StartTitlebarAnimation(base::TimeDelta origin_text_slide_duration);
private:
friend class HostedAppNonClientFrameViewAshTest;
friend class HostedAppGlassBrowserFrameViewTest;
friend class ImmersiveModeControllerAshHostedAppBrowserTest;
// Duration to wait before starting the opening animation.
static const base::TimeDelta kTitlebarAnimationDelay;
// Methods for coordinate the titlebar animation (origin text slide, menu
// highlight and icon fade in).
bool ShouldAnimate() const;
void StartTitlebarAnimation();
void FadeInContentSettingIcons();
static void DisableAnimationForTesting();
class ContentSettingsContainer;
......@@ -67,8 +80,6 @@ class HostedAppButtonContainer : public views::AccessiblePaneView,
const std::vector<ContentSettingImageView*>&
GetContentSettingViewsForTesting() const;
void FadeInContentSettingButtons();
void UpdateIconsColor();
// views::View:
......@@ -98,24 +109,35 @@ class HostedAppButtonContainer : public views::AccessiblePaneView,
// ImmersiveModeController::Observer:
void OnImmersiveRevealStarted() override;
// views::WidgetObserver:
void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
// Whether we're waiting for the widget to become visible.
bool pending_widget_visibility_ = true;
ScopedObserver<views::Widget, views::WidgetObserver> scoped_widget_observer_;
// Timers for synchronising their respective parts of the titlebar animation.
base::OneShotTimer animation_start_delay_;
base::OneShotTimer icon_fade_in_delay_;
// The containing browser view.
BrowserView* browser_view_;
// The origin text to coordinate the titlebar animation with.
HostedAppOriginText* hosted_app_origin_text_ = nullptr;
// Button colors.
bool paint_as_active_ = true;
const SkColor active_icon_color_;
const SkColor inactive_icon_color_;
base::OneShotTimer fade_in_content_setting_buttons_timer_;
// Owned by the views hierarchy.
ContentSettingsContainer* content_settings_container_ = nullptr;
PageActionIconContainerView* page_action_icon_container_view_ = nullptr;
BrowserActionsContainer* browser_actions_container_ = nullptr;
HostedAppMenuButton* app_menu_button_ = nullptr;
base::OneShotTimer opening_animation_timer_;
DISALLOW_COPY_AND_ASSIGN(HostedAppButtonContainer);
};
......
......@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/frame/frame_header_origin_text.h"
#include "chrome/browser/ui/views/frame/hosted_app_origin_text.h"
#include "base/i18n/rtl.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/compositor/layer_animation_element.h"
#include "ui/compositor/layer_animation_sequence.h"
......@@ -12,8 +14,6 @@
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
namespace ash {
namespace {
constexpr base::TimeDelta kOriginSlideInDuration =
......@@ -27,13 +27,19 @@ constexpr gfx::Tween::Type kTweenType = gfx::Tween::FAST_OUT_SLOW_IN_2;
} // namespace
FrameHeaderOriginText::FrameHeaderOriginText(const base::string16& origin,
HostedAppOriginText::HostedAppOriginText(Browser* browser,
SkColor active_color,
SkColor inactive_color)
: active_color_(active_color), inactive_color_(inactive_color) {
DCHECK(
extensions::HostedAppBrowserController::IsForExperimentalHostedAppBrowser(
browser));
SetLayoutManager(std::make_unique<views::FillLayout>());
label_ = std::make_unique<views::Label>(origin).release();
label_ = std::make_unique<views::Label>(
browser->hosted_app_controller()->GetFormattedUrlOrigin())
.release();
label_->SetElideBehavior(gfx::ELIDE_HEAD);
label_->SetSubpixelRenderingEnabled(false);
label_->SetEnabledColor(active_color);
......@@ -51,13 +57,13 @@ FrameHeaderOriginText::FrameHeaderOriginText(const base::string16& origin,
layer()->SetMasksToBounds(true);
}
FrameHeaderOriginText::~FrameHeaderOriginText() = default;
HostedAppOriginText::~HostedAppOriginText() = default;
void FrameHeaderOriginText::SetPaintAsActive(bool active) {
void HostedAppOriginText::SetPaintAsActive(bool active) {
label_->SetEnabledColor(active ? active_color_ : inactive_color_);
}
void FrameHeaderOriginText::StartSlideAnimation() {
void HostedAppOriginText::StartSlideAnimation() {
ui::Layer* label_layer = label_->layer();
// Current state will become the first animation keyframe.
......@@ -104,14 +110,12 @@ void FrameHeaderOriginText::StartSlideAnimation() {
NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true);
}
base::TimeDelta FrameHeaderOriginText::AnimationDuration() {
base::TimeDelta HostedAppOriginText::AnimationDuration() {
return kOriginSlideInDuration + kOriginPauseDuration +
kOriginSlideOutDuration;
}
void FrameHeaderOriginText::GetAccessibleNodeData(ui::AXNodeData* node_data) {
void HostedAppOriginText::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kApplication;
node_data->SetName(label_->text());
}
} // namespace ash
......@@ -2,28 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_FRAME_FRAME_HEADER_ORIGIN_TEXT_H_
#define ASH_FRAME_FRAME_HEADER_ORIGIN_TEXT_H_
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_HOSTED_APP_ORIGIN_TEXT_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_HOSTED_APP_ORIGIN_TEXT_H_
#include "ash/ash_export.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/views/view.h"
class Browser;
namespace views {
class Label;
}
namespace ash {
// A URL's origin text with a slide in/out animation.
class ASH_EXPORT FrameHeaderOriginText : public views::View {
class HostedAppOriginText : public views::View {
public:
FrameHeaderOriginText(const base::string16& origin,
HostedAppOriginText(Browser* browser,
SkColor active_color,
SkColor inactive_color);
~FrameHeaderOriginText() override;
~HostedAppOriginText() override;
// Sets whether to paint the text with the active/inactive color.
void SetPaintAsActive(bool active);
......@@ -44,9 +43,7 @@ class ASH_EXPORT FrameHeaderOriginText : public views::View {
const SkColor active_color_;
const SkColor inactive_color_;
DISALLOW_COPY_AND_ASSIGN(FrameHeaderOriginText);
DISALLOW_COPY_AND_ASSIGN(HostedAppOriginText);
};
} // namespace ash
#endif // ASH_FRAME_FRAME_HEADER_ORIGIN_TEXT_H_
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_HOSTED_APP_ORIGIN_TEXT_H_
......@@ -133,6 +133,9 @@ class ImmersiveModeControllerAshHostedAppBrowserTest
return BrowserView::GetBrowserViewForBrowser(browser_);
}
ImmersiveModeController* controller() { return controller_; }
base::TimeDelta titlebar_animation_delay() {
return HostedAppButtonContainer::kTitlebarAnimationDelay;
}
private:
// Not owned.
......@@ -331,8 +334,7 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerAshHostedAppBrowserTest,
frame_view = static_cast<BrowserNonClientFrameViewAsh*>(
browser_view->GetWidget()->non_client_view()->frame_view());
task_runner->FastForwardBy(
BrowserNonClientFrameViewAsh::kTitlebarAnimationDelay);
task_runner->FastForwardBy(titlebar_animation_delay());
VerifyButtonsInImmersiveMode(frame_view);
}
......
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