| 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 #include "chrome/browser/cocoa/status_bubble_mac.h" | 5 #include "chrome/browser/cocoa/status_bubble_mac.h" |
| 6 | 6 |
| 7 #include "app/gfx/text_elider.h" | 7 #include "app/gfx/text_elider.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 @private | 49 @private |
| 50 NSString* content_; | 50 NSString* content_; |
| 51 BubbleStyle style_; | 51 BubbleStyle style_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 - (void)setContent:(NSString*)content; | 54 - (void)setContent:(NSString*)content; |
| 55 - (void)setStyle:(BubbleStyle)style; | 55 - (void)setStyle:(BubbleStyle)style; |
| 56 - (NSFont*)font; | 56 - (NSFont*)font; |
| 57 @end | 57 @end |
| 58 | 58 |
| 59 StatusBubbleMac::StatusBubbleMac(NSWindow* parent) | 59 StatusBubbleMac::StatusBubbleMac(NSWindow* parent, id delegate) |
| 60 : parent_(parent), | 60 : parent_(parent), |
| 61 delegate_(delegate), |
| 61 window_(nil), | 62 window_(nil), |
| 62 status_text_(nil), | 63 status_text_(nil), |
| 63 url_text_(nil) { | 64 url_text_(nil), |
| 65 is_download_shelf_visible_(false) { |
| 64 } | 66 } |
| 65 | 67 |
| 66 StatusBubbleMac::~StatusBubbleMac() { | 68 StatusBubbleMac::~StatusBubbleMac() { |
| 67 Hide(); | 69 Hide(); |
| 68 } | 70 } |
| 69 | 71 |
| 70 void StatusBubbleMac::SetStatus(const std::wstring& status) { | 72 void StatusBubbleMac::SetStatus(const std::wstring& status) { |
| 71 Create(); | 73 Create(); |
| 72 | 74 |
| 73 NSString* status_ns = base::SysWideToNSString(status); | 75 NSString* status_ns = base::SysWideToNSString(status); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 offset = NSHeight(window_frame); | 175 offset = NSHeight(window_frame); |
| 174 [[window_ contentView] setStyle:STYLE_BOTTOM]; | 176 [[window_ contentView] setStyle:STYLE_BOTTOM]; |
| 175 } else if (offset > 0) { | 177 } else if (offset > 0) { |
| 176 [[window_ contentView] setStyle:STYLE_FLOATING]; | 178 [[window_ contentView] setStyle:STYLE_FLOATING]; |
| 177 } else { | 179 } else { |
| 178 [[window_ contentView] setStyle:STYLE_STANDARD]; | 180 [[window_ contentView] setStyle:STYLE_STANDARD]; |
| 179 } | 181 } |
| 180 | 182 |
| 181 offset_ = offset; | 183 offset_ = offset; |
| 182 window_frame.origin.y -= offset; | 184 window_frame.origin.y -= offset; |
| 183 [window_ setFrame:window_frame display:YES]; | |
| 184 } else { | 185 } else { |
| 185 offset_ = 0; | 186 offset_ = 0; |
| 186 [[window_ contentView] setStyle:STYLE_STANDARD]; | 187 [[window_ contentView] setStyle:STYLE_STANDARD]; |
| 187 [window_ setFrame:window_frame display:YES]; | |
| 188 } | 188 } |
| 189 |
| 190 // |delegate_| can be nil during unit tests. |
| 191 if (is_download_shelf_visible_) { |
| 192 if ([delegate_ respondsToSelector:@selector(verticalOffsetForStatusBubble)]) |
| 193 window_frame.origin.y += [delegate_ verticalOffsetForStatusBubble]; |
| 194 } |
| 195 |
| 196 [window_ setFrame:window_frame display:YES]; |
| 189 } | 197 } |
| 190 | 198 |
| 191 void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { | 199 void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { |
| 192 NOTIMPLEMENTED(); | 200 is_download_shelf_visible_ = visible; |
| 193 } | 201 } |
| 194 | 202 |
| 195 void StatusBubbleMac::Create() { | 203 void StatusBubbleMac::Create() { |
| 196 if (window_) | 204 if (window_) |
| 197 return; | 205 return; |
| 198 | 206 |
| 199 NSRect rect = [parent_ frame]; | 207 NSRect rect = [parent_ frame]; |
| 200 rect.size.height = kWindowHeight; | 208 rect.size.height = kWindowHeight; |
| 201 rect.size.width = static_cast<int>(kWindowWidthPercent * rect.size.width); | 209 rect.size.width = static_cast<int>(kWindowWidthPercent * rect.size.width); |
| 202 // TODO(avi):fix this for RTL | 210 // TODO(avi):fix this for RTL |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 328 |
| 321 NSDictionary* textDict = [NSDictionary dictionaryWithObjectsAndKeys: | 329 NSDictionary* textDict = [NSDictionary dictionaryWithObjectsAndKeys: |
| 322 textFont, NSFontAttributeName, | 330 textFont, NSFontAttributeName, |
| 323 textShadow, NSShadowAttributeName, | 331 textShadow, NSShadowAttributeName, |
| 324 nil]; | 332 nil]; |
| 325 [content_ drawAtPoint:NSMakePoint(kTextPositionX, kTextPositionY) | 333 [content_ drawAtPoint:NSMakePoint(kTextPositionX, kTextPositionY) |
| 326 withAttributes:textDict]; | 334 withAttributes:textDict]; |
| 327 } | 335 } |
| 328 | 336 |
| 329 @end | 337 @end |
| OLD | NEW |