Index: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
index 55dfde9866b8dc7c182eaf618b12be396523e038..f3ba8456ce588ac6aa75d7183aea6c6b8c44c1e8 100644 |
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
@@ -34,6 +34,9 @@ |
namespace { |
+// The number of seconds the inactive bubble should stay alive. |
+const int kBubbleCloseDelay = 15; |
+ |
const int kDesiredBubbleWidth = 370; |
enum ColumnSetType { |
@@ -551,6 +554,7 @@ void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, |
manage_passwords_bubble_->GetWidget()->ShowInactive(); |
else |
manage_passwords_bubble_->GetWidget()->Show(); |
+ manage_passwords_bubble_->StartTimerIfNecessary(); |
} |
// static |
@@ -579,6 +583,7 @@ ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
initially_focused_view_(NULL) { |
// Compensate for built-in vertical padding in the anchor view's image. |
set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
+ set_notify_enter_exit_on_child(true); |
if (anchor_view) |
anchor_view->SetActive(true); |
} |
@@ -606,24 +611,6 @@ void ManagePasswordsBubbleView::Close() { |
GetWidget()->Close(); |
} |
-void ManagePasswordsBubbleView::Init() { |
Mike West
2014/08/05 16:47:59
Nit: Please don't move unrelated code. CLs are che
vasilii
2014/08/06 10:36:10
Done.
|
- views::FillLayout* layout = new views::FillLayout(); |
- SetLayoutManager(layout); |
- |
- Refresh(); |
-} |
- |
-void ManagePasswordsBubbleView::WindowClosing() { |
- // Close() closes the window asynchronously, so by the time we reach here, |
- // |manage_passwords_bubble_| may have already been reset. |
- if (manage_passwords_bubble_ == this) |
- manage_passwords_bubble_ = NULL; |
-} |
- |
-views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { |
- return initially_focused_view_; |
-} |
- |
void ManagePasswordsBubbleView::Refresh() { |
RemoveAllChildViews(true); |
initially_focused_view_ = NULL; |
@@ -640,6 +627,9 @@ void ManagePasswordsBubbleView::Refresh() { |
AddChildView(new ManageView(this)); |
} |
GetLayoutManager()->Layout(this); |
+ // If we refresh the existing bubble we may want to restart the timer. |
+ if (GetWidget()) |
+ StartTimerIfNecessary(); |
} |
void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
@@ -661,3 +651,46 @@ void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { |
never_save_passwords_ = false; |
Refresh(); |
} |
+ |
+void ManagePasswordsBubbleView::StartTimerIfNecessary() { |
+ // Active bubble will stay visible until it loses focus. |
+ if (GetWidget()->IsActive()) |
+ return; |
+ timer_.Start(FROM_HERE, |
+ base::TimeDelta::FromSeconds(kBubbleCloseDelay), |
+ this, |
+ &ManagePasswordsBubbleView::Close); |
+} |
+ |
+void ManagePasswordsBubbleView::Init() { |
+ views::FillLayout* layout = new views::FillLayout(); |
+ SetLayoutManager(layout); |
+ |
+ Refresh(); |
+} |
+ |
+void ManagePasswordsBubbleView::WindowClosing() { |
+ // Close() closes the window asynchronously, so by the time we reach here, |
+ // |manage_passwords_bubble_| may have already been reset. |
+ if (manage_passwords_bubble_ == this) |
+ manage_passwords_bubble_ = NULL; |
+} |
+ |
+void ManagePasswordsBubbleView::OnWidgetActivationChanged(views::Widget* widget, |
+ bool active) { |
+ if (active && widget == GetWidget()) |
+ timer_.Stop(); |
+ BubbleDelegateView::OnWidgetActivationChanged(widget, active); |
+} |
+ |
+views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { |
+ return initially_focused_view_; |
+} |
+ |
+void ManagePasswordsBubbleView::OnMouseEntered(const ui::MouseEvent& event) { |
+ timer_.Stop(); |
+} |
+ |
+void ManagePasswordsBubbleView::OnMouseExited(const ui::MouseEvent& event) { |
+ StartTimerIfNecessary(); |
+} |