Chromium Code Reviews| Index: chrome/browser/ui/views/screen_capture_notification_ui_views.cc |
| diff --git a/chrome/browser/ui/views/screen_capture_notification_ui_views.cc b/chrome/browser/ui/views/screen_capture_notification_ui_views.cc |
| index 12371bc8a63c477ae78eab7662cff0411bb32326..ea71fd99cccd282fa0a7051c69573a4ffd55d317 100644 |
| --- a/chrome/browser/ui/views/screen_capture_notification_ui_views.cc |
| +++ b/chrome/browser/ui/views/screen_capture_notification_ui_views.cc |
| @@ -17,6 +17,8 @@ |
| #include "ui/views/bubble/bubble_frame_view.h" |
| #include "ui/views/controls/button/blue_button.h" |
| #include "ui/views/controls/image_view.h" |
| +#include "ui/views/controls/link.h" |
| +#include "ui/views/controls/link_listener.h" |
| #include "ui/views/corewm/shadow_types.h" |
| #include "ui/views/layout/box_layout.h" |
| #include "ui/views/view.h" |
| @@ -71,7 +73,8 @@ class NotificationBarClientView : public views::ClientView { |
| class ScreenCaptureNotificationUIViews |
| : public ScreenCaptureNotificationUI, |
| public views::WidgetDelegateView, |
| - public views::ButtonListener { |
| + public views::ButtonListener, |
| + public views::LinkListener { |
| public: |
| explicit ScreenCaptureNotificationUIViews(const base::string16& text); |
| virtual ~ScreenCaptureNotificationUIViews(); |
| @@ -97,6 +100,9 @@ class ScreenCaptureNotificationUIViews |
| virtual void ButtonPressed(views::Button* sender, |
| const ui::Event& event) OVERRIDE; |
| + // views::LinkListener interface. |
| + virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| + |
| private: |
| // Helper to call |stop_callback_|. |
| void NotifyStopped(); |
| @@ -107,6 +113,7 @@ class ScreenCaptureNotificationUIViews |
| views::ImageView* gripper_; |
| views::Label* label_; |
| views::BlueButton* stop_button_; |
| + views::Link* hide_link_; |
| DISALLOW_COPY_AND_ASSIGN(ScreenCaptureNotificationUIViews); |
| }; |
| @@ -117,7 +124,8 @@ ScreenCaptureNotificationUIViews::ScreenCaptureNotificationUIViews( |
| client_view_(NULL), |
| gripper_(NULL), |
| label_(NULL), |
| - stop_button_(NULL) { |
| + stop_button_(NULL), |
| + hide_link_(NULL) { |
| set_owned_by_client(); |
| set_background(views::Background::CreateSolidBackground(GetNativeTheme()-> |
| @@ -136,6 +144,11 @@ ScreenCaptureNotificationUIViews::ScreenCaptureNotificationUIViews( |
| l10n_util::GetStringUTF16(IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_STOP); |
| stop_button_ = new views::BlueButton(this, stop_text); |
| AddChildView(stop_button_); |
| + |
| + hide_link_ = new views::Link( |
| + l10n_util::GetStringUTF16(IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_HIDE)); |
| + hide_link_->set_listener(this); |
| + AddChildView(hide_link_); |
| } |
| ScreenCaptureNotificationUIViews::~ScreenCaptureNotificationUIViews() { |
| @@ -193,12 +206,15 @@ void ScreenCaptureNotificationUIViews::OnStarted( |
| gfx::Size ScreenCaptureNotificationUIViews::GetPreferredSize() { |
| gfx::Size grip_size = gripper_->GetPreferredSize(); |
| gfx::Size label_size = child_at(1)->GetPreferredSize(); |
| - gfx::Size button_size = child_at(2)->GetPreferredSize(); |
| - int width = kHorizontalMargin * 2 + grip_size.width() + label_size.width() + |
| - button_size.width(); |
| + gfx::Size stop_button_size = child_at(2)->GetPreferredSize(); |
| + gfx::Size hide_link_size = child_at(3)->GetPreferredSize(); |
|
Sergey Ulanov
2014/03/11 23:45:38
Please replace child_at(?) here with label_, stop_
jiayl
2014/03/11 23:54:35
Done.
|
| + int width = kHorizontalMargin * 3 + grip_size.width() + label_size.width() + |
| + stop_button_size.width() + hide_link_size.width(); |
| width = std::max(width, kMinimumWidth); |
| width = std::min(width, kMaximumWidth); |
| - return gfx::Size(width, std::max(label_size.height(), button_size.height())); |
| + return gfx::Size(width, std::max(label_size.height(), |
| + std::max(hide_link_size.height(), |
| + stop_button_size.height()))); |
| } |
| void ScreenCaptureNotificationUIViews::Layout() { |
| @@ -206,17 +222,28 @@ void ScreenCaptureNotificationUIViews::Layout() { |
| grip_rect.set_y(bounds().height() / 2 - grip_rect.height() / 2); |
| gripper_->SetBoundsRect(grip_rect); |
| - gfx::Rect button_rect(stop_button_->GetPreferredSize()); |
| - button_rect.set_x(bounds().width() - button_rect.width()); |
| - stop_button_->SetBoundsRect(button_rect); |
| + gfx::Rect stop_button_rect(stop_button_->GetPreferredSize()); |
| + gfx::Rect hide_link_rect(hide_link_->GetPreferredSize()); |
| + |
| + stop_button_rect.set_x(bounds().width() - stop_button_rect.width() - |
| + kHorizontalMargin - hide_link_rect.width()); |
| + stop_button_->SetBoundsRect(stop_button_rect); |
| - gfx::Rect label_rect; |
| + hide_link_rect.set_x(stop_button_rect.right() + kHorizontalMargin); |
| + hide_link_rect.set_y((bounds().height() - hide_link_rect.height()) / 2); |
| + hide_link_->SetBoundsRect(hide_link_rect); |
| + |
| + gfx::Rect label_rect(label_->GetPreferredSize()); |
| label_rect.set_x(grip_rect.right() + kHorizontalMargin); |
| - label_rect.set_width(button_rect.x() - kHorizontalMargin - label_rect.x()); |
| + label_rect.set_width( |
| + stop_button_rect.x() - kHorizontalMargin - label_rect.x()); |
| label_rect.set_height(bounds().height()); |
| label_->SetBoundsRect(label_rect); |
| - client_view_->SetClientRect(button_rect); |
| + client_view_->SetClientRect(gfx::Rect( |
| + stop_button_rect.x(), stop_button_rect.y(), |
| + stop_button_rect.width() + kHorizontalMargin + hide_link_rect.width(), |
| + std::max(stop_button_rect.height(), hide_link_rect.height()))); |
| } |
| void ScreenCaptureNotificationUIViews::DeleteDelegate() { |
| @@ -265,6 +292,11 @@ void ScreenCaptureNotificationUIViews::ButtonPressed(views::Button* sender, |
| NotifyStopped(); |
| } |
| +void ScreenCaptureNotificationUIViews::LinkClicked( |
| + views::Link* source, int event_flags) { |
| + GetWidget()->Minimize(); |
|
Sergey Ulanov
2014/03/11 23:45:38
Does this work as expected on Windows and Linux? N
jiayl
2014/03/11 23:54:35
It works as expected on Linux because the notifica
jiayl
2014/03/12 01:12:49
Fixed now. Confirmed working on Linux/Windows/Mac.
|
| +} |
| + |
| void ScreenCaptureNotificationUIViews::NotifyStopped() { |
| if (!stop_callback_.is_null()) { |
| base::Closure callback = stop_callback_; |