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