OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 5 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
6 | 6 |
7 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" | 7 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
8 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 8 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 void ManagePasswordsIconView::ShowBubbleIfNeeded( | 43 void ManagePasswordsIconView::ShowBubbleIfNeeded( |
44 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller) { | 44 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller) { |
45 if (manage_passwords_bubble_ui_controller-> | 45 if (manage_passwords_bubble_ui_controller-> |
46 manage_passwords_bubble_needs_showing() && | 46 manage_passwords_bubble_needs_showing() && |
47 visible() && | 47 visible() && |
48 !ManagePasswordsBubbleView::IsShowing()) { | 48 !ManagePasswordsBubbleView::IsShowing()) { |
49 ManagePasswordsBubbleView::ShowBubble( | 49 ManagePasswordsBubbleView::ShowBubble( |
50 location_bar_delegate_->GetWebContents(), | 50 location_bar_delegate_->GetWebContents(), |
51 this, | |
52 ManagePasswordsBubbleView::AUTOMATIC); | 51 ManagePasswordsBubbleView::AUTOMATIC); |
53 manage_passwords_bubble_ui_controller->OnBubbleShown(); | 52 manage_passwords_bubble_ui_controller->OnBubbleShown(); |
54 } | 53 } |
55 } | 54 } |
56 | 55 |
57 void ManagePasswordsIconView::SetTooltip(bool password_to_be_saved) { | 56 void ManagePasswordsIconView::SetTooltip(bool password_to_be_saved) { |
58 SetTooltipText(l10n_util::GetStringUTF16( | 57 SetTooltipText(l10n_util::GetStringUTF16( |
59 (password_to_be_saved ? | 58 (password_to_be_saved ? |
60 IDS_PASSWORD_MANAGER_TOOLTIP_SAVE : | 59 IDS_PASSWORD_MANAGER_TOOLTIP_SAVE : |
61 IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE))); | 60 IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE))); |
62 } | 61 } |
63 | 62 |
64 bool ManagePasswordsIconView::GetTooltipText(const gfx::Point& p, | 63 bool ManagePasswordsIconView::GetTooltipText(const gfx::Point& p, |
65 base::string16* tooltip) const { | 64 base::string16* tooltip) const { |
66 // Don't show tooltip if the password bubble is displayed. | 65 // Don't show tooltip if the password bubble is displayed. |
67 return !ManagePasswordsBubbleView::IsShowing() && | 66 return !ManagePasswordsBubbleView::IsShowing() && |
68 ImageView::GetTooltipText(p, tooltip); | 67 ImageView::GetTooltipText(p, tooltip); |
69 } | 68 } |
70 | 69 |
71 void ManagePasswordsIconView::OnGestureEvent(ui::GestureEvent* event) { | 70 void ManagePasswordsIconView::OnGestureEvent(ui::GestureEvent* event) { |
72 if (event->type() == ui::ET_GESTURE_TAP) { | 71 if (event->type() == ui::ET_GESTURE_TAP) { |
73 ManagePasswordsBubbleView::ShowBubble( | 72 ManagePasswordsBubbleView::ShowBubble( |
74 location_bar_delegate_->GetWebContents(), | 73 location_bar_delegate_->GetWebContents(), |
75 this, | |
76 ManagePasswordsBubbleView::USER_ACTION); | 74 ManagePasswordsBubbleView::USER_ACTION); |
77 event->SetHandled(); | 75 event->SetHandled(); |
78 } | 76 } |
79 } | 77 } |
80 | 78 |
81 bool ManagePasswordsIconView::OnMousePressed(const ui::MouseEvent& event) { | 79 bool ManagePasswordsIconView::OnMousePressed(const ui::MouseEvent& event) { |
82 // Do nothing until the mouse button is released. | 80 // Do nothing until the mouse button is released. |
83 return true; | 81 return true; |
84 } | 82 } |
85 | 83 |
86 void ManagePasswordsIconView::OnMouseReleased(const ui::MouseEvent& event) { | 84 void ManagePasswordsIconView::OnMouseReleased(const ui::MouseEvent& event) { |
87 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) { | 85 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) { |
88 ManagePasswordsBubbleView::ShowBubble( | 86 ManagePasswordsBubbleView::ShowBubble( |
89 location_bar_delegate_->GetWebContents(), | 87 location_bar_delegate_->GetWebContents(), |
90 this, | |
91 ManagePasswordsBubbleView::USER_ACTION); | 88 ManagePasswordsBubbleView::USER_ACTION); |
92 } | 89 } |
93 } | 90 } |
OLD | NEW |