| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #import <Cocoa/Cocoa.h> | 11 #import <Cocoa/Cocoa.h> |
| 12 #import <QuartzCore/QuartzCore.h> | 12 #import <QuartzCore/QuartzCore.h> |
| 13 | 13 |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "base/task.h" | 15 #include "base/task.h" |
| 16 #include "chrome/browser/status_bubble.h" | 16 #include "chrome/browser/status_bubble.h" |
| 17 #include "googleurl/src/gurl.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 class StatusBubbleMacTest; | 20 class StatusBubbleMacTest; |
| 20 | 21 |
| 21 class StatusBubbleMac : public StatusBubble { | 22 class StatusBubbleMac : public StatusBubble { |
| 22 public: | 23 public: |
| 23 // The various states that a status bubble may be in. Public for delegate | 24 // The various states that a status bubble may be in. Public for delegate |
| 24 // access (for testing). | 25 // access (for testing). |
| 25 enum StatusBubbleState { | 26 enum StatusBubbleState { |
| 26 kBubbleHidden, // Fully hidden | 27 kBubbleHidden, // Fully hidden |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 // Mac-specific method: Change the parent window of the status bubble. Safe to | 50 // Mac-specific method: Change the parent window of the status bubble. Safe to |
| 50 // call even when the status bubble does not exist. | 51 // call even when the status bubble does not exist. |
| 51 void SwitchParentWindow(NSWindow* parent); | 52 void SwitchParentWindow(NSWindow* parent); |
| 52 | 53 |
| 53 // Delegate method called when a fade-in or fade-out transition has | 54 // Delegate method called when a fade-in or fade-out transition has |
| 54 // completed. This is public so that it may be visible to the CAAnimation | 55 // completed. This is public so that it may be visible to the CAAnimation |
| 55 // delegate, which is an Objective-C object. | 56 // delegate, which is an Objective-C object. |
| 56 void AnimationDidStop(CAAnimation* animation, bool finished); | 57 void AnimationDidStop(CAAnimation* animation, bool finished); |
| 57 | 58 |
| 59 // Expand the bubble to fit a URL too long for the standard bubble size. |
| 60 void ExpandBubble(); |
| 61 |
| 58 private: | 62 private: |
| 59 friend class StatusBubbleMacTest; | 63 friend class StatusBubbleMacTest; |
| 60 | 64 |
| 61 // Setter for state_. Use this instead of writing to state_ directly so | 65 // Setter for state_. Use this instead of writing to state_ directly so |
| 62 // that state changes can be observed by unit tests. | 66 // that state changes can be observed by unit tests. |
| 63 void SetState(StatusBubbleState state); | 67 void SetState(StatusBubbleState state); |
| 64 | 68 |
| 65 // Sets the bubble text for SetStatus and SetURL. | 69 // Sets the bubble text for SetStatus and SetURL. |
| 66 void SetText(const string16& text, bool is_url); | 70 void SetText(const string16& text, bool is_url); |
| 67 | 71 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 96 void StartTimer(int64 time_ms); | 100 void StartTimer(int64 time_ms); |
| 97 void CancelTimer(); | 101 void CancelTimer(); |
| 98 void TimerFired(); | 102 void TimerFired(); |
| 99 | 103 |
| 100 // Begin the process of showing or hiding the status bubble. These may be | 104 // Begin the process of showing or hiding the status bubble. These may be |
| 101 // called from any state, and will take the appropriate action to initiate | 105 // called from any state, and will take the appropriate action to initiate |
| 102 // any state changes that may be needed. | 106 // any state changes that may be needed. |
| 103 void StartShowing(); | 107 void StartShowing(); |
| 104 void StartHiding(); | 108 void StartHiding(); |
| 105 | 109 |
| 110 // Cancel the expansion timer. |
| 111 void CancelExpandTimer(); |
| 112 |
| 106 // The timer factory used for show and hide delay timers. | 113 // The timer factory used for show and hide delay timers. |
| 107 ScopedRunnableMethodFactory<StatusBubbleMac> timer_factory_; | 114 ScopedRunnableMethodFactory<StatusBubbleMac> timer_factory_; |
| 108 | 115 |
| 109 // Calculate the appropriate frame for the status bubble window. | 116 // The timer factory used for the expansion delay timer. |
| 110 NSRect CalculateWindowFrame(); | 117 ScopedRunnableMethodFactory<StatusBubbleMac> expand_timer_factory_; |
| 118 |
| 119 // Calculate the appropriate frame for the status bubble window. If |
| 120 // |expanded_width|, use entire width of parent frame. |
| 121 NSRect CalculateWindowFrame(bool expanded_width); |
| 111 | 122 |
| 112 // The window we attach ourselves to. | 123 // The window we attach ourselves to. |
| 113 NSWindow* parent_; // WEAK | 124 NSWindow* parent_; // WEAK |
| 114 | 125 |
| 115 // The object that we query about our vertical offset for positioning. | 126 // The object that we query about our vertical offset for positioning. |
| 116 id delegate_; // WEAK | 127 id delegate_; // WEAK |
| 117 | 128 |
| 118 // The window we own. | 129 // The window we own. |
| 119 NSWindow* window_; | 130 NSWindow* window_; |
| 120 | 131 |
| 121 // The status text we want to display when there are no URLs to display. | 132 // The status text we want to display when there are no URLs to display. |
| 122 NSString* status_text_; | 133 NSString* status_text_; |
| 123 | 134 |
| 124 // The url we want to display when there is no status text to display. | 135 // The url we want to display when there is no status text to display. |
| 125 NSString* url_text_; | 136 NSString* url_text_; |
| 126 | 137 |
| 127 // The status bubble's current state. Do not write to this field directly; | 138 // The status bubble's current state. Do not write to this field directly; |
| 128 // use SetState(). | 139 // use SetState(). |
| 129 StatusBubbleState state_; | 140 StatusBubbleState state_; |
| 130 | 141 |
| 131 // True if operations are to be performed immediately rather than waiting | 142 // True if operations are to be performed immediately rather than waiting |
| 132 // for delays and transitions. Normally false, this should only be set to | 143 // for delays and transitions. Normally false, this should only be set to |
| 133 // true for testing. | 144 // true for testing. |
| 134 bool immediate_; | 145 bool immediate_; |
| 135 | 146 |
| 147 // True if the status bubble has been expanded. If the bubble is in the |
| 148 // expanded state and encounters a new URL, change size immediately, |
| 149 // with no hover delay. |
| 150 bool is_expanded_; |
| 151 |
| 152 // The original, non-elided URL. |
| 153 GURL url_; |
| 154 |
| 155 // Needs to be passed to ElideURL if the original URL string is wider than |
| 156 // the standard bubble width. |
| 157 string16 languages_; |
| 158 |
| 136 DISALLOW_COPY_AND_ASSIGN(StatusBubbleMac); | 159 DISALLOW_COPY_AND_ASSIGN(StatusBubbleMac); |
| 137 }; | 160 }; |
| 138 | 161 |
| 139 // Delegate interface | 162 // Delegate interface |
| 140 @interface NSObject(StatusBubbleDelegate) | 163 @interface NSObject(StatusBubbleDelegate) |
| 141 // Called to query the delegate about the vertical offset (if any) that should | 164 // Called to query the delegate about the vertical offset (if any) that should |
| 142 // be applied to the StatusBubble's position. | 165 // be applied to the StatusBubble's position. |
| 143 - (CGFloat)verticalOffsetForStatusBubble; | 166 - (CGFloat)verticalOffsetForStatusBubble; |
| 144 | 167 |
| 145 // Called from SetState to notify the delegate of state changes. | 168 // Called from SetState to notify the delegate of state changes. |
| 146 - (void)statusBubbleWillEnterState:(StatusBubbleMac::StatusBubbleState)state; | 169 - (void)statusBubbleWillEnterState:(StatusBubbleMac::StatusBubbleState)state; |
| 147 @end | 170 @end |
| 148 | 171 |
| 149 #endif // #ifndef CHROME_BROWSER_COCOA_STATUS_BUBBLE_MAC_H_ | 172 #endif // #ifndef CHROME_BROWSER_COCOA_STATUS_BUBBLE_MAC_H_ |
| OLD | NEW |