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