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_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_COCOA_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/mac/scoped_nsobject.h"
11 #import "chrome/browser/ui/passwords/manage_passwords_bubble.h"
17 @
class ManagePasswordsBubbleController
;
18 @
class ManagePasswordsBubbleCocoaNotificationBridge
;
19 class ManagePasswordsIcon
;
21 // Cocoa implementation of the platform-independent password bubble interface.
22 class ManagePasswordsBubbleCocoa
: public ManagePasswordsBubble
{
24 // Creates and shows the bubble, which owns itself. Does nothing if the bubble
26 static void Show(content::WebContents
* webContents
, bool user_action
);
28 // Closes and deletes the bubble.
31 // Sets the location bar icon that should be updated with state changes.
32 void SetIcon(ManagePasswordsIcon
* icon
) { icon_
= icon
; }
34 // Accessor for the global bubble.
35 static ManagePasswordsBubbleCocoa
* instance() { return bubble_
; }
38 friend class ManagePasswordsBubbleCocoaTest
;
39 friend class ManagePasswordsBubbleTest
;
41 // Instance-specific logic. Clients should use the static interface.
42 ManagePasswordsBubbleCocoa(content::WebContents
* webContents
,
43 DisplayReason displayReason
,
44 ManagePasswordsIcon
* icon
);
45 ~ManagePasswordsBubbleCocoa() override
;
48 // Cleans up state and deletes itself. Called when the bubble is closed.
51 // The location bar icon corresponding to the bubble.
52 ManagePasswordsIcon
* icon_
;
54 // Whether there is currently a close operation taking place. Prevents
55 // multiple attempts to close the window.
58 // The view controller for the bubble. Weak; owns itself. Must be nilled
59 // after the bubble is closed.
60 ManagePasswordsBubbleController
* controller_
;
62 // WebContents on which the bubble should be displayed. Weak.
63 content::WebContents
* webContents_
;
65 // Listens for NSNotificationCenter notifications.
66 base::scoped_nsobject
<ManagePasswordsBubbleCocoaNotificationBridge
> bridge_
;
68 // The global bubble instance. Deleted by Close().
69 static ManagePasswordsBubbleCocoa
* bubble_
;
71 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleCocoa
);
74 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_COCOA_H_