1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_MANAGE_PASSWORDS_DECORATION_H_
6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_MANAGE_PASSWORDS_DECORATION_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/ui/cocoa/location_bar/image_decoration.h"
13 #include "chrome/browser/ui/passwords/manage_passwords_icon.h"
16 class LocationBarViewMac;
17 class ManagePasswordsDecoration;
19 // Cocoa implementation of ManagePasswordsIcon that delegates to
20 // ManagePasswordsDecoration.
21 class ManagePasswordsIconCocoa : public ManagePasswordsIcon {
23 ManagePasswordsIconCocoa(ManagePasswordsDecoration* decoration);
24 virtual ~ManagePasswordsIconCocoa();
25 void UpdateVisibleUI() override;
27 int icon_id() { return icon_id_; }
28 int tooltip_text_id() { return tooltip_text_id_; }
31 ManagePasswordsDecoration* decoration_; // weak, owns us
34 // Manage passwords icon on the right side of the field. This appears when
35 // password management is available on the current page.
36 class ManagePasswordsDecoration : public ImageDecoration {
38 explicit ManagePasswordsDecoration(CommandUpdater* command_updater,
39 LocationBarViewMac* location_bar);
40 ~ManagePasswordsDecoration() override;
42 // Implement |LocationBarDecoration|
43 bool AcceptsMousePress() override;
44 bool OnMousePressed(NSRect frame, NSPoint location) override;
45 NSString* GetToolTip() override;
46 NSPoint GetBubblePointInFrame(NSRect frame) override;
48 // Updates the decoration according to icon state changes.
49 void UpdateVisibleUI();
51 // Accessor for the platform-independent interface.
52 ManagePasswordsIconCocoa* icon() { return icon_.get(); }
55 // Triggers a redraw after a state change.
58 // Updates child view states.
61 // Shows the manage passwords bubble.
62 CommandUpdater* command_updater_; // Weak, owned by Browser.
64 // Displays all the decorations.
65 LocationBarViewMac* location_bar_; // Weak, owns us.
67 // The platform-independent interface.
68 scoped_ptr<ManagePasswordsIconCocoa> icon_;
70 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsDecoration);
73 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_MANAGE_PASSWORDS_DECORATION_H_