Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/page_info_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/page_info_bubble_controller.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/l10n_util_mac.h" | 8 #include "app/l10n_util_mac.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 - (CGFloat)addSeparatorToSubviews:(NSMutableArray*)subviews | 46 - (CGFloat)addSeparatorToSubviews:(NSMutableArray*)subviews |
| 47 atOffset:(CGFloat)offset; | 47 atOffset:(CGFloat)offset; |
| 48 - (NSPoint)anchorPointForWindowWithHeight:(CGFloat)bubbleHeight | 48 - (NSPoint)anchorPointForWindowWithHeight:(CGFloat)bubbleHeight |
| 49 parentWindow:(NSWindow*)parent; | 49 parentWindow:(NSWindow*)parent; |
| 50 @end | 50 @end |
| 51 | 51 |
| 52 // This simple NSView subclass is used as the single subview of the page info | 52 // This simple NSView subclass is used as the single subview of the page info |
| 53 // bubble's window's contentView. Drawing is flipped so that layout of the | 53 // bubble's window's contentView. Drawing is flipped so that layout of the |
| 54 // sections is easier. Apple recommends flipping the coordinate origin when | 54 // sections is easier. Apple recommends flipping the coordinate origin when |
| 55 // doing a lot of text layout because it's more natural. | 55 // doing a lot of text layout because it's more natural. |
| 56 @interface PageInfoContentView : NSView { | 56 @interface PageInfoContentView : NSView { |
|
pink (ping after 24hrs)
2011/01/24 15:59:11
you can omit the braces in this case.
Robert Sesek
2011/01/24 16:39:56
Done.
| |
| 57 } | 57 } |
| 58 @end | 58 @end |
| 59 @implementation PageInfoContentView | 59 @implementation PageInfoContentView |
| 60 - (BOOL)isFlipped { | 60 - (BOOL)isFlipped { |
| 61 return YES; | 61 return YES; |
| 62 } | 62 } |
| 63 @end | 63 @end |
| 64 | 64 |
| 65 namespace { | 65 namespace { |
| 66 | 66 |
| 67 // The width of the window, in view coordinates. The height will be determined | 67 // The width of the window, in view coordinates. The height will be determined |
| 68 // by the content. | 68 // by the content. |
| 69 const NSInteger kWindowWidth = 380; | 69 const NSInteger kWindowWidth = 380; |
|
pink (ping after 24hrs)
2011/01/24 15:59:11
since these are effectively coordinates, should th
Robert Sesek
2011/01/24 16:39:56
Done.
| |
| 70 | 70 |
| 71 // Spacing in between sections. | 71 // Spacing in between sections. |
| 72 const NSInteger kVerticalSpacing = 10; | 72 const NSInteger kVerticalSpacing = 10; |
| 73 | 73 |
| 74 // Padding along on the X-axis between the window frame and content. | 74 // Padding along on the X-axis between the window frame and content. |
| 75 const NSInteger kFramePadding = 10; | 75 const NSInteger kFramePadding = 10; |
| 76 | 76 |
| 77 // Spacing between the optional headline and description text views. | 77 // Spacing between the optional headline and description text views. |
| 78 const NSInteger kHeadlineSpacing = 2; | 78 const NSInteger kHeadlineSpacing = 2; |
| 79 | 79 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 | 387 |
| 388 return NSHeight([certButton frame]); | 388 return NSHeight([certButton frame]); |
| 389 } | 389 } |
| 390 | 390 |
| 391 // Adds the state image at a pre-determined x position and the given y. This | 391 // Adds the state image at a pre-determined x position and the given y. This |
| 392 // does not affect the next Y position because the image is placed next to | 392 // does not affect the next Y position because the image is placed next to |
| 393 // a text field that is larger and accounts for the image's size. | 393 // a text field that is larger and accounts for the image's size. |
| 394 - (void)addImageViewForInfo:(const PageInfoModel::SectionInfo&)info | 394 - (void)addImageViewForInfo:(const PageInfoModel::SectionInfo&)info |
| 395 toSubviews:(NSMutableArray*)subviews | 395 toSubviews:(NSMutableArray*)subviews |
| 396 atOffset:(CGFloat)offset { | 396 atOffset:(CGFloat)offset { |
| 397 NSRect frame = NSMakeRect(kFramePadding, offset, kImageSize, | 397 NSRect frame = NSMakeRect(kFramePadding, offset, kImageSize, |
|
pink (ping after 24hrs)
2011/01/24 15:59:11
i'd probably break this as:
NSRect frame =
NS
Robert Sesek
2011/01/24 16:39:56
Done.
| |
| 398 kImageSize); | 398 kImageSize); |
| 399 scoped_nsobject<NSImageView> imageView( | 399 scoped_nsobject<NSImageView> imageView( |
| 400 [[NSImageView alloc] initWithFrame:frame]); | 400 [[NSImageView alloc] initWithFrame:frame]); |
| 401 [imageView setImageFrameStyle:NSImageFrameNone]; | 401 [imageView setImageFrameStyle:NSImageFrameNone]; |
| 402 [imageView setImage:model_->GetIconImage(info.icon_id)]; | 402 [imageView setImage:model_->GetIconImage(info.icon_id)]; |
| 403 [subviews addObject:imageView.get()]; | 403 [subviews addObject:imageView.get()]; |
| 404 } | 404 } |
| 405 | 405 |
| 406 // Adds the help center button that explains the icons. Returns the y position | 406 // Adds the help center button that explains the icons. Returns the y position |
| 407 // delta for the next offset. | 407 // delta for the next offset. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 LocationBarViewMac* locationBar = [controller locationBarBridge]; | 452 LocationBarViewMac* locationBar = [controller locationBarBridge]; |
| 453 if (locationBar) { | 453 if (locationBar) { |
| 454 NSPoint bubblePoint = locationBar->GetPageInfoBubblePoint(); | 454 NSPoint bubblePoint = locationBar->GetPageInfoBubblePoint(); |
| 455 origin = [parent convertBaseToScreen:bubblePoint]; | 455 origin = [parent convertBaseToScreen:bubblePoint]; |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 return origin; | 458 return origin; |
| 459 } | 459 } |
| 460 | 460 |
| 461 @end | 461 @end |
| OLD | NEW |