| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COCOA_STATUS_BUBBLE_MAC_H_ | 5 #ifndef CHROME_BROWSER_COCOA_STATUS_BUBBLE_MAC_H_ |
| 6 #define CHROME_BROWSER_COCOA_STATUS_BUBBLE_MAC_H_ | 6 #define CHROME_BROWSER_COCOA_STATUS_BUBBLE_MAC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #import <Cocoa/Cocoa.h> | 10 #import <Cocoa/Cocoa.h> |
| 11 | 11 |
| 12 #include "chrome/browser/status_bubble.h" | 12 #include "chrome/browser/status_bubble.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 class StatusBubbleMacTest; | 15 class StatusBubbleMacTest; |
| 16 | 16 |
| 17 class StatusBubbleMac : public StatusBubble { | 17 class StatusBubbleMac : public StatusBubble { |
| 18 public: | 18 public: |
| 19 StatusBubbleMac(NSWindow* parent, id delegate); | 19 StatusBubbleMac(NSWindow* parent, id delegate); |
| 20 virtual ~StatusBubbleMac(); | 20 virtual ~StatusBubbleMac(); |
| 21 | 21 |
| 22 // StatusBubble implementation. | 22 // StatusBubble implementation. |
| 23 virtual void SetStatus(const std::wstring& status); | 23 virtual void SetStatus(const std::wstring& status); |
| 24 virtual void SetURL(const GURL& url, const std::wstring& languages); | 24 virtual void SetURL(const GURL& url, const std::wstring& languages); |
| 25 virtual void Hide(); | 25 virtual void Hide(); |
| 26 virtual void MouseMoved(); | 26 virtual void MouseMoved(); |
| 27 virtual void UpdateDownloadShelfVisibility(bool visible); | 27 virtual void UpdateDownloadShelfVisibility(bool visible); |
| 28 | 28 |
| 29 // Mac-specific method: Update the size and position of the status bubble to |
| 30 // match the parent window. Safe to call even when the status bubble does not |
| 31 // exist. |
| 32 void UpdateSizeAndPosition(); |
| 33 |
| 29 private: | 34 private: |
| 30 friend class StatusBubbleMacTest; | 35 friend class StatusBubbleMacTest; |
| 31 | 36 |
| 32 void SetStatus(NSString* status, bool is_url); | 37 void SetStatus(NSString* status, bool is_url); |
| 33 | 38 |
| 34 // Construct the window/widget if it does not already exist. (Safe to call if | 39 // Construct the window/widget if it does not already exist. (Safe to call if |
| 35 // it does.) | 40 // it does.) |
| 36 void Create(); | 41 void Create(); |
| 37 | 42 |
| 38 void FadeIn(); | 43 void FadeIn(); |
| 39 void FadeOut(); | 44 void FadeOut(); |
| 40 | 45 |
| 46 // Calculate the appropriate frame for the status bubble window. |
| 47 NSRect CalculateWindowFrame(); |
| 48 |
| 41 // The window we attach ourselves to. | 49 // The window we attach ourselves to. |
| 42 NSWindow* parent_; // WEAK | 50 NSWindow* parent_; // WEAK |
| 43 | 51 |
| 44 // The object that we query about our vertical offset for positioning. | 52 // The object that we query about our vertical offset for positioning. |
| 45 id delegate_; // WEAK | 53 id delegate_; // WEAK |
| 46 | 54 |
| 47 // The window we own. | 55 // The window we own. |
| 48 NSWindow* window_; | 56 NSWindow* window_; |
| 49 | 57 |
| 50 // The status text we want to display when there are no URLs to display. | 58 // The status text we want to display when there are no URLs to display. |
| 51 NSString* status_text_; | 59 NSString* status_text_; |
| 52 | 60 |
| 53 // The url we want to display when there is no status text to display. | 61 // The url we want to display when there is no status text to display. |
| 54 NSString* url_text_; | 62 NSString* url_text_; |
| 55 | 63 |
| 56 // How vertically offset the bubble is from its root position. | 64 // How vertically offset the bubble is from its root position. |
| 57 int offset_; | 65 int offset_; |
| 58 }; | 66 }; |
| 59 | 67 |
| 60 // Delegate interface that allows the StatusBubble to query its delegate about | 68 // Delegate interface that allows the StatusBubble to query its delegate about |
| 61 // the vertical offset (if any) that should be applied to the StatusBubble's | 69 // the vertical offset (if any) that should be applied to the StatusBubble's |
| 62 // position. | 70 // position. |
| 63 @interface NSObject(StatusBubbleDelegate) | 71 @interface NSObject(StatusBubbleDelegate) |
| 64 - (float)verticalOffsetForStatusBubble; | 72 - (float)verticalOffsetForStatusBubble; |
| 65 @end | 73 @end |
| 66 | 74 |
| 67 #endif // #ifndef CHROME_BROWSER_COCOA_STATUS_BUBBLE_MAC_H_ | 75 #endif // #ifndef CHROME_BROWSER_COCOA_STATUS_BUBBLE_MAC_H_ |
| OLD | NEW |