OLD | NEW |
| (Empty) |
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_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_COCOA_H_ | |
6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_COCOA_H_ | |
7 | |
8 #import <Cocoa/Cocoa.h> | |
9 | |
10 #include "base/mac/scoped_nsobject.h" | |
11 #import "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | |
12 | |
13 namespace content { | |
14 class WebContents; | |
15 } | |
16 | |
17 @class ManagePasswordsBubbleController; | |
18 @class ManagePasswordsBubbleCocoaNotificationBridge; | |
19 class ManagePasswordsIcon; | |
20 | |
21 // Cocoa implementation of the platform-independent password bubble interface. | |
22 class ManagePasswordsBubbleCocoa { | |
23 public: | |
24 // Creates and shows the bubble, which owns itself. Does nothing if the bubble | |
25 // is already shown. | |
26 static void Show(content::WebContents* webContents, bool user_action); | |
27 | |
28 // Closes and deletes the bubble. | |
29 void Close(); | |
30 | |
31 // Sets the location bar icon that should be updated with state changes. | |
32 void SetIcon(ManagePasswordsIcon* icon) { icon_ = icon; } | |
33 | |
34 // Accessor for the global bubble. | |
35 static ManagePasswordsBubbleCocoa* instance() { return bubble_; } | |
36 | |
37 private: | |
38 friend class ManagePasswordsBubbleCocoaTest; | |
39 friend class ManagePasswordsBubbleTest; | |
40 | |
41 // Instance-specific logic. Clients should use the static interface. | |
42 ManagePasswordsBubbleCocoa( | |
43 content::WebContents* webContents, | |
44 ManagePasswordsBubbleModel::DisplayReason displayReason, | |
45 ManagePasswordsIcon* icon); | |
46 ~ManagePasswordsBubbleCocoa(); | |
47 void Show(bool user_action); | |
48 | |
49 // Cleans up state and deletes itself. Called when the bubble is closed. | |
50 void OnClose(); | |
51 | |
52 ManagePasswordsBubbleModel model_; | |
53 | |
54 // The location bar icon corresponding to the bubble. | |
55 ManagePasswordsIcon* icon_; | |
56 | |
57 // Whether there is currently a close operation taking place. Prevents | |
58 // multiple attempts to close the window. | |
59 bool closing_; | |
60 | |
61 // The view controller for the bubble. Weak; owns itself. Must be nilled | |
62 // after the bubble is closed. | |
63 ManagePasswordsBubbleController* controller_; | |
64 | |
65 // WebContents on which the bubble should be displayed. Weak. | |
66 content::WebContents* webContents_; | |
67 | |
68 // Listens for NSNotificationCenter notifications. | |
69 base::scoped_nsobject<ManagePasswordsBubbleCocoaNotificationBridge> bridge_; | |
70 | |
71 // The global bubble instance. Deleted by Close(). | |
72 static ManagePasswordsBubbleCocoa* bubble_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleCocoa); | |
75 }; | |
76 | |
77 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_COCOA_H_ | |
OLD | NEW |