Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / location_bar / manage_passwords_decoration.h
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.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_MANAGE_PASSWORDS_DECORATION_H_
6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_MANAGE_PASSWORDS_DECORATION_H_
7
8 #import <Cocoa/Cocoa.h>
9
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"
14
15 class CommandUpdater;
16 class LocationBarViewMac;
17 class ManagePasswordsDecoration;
18
19 // Cocoa implementation of ManagePasswordsIcon that delegates to
20 // ManagePasswordsDecoration.
21 class ManagePasswordsIconCocoa : public ManagePasswordsIcon {
22  public:
23   ManagePasswordsIconCocoa(ManagePasswordsDecoration* decoration);
24   virtual ~ManagePasswordsIconCocoa();
25   void UpdateVisibleUI() override;
26
27   int icon_id() { return icon_id_; }
28   int tooltip_text_id() { return tooltip_text_id_; }
29
30  private:
31   ManagePasswordsDecoration* decoration_;  // weak, owns us
32 };
33
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 {
37  public:
38   explicit ManagePasswordsDecoration(CommandUpdater* command_updater,
39                                      LocationBarViewMac* location_bar);
40   ~ManagePasswordsDecoration() override;
41
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;
47
48   // Updates the decoration according to icon state changes.
49   void UpdateVisibleUI();
50
51   // Accessor for the platform-independent interface.
52   ManagePasswordsIconCocoa* icon() { return icon_.get(); }
53
54  private:
55   // Triggers a redraw after a state change.
56   void OnChange();
57
58   // Updates child view states.
59   void UpdateUIState();
60
61   // Shows the manage passwords bubble.
62   CommandUpdater* command_updater_;  // Weak, owned by Browser.
63
64   // Displays all the decorations.
65   LocationBarViewMac* location_bar_;  // Weak, owns us.
66
67   // The platform-independent interface.
68   scoped_ptr<ManagePasswordsIconCocoa> icon_;
69
70   DISALLOW_COPY_AND_ASSIGN(ManagePasswordsDecoration);
71 };
72
73 #endif  // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_MANAGE_PASSWORDS_DECORATION_H_