Upstream version 9.38.198.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 ManagePasswordsDecoration;
17
18 // Cocoa implementation of ManagePasswordsIcon that delegates to
19 // ManagePasswordsDecoration.
20 class ManagePasswordsIconCocoa : public ManagePasswordsIcon {
21  public:
22   ManagePasswordsIconCocoa(ManagePasswordsDecoration* decoration);
23   virtual ~ManagePasswordsIconCocoa();
24   virtual void UpdateVisibleUI() OVERRIDE;
25
26   int icon_id() { return icon_id_; }
27   int tooltip_text_id() { return tooltip_text_id_; }
28
29  private:
30   ManagePasswordsDecoration* decoration_;  // weak, owns us
31 };
32
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 {
36  public:
37   explicit ManagePasswordsDecoration(CommandUpdater* command_updater);
38   virtual ~ManagePasswordsDecoration();
39
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;
45
46   // Updates the decoration according to icon state changes.
47   void UpdateVisibleUI();
48
49   // Accessor for the platform-independent interface.
50   ManagePasswordsIconCocoa* icon() { return icon_.get(); }
51
52  private:
53   // Shows the manage passwords bubble.
54   CommandUpdater* command_updater_;  // Weak, owned by Browser.
55
56   // The platform-independent interface.
57   scoped_ptr<ManagePasswordsIconCocoa> icon_;
58
59   DISALLOW_COPY_AND_ASSIGN(ManagePasswordsDecoration);
60 };
61
62 #endif  // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_MANAGE_PASSWORDS_DECORATION_H_