Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Unified Diff: chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.mm

Issue 419263002: Add ManagePasswordsDecoration and unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_));
+}

Powered by Google App Engine
This is Rietveld 408576698