| 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(); | 30 void Close(bool no_animation = false); |
| 31 | 31 |
| 32 // Sets the location bar icon that should be updated with state changes. | 32 // Sets the location bar icon that should be updated with state changes. |
| 33 void SetIcon(ManagePasswordsIcon* icon) { icon_ = icon; } | 33 void SetIcon(ManagePasswordsIcon* icon) { icon_ = icon; } |
| 34 | 34 |
| 35 // Accessor for the global bubble. | 35 // Accessor for the global bubble. |
| 36 static ManagePasswordsBubbleCocoa* instance() { return bubble_; } | 36 static ManagePasswordsBubbleCocoa* instance() { return bubble_; } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 friend class ManagePasswordsBubbleCocoaTest; | 39 friend class ManagePasswordsBubbleCocoaTest; |
| 40 friend class ManagePasswordsBubbleTest; | 40 friend class ManagePasswordsBubbleTest; |
| 41 | 41 |
| 42 // Instance-specific logic. Clients should use the static interface. | 42 // Instance-specific logic. Clients should use the static interface. |
| 43 ManagePasswordsBubbleCocoa( | 43 ManagePasswordsBubbleCocoa( |
| 44 content::WebContents* webContents, | 44 content::WebContents* webContents, |
| 45 ManagePasswordsBubbleModel::DisplayReason displayReason, | 45 ManagePasswordsBubbleModel::DisplayReason displayReason, |
| 46 ManagePasswordsIcon* icon); | 46 ManagePasswordsIcon* icon); |
| 47 ~ManagePasswordsBubbleCocoa(); | 47 ~ManagePasswordsBubbleCocoa(); |
| 48 void Show(bool user_action); | 48 void Show(bool user_action); |
| 49 | 49 |
| 50 // Cleans up state and deletes itself. Called when the bubble is closed. | 50 // Cleans up state and deletes itself. Called when the bubble is closed. |
| 51 void OnClose(); | 51 void OnClose(); |
| 52 | 52 |
| 53 ManagePasswordsBubbleModel model_; | 53 ManagePasswordsBubbleModel model_; |
| 54 | 54 |
| 55 // The location bar icon corresponding to the bubble. | 55 // The location bar icon corresponding to the bubble. |
| 56 ManagePasswordsIcon* icon_; | 56 ManagePasswordsIcon* icon_; |
| 57 | 57 |
| 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 | 58 // The view controller for the bubble. Weak; owns itself. Must be nilled |
| 63 // after the bubble is closed. | 59 // after the bubble is closed. |
| 64 ManagePasswordsBubbleController* controller_; | 60 ManagePasswordsBubbleController* controller_; |
| 65 | 61 |
| 66 // WebContents on which the bubble should be displayed. Weak. | 62 // WebContents on which the bubble should be displayed. Weak. |
| 67 content::WebContents* webContents_; | 63 content::WebContents* webContents_; |
| 68 | 64 |
| 69 // Listens for NSNotificationCenter notifications. | 65 // Listens for NSNotificationCenter notifications. |
| 70 base::scoped_nsobject<ManagePasswordsBubbleCocoaNotificationBridge> bridge_; | 66 base::scoped_nsobject<ManagePasswordsBubbleCocoaNotificationBridge> bridge_; |
| 71 | 67 |
| 72 // The global bubble instance. Deleted by Close(). | 68 // The global bubble instance. Deleted by Close(). |
| 73 static ManagePasswordsBubbleCocoa* bubble_; | 69 static ManagePasswordsBubbleCocoa* bubble_; |
| 74 | 70 |
| 75 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleCocoa); | 71 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleCocoa); |
| 76 }; | 72 }; |
| 77 | 73 |
| 78 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_PASSWORDS_BUBBLE_COCOA_H_ | 74 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_PASSWORDS_BUBBLE_COCOA_H_ |
| OLD | NEW |