Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/origin_chip_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/origin_chip_view.cc b/chrome/browser/ui/views/location_bar/origin_chip_view.cc |
| index 09e385370cdcfe2b1cf547423b3fd39b5407bdf6..dd988901499d6fbc73933db6f24d6a546510ab3f 100644 |
| --- a/chrome/browser/ui/views/location_bar/origin_chip_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/origin_chip_view.cc |
| @@ -25,8 +25,6 @@ |
| #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| #include "chrome/common/extensions/extension_constants.h" |
| #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| -#include "content/public/browser/navigation_controller.h" |
| -#include "content/public/browser/navigation_entry.h" |
| #include "content/public/browser/user_metrics.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/common/url_constants.h" |
| @@ -37,6 +35,8 @@ |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/base/theme_provider.h" |
| +#include "ui/gfx/animation/slide_animation.h" |
| +#include "ui/gfx/canvas.h" |
| #include "ui/gfx/font_list.h" |
| #include "ui/views/background.h" |
| #include "ui/views/controls/button/label_button.h" |
| @@ -164,6 +164,10 @@ void OriginChipView::Init() { |
| host_label_ = new views::Label(base::string16(), GetFontList()); |
| AddChildView(host_label_); |
| + |
| + fade_in_animation_.reset(new gfx::SlideAnimation(this)); |
| + fade_in_animation_->SetTweenType(gfx::Tween::LINEAR); |
| + fade_in_animation_->SetSlideDuration(300); |
| } |
| bool OriginChipView::ShouldShow() { |
| @@ -280,6 +284,30 @@ void OriginChipView::OnChanged() { |
| // arrows are pointing to the right spot. Only needed for some edge cases. |
| } |
| +void OriginChipView::FadeIn() { |
| + fade_in_animation_->Show(); |
| +} |
| + |
| +int OriginChipView::LabelPosition() { |
|
Peter Kasting
2014/03/21 21:22:10
Nit: This function can be declared unix_hacker()-s
Justin Donnelly
2014/03/24 22:59:37
Done.
|
| + return host_label_->x(); |
| +} |
| + |
| +void OriginChipView::AnimationProgressed(const gfx::Animation* animation) { |
| + if (animation == fade_in_animation_.get()) { |
|
Peter Kasting
2014/03/21 21:22:10
Nit: No {} (2 places)
Though, are there other ani
Justin Donnelly
2014/03/24 22:59:37
Done.
|
| + SchedulePaint(); |
| + } else { |
| + views::LabelButton::AnimationProgressed(animation); |
| + } |
| +} |
| + |
| +void OriginChipView::AnimationEnded(const gfx::Animation* animation) { |
| + if (animation == fade_in_animation_.get()) { |
| + fade_in_animation_->Reset(); |
| + } else { |
| + views::LabelButton::AnimationEnded(animation); |
| + } |
| +} |
| + |
| gfx::Size OriginChipView::GetPreferredSize() { |
| gfx::Size label_size = host_label_->GetPreferredSize(); |
| gfx::Size icon_size = location_icon_view_->GetPreferredSize(); |
| @@ -312,6 +340,17 @@ void OriginChipView::Layout() { |
| height() - 2 * LocationBarView::kNormalEdgeThickness); |
| } |
| +void OriginChipView::OnPaintBorder(gfx::Canvas* canvas) { |
| + if (fade_in_animation_->is_animating()) { |
| + canvas->SaveLayerAlpha(static_cast<uint8>( |
| + fade_in_animation_->CurrentValueBetween(0, 255))); |
| + views::LabelButton::OnPaintBorder(canvas); |
| + canvas->Restore(); |
| + } else { |
| + views::LabelButton::OnPaintBorder(canvas); |
| + } |
| +} |
| + |
| int OriginChipView::ElideDomainTarget(int target_max_width) { |
| base::string16 host = |
| OriginChip::LabelFromURLForProfile(url_displayed_, profile_); |
| @@ -350,7 +389,7 @@ void OriginChipView::ButtonPressed(views::Button* sender, |
| UMA_HISTOGRAM_COUNTS("OriginChip.Pressed", 1); |
| content::RecordAction(base::UserMetricsAction("OriginChipPress")); |
| - location_bar_view_->GetOmniboxView()->ShowURL(); |
| + location_bar_view_->ShowURL(); |
| } |
| // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will |