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 ManagePasswordsDecoration;
18 // Cocoa implementation of ManagePasswordsIcon that delegates to
19 // ManagePasswordsDecoration.
20 class ManagePasswordsIconCocoa : public ManagePasswordsIcon {
22 ManagePasswordsIconCocoa(ManagePasswordsDecoration* decoration);
23 virtual ~ManagePasswordsIconCocoa();
24 virtual void UpdateVisibleUI() OVERRIDE;
26 int icon_id() { return icon_id_; }
27 int tooltip_text_id() { return tooltip_text_id_; }
30 ManagePasswordsDecoration* decoration_; // weak, owns us
33 // Manage passwords icon on the right side of the field. This appears when
34 // password management is available on the current page.
35 class ManagePasswordsDecoration : public ImageDecoration {
37 explicit ManagePasswordsDecoration(CommandUpdater* command_updater);
38 virtual ~ManagePasswordsDecoration();
40 // Implement |LocationBarDecoration|
41 virtual bool AcceptsMousePress() OVERRIDE;
42 virtual bool OnMousePressed(NSRect frame, NSPoint location) OVERRIDE;
43 virtual NSString* GetToolTip() OVERRIDE;
44 virtual NSPoint GetBubblePointInFrame(NSRect frame) OVERRIDE;
46 // Updates the decoration according to icon state changes.
47 void UpdateVisibleUI();
49 // Accessor for the platform-independent interface.
50 ManagePasswordsIconCocoa* icon() { return icon_.get(); }
53 // Shows the manage passwords bubble.
54 CommandUpdater* command_updater_; // Weak, owned by Browser.
56 // The platform-independent interface.
57 scoped_ptr<ManagePasswordsIconCocoa> icon_;
59 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsDecoration);
62 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_MANAGE_PASSWORDS_DECORATION_H_