Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d81884dabefe173bee22be0cfb9ab69ba6403140 |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.mm |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" |
| + |
| +#include "chrome/app/chrome_command_ids.h" |
| +#include "chrome/browser/command_updater.h" |
| +#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
|
rohitrao (ping after 24h)
2014/07/31 12:35:19
OmniboxViewMac is a C++ class, so this should be #
dconnelly
2014/08/01 09:11:46
Done.
|
| +#include "ui/base/l10n/l10n_util_mac.h" |
| + |
| +ManagePasswordsDecoration::ManagePasswordsDecoration( |
| + CommandUpdater* command_updater) |
| + : command_updater_(command_updater) { |
| + UpdateVisibleUI(); |
| +} |
| + |
| +ManagePasswordsDecoration::~ManagePasswordsDecoration() {} |
| + |
| +NSPoint ManagePasswordsDecoration::GetBubblePointInFrame(NSRect frame) { |
| + const NSRect draw_frame = GetDrawRectInFrame(frame); |
| + return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame)); |
| +} |
| + |
| +bool ManagePasswordsDecoration::AcceptsMousePress() { |
| + return true; |
| +} |
| + |
| +bool ManagePasswordsDecoration::OnMousePressed(NSRect frame, NSPoint location) { |
| + command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); |
| + return true; |
| +} |
| + |
| +NSString* ManagePasswordsDecoration::GetToolTip() { |
| + return tooltip_text_id_ ? l10n_util::GetNSStringWithFixup(tooltip_text_id_) |
| + : nil; |
| +} |
| + |
| +// ManagePasswordsIcon: |
| + |
| +void ManagePasswordsDecoration::UpdateVisibleUI() { |
| + if (state() == password_manager::ui::INACTIVE_STATE) { |
| + SetVisible(false); |
| + SetImage(nil); |
| + // TODO(dconnelly): Hide the bubble once it is implemented. |
| + return; |
| + } |
| + SetVisible(true); |
| + SetImage(OmniboxViewMac::ImageForResource(icon_id_)); |
| +} |