| Index: chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.mm
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.mm b/chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.mm
|
| index 4f9528f932eeb0dba71d014b62ecf36899e5e81b..4e3e1c854043ef62094f32435fa7b985878acc47 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.mm
|
| +++ b/chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.mm
|
| @@ -8,6 +8,7 @@
|
| #include "chrome/browser/command_updater.h"
|
| #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
|
| #include "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h"
|
| +#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
|
| #include "ui/base/l10n/l10n_util_mac.h"
|
|
|
| // ManagePasswordsIconCocoa
|
| @@ -27,10 +28,12 @@ void ManagePasswordsIconCocoa::UpdateVisibleUI() {
|
| // ManagePasswordsDecoration
|
|
|
| ManagePasswordsDecoration::ManagePasswordsDecoration(
|
| - CommandUpdater* command_updater)
|
| + CommandUpdater* command_updater,
|
| + LocationBarViewMac* location_bar)
|
| : command_updater_(command_updater),
|
| + location_bar_(location_bar),
|
| icon_(new ManagePasswordsIconCocoa(this)) {
|
| - UpdateVisibleUI();
|
| + UpdateUIState();
|
| }
|
|
|
| ManagePasswordsDecoration::~ManagePasswordsDecoration() {}
|
| @@ -45,8 +48,12 @@ bool ManagePasswordsDecoration::AcceptsMousePress() {
|
| }
|
|
|
| bool ManagePasswordsDecoration::OnMousePressed(NSRect frame, NSPoint location) {
|
| - command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
|
| - return true;
|
| + bool result = ImageDecoration::OnMousePressed(frame, location);
|
| + if (ManagePasswordsBubbleCocoa::instance())
|
| + ManagePasswordsBubbleCocoa::instance()->Close();
|
| + else
|
| + command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
|
| + return result;
|
| }
|
|
|
| NSString* ManagePasswordsDecoration::GetToolTip() {
|
| @@ -55,7 +62,13 @@ NSString* ManagePasswordsDecoration::GetToolTip() {
|
| : nil;
|
| }
|
|
|
| -void ManagePasswordsDecoration::UpdateVisibleUI() {
|
| +void ManagePasswordsDecoration::OnChange() {
|
| + // |location_bar_| can be NULL in tests.
|
| + if (location_bar_)
|
| + location_bar_->OnDecorationsChanged();
|
| +}
|
| +
|
| +void ManagePasswordsDecoration::UpdateUIState() {
|
| if (icon_->state() == password_manager::ui::INACTIVE_STATE) {
|
| SetVisible(false);
|
| SetImage(nil);
|
| @@ -66,3 +79,8 @@ void ManagePasswordsDecoration::UpdateVisibleUI() {
|
| SetVisible(true);
|
| SetImage(OmniboxViewMac::ImageForResource(icon_->icon_id()));
|
| }
|
| +
|
| +void ManagePasswordsDecoration::UpdateVisibleUI() {
|
| + UpdateUIState();
|
| + OnChange();
|
| +}
|
|
|