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