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