Chromium Code Reviews| Index: chrome/browser/ui/views/passwords/manage_passwords_icon_view.cc |
| diff --git a/chrome/browser/ui/views/passwords/manage_passwords_icon_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_icon_view.cc |
| index aa99be4b8b9ae00f395a1a058e661f03bbad2e92..116e7c0f59deab45baa7c434347c4033263a252f 100644 |
| --- a/chrome/browser/ui/views/passwords/manage_passwords_icon_view.cc |
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_icon_view.cc |
| @@ -5,6 +5,7 @@ |
| #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
| #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
| +#include "chrome/browser/ui/view_ids.h" |
| #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| #include "grit/generated_resources.h" |
| #include "grit/theme_resources.h" |
| @@ -14,50 +15,47 @@ |
| ManagePasswordsIconView::ManagePasswordsIconView( |
| LocationBarView::Delegate* location_bar_delegate) |
| : location_bar_delegate_(location_bar_delegate) { |
| + set_id(VIEW_ID_MANAGE_PASSWORDS_ICON_BUTTON); |
| SetAccessibilityFocusable(true); |
| - Update(NULL); |
| LocationBarView::InitTouchableLocationBarChildView(this); |
| + SetState(ManagePasswordsIcon::INACTIVE_STATE); |
| } |
| ManagePasswordsIconView::~ManagePasswordsIconView() {} |
| -void ManagePasswordsIconView::Update( |
| - ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller) { |
| - SetVisible(manage_passwords_bubble_ui_controller && |
| - manage_passwords_bubble_ui_controller-> |
| - manage_passwords_icon_to_be_shown() && |
| - !location_bar_delegate_->GetToolbarModel()->input_in_progress()); |
| - if (!visible()) { |
| - ManagePasswordsBubbleView::CloseBubble(); |
| +void ManagePasswordsIconView::SetStateInternal( |
| + ManagePasswordsIcon::State state) { |
| + if (state == ManagePasswordsIcon::INACTIVE_STATE) { |
| + SetVisible(false); |
| + if (ManagePasswordsBubbleView::IsShowing()) |
| + ManagePasswordsBubbleView::CloseBubble(); |
| return; |
| } |
| - int icon_to_display = |
| - manage_passwords_bubble_ui_controller->autofill_blocked() |
| - ? IDR_SAVE_PASSWORD_BLACKLISTED |
| - : IDR_SAVE_PASSWORD; |
| - SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| - icon_to_display)); |
| - SetTooltip(manage_passwords_bubble_ui_controller->password_to_be_saved()); |
| -} |
| -void ManagePasswordsIconView::ShowBubbleIfNeeded( |
| - ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller) { |
| - if (manage_passwords_bubble_ui_controller-> |
| - manage_passwords_bubble_needs_showing() && |
| - visible() && |
| - !ManagePasswordsBubbleView::IsShowing()) { |
| - ManagePasswordsBubbleView::ShowBubble( |
| - location_bar_delegate_->GetWebContents(), |
| - ManagePasswordsBubbleView::AUTOMATIC); |
| - manage_passwords_bubble_ui_controller->OnBubbleShown(); |
| - } |
| + // Start with the correct values for ManagePasswordsIcon::MANAGE_STATE, and |
| + // adjust things accordingly if we're either in BLACKLISTED_STATE or |
| + // PENDING_STATE. |
| + int which_icon = IDR_SAVE_PASSWORD; |
| + int which_text = IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE; |
| + if (state == ManagePasswordsIcon::BLACKLISTED_STATE) |
| + which_icon = IDR_SAVE_PASSWORD_BLACKLISTED; |
| + else if (state == ManagePasswordsIcon::PENDING_STATE) |
| + which_text = IDS_PASSWORD_MANAGER_TOOLTIP_SAVE; |
| + |
| + SetVisible(true); |
| + SetImage( |
| + ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(which_icon)); |
| + SetTooltipText(l10n_util::GetStringUTF16(which_text)); |
| } |
| -void ManagePasswordsIconView::SetTooltip(bool password_to_be_saved) { |
| - SetTooltipText(l10n_util::GetStringUTF16( |
| - (password_to_be_saved ? |
| - IDS_PASSWORD_MANAGER_TOOLTIP_SAVE : |
| - IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE))); |
| +void ManagePasswordsIconView::ShowBubbleWithoutUserInteraction() { |
| + // Suppress the bubble if the user is working in the omnibox. |
|
markusheintz_
2014/04/25 13:25:10
What does working mean?
Is the bubble displayed a
Mike West
2014/04/25 13:31:42
I believe this method returns true if the user has
|
| + if (location_bar_delegate_->GetToolbarModel()->input_in_progress()) |
| + return; |
| + |
| + ManagePasswordsBubbleView::ShowBubble( |
| + location_bar_delegate_->GetWebContents(), |
| + ManagePasswordsBubbleView::AUTOMATIC); |
| } |
| bool ManagePasswordsIconView::GetTooltipText(const gfx::Point& p, |