diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/download_shelf_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/download_shelf_controller.mm | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/download_shelf_controller.h b/chrome/browser/cocoa/download_shelf_controller.h index 86c5535..58241c6 100644 --- a/chrome/browser/cocoa/download_shelf_controller.h +++ b/chrome/browser/cocoa/download_shelf_controller.h @@ -15,6 +15,8 @@ class DownloadShelf; @interface DownloadShelfController : NSViewController { @private + IBOutlet NSTextView* showAllDownloadsLink_; + // Currently these two are always the same, but they mean slightly // different things. contentAreaHasOffset_ is an implementation // detail of download shelf visibility. diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm index b82f67f..e0b8cd0 100644 --- a/chrome/browser/cocoa/download_shelf_controller.mm +++ b/chrome/browser/cocoa/download_shelf_controller.mm @@ -4,11 +4,14 @@ #import "download_shelf_controller.h" +#include "app/l10n_util.h" #include "base/mac_util.h" +#include "base/sys_string_conversions.h" #import "chrome/browser/cocoa/browser_window_controller.h" #include "chrome/browser/cocoa/browser_window_cocoa.h" #include "chrome/browser/cocoa/download_shelf_mac.h" #import "chrome/browser/cocoa/download_shelf_view.h" +#include "grit/generated_resources.h" @interface DownloadShelfController(Private) @@ -36,6 +39,35 @@ return self; } +- (void)awakeFromNib { + // Initialize "Show all downloads" link. + + scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( + [[NSParagraphStyle defaultParagraphStyle] mutableCopy]); + // TODO(thakis): left-align for RTL languages? + [paragraphStyle.get() setAlignment:NSRightTextAlignment]; + + NSDictionary* linkAttributes = [NSDictionary dictionaryWithObjectsAndKeys: + self, NSLinkAttributeName, + [NSCursor pointingHandCursor], NSCursorAttributeName, + paragraphStyle.get(), NSParagraphStyleAttributeName, + nil]; + NSString* text = + base::SysWideToNSString(l10n_util::GetString(IDS_SHOW_ALL_DOWNLOADS)); + scoped_nsobject<NSAttributedString> linkText([[NSAttributedString alloc] + initWithString:text attributes:linkAttributes]); + + [[showAllDownloadsLink_ textStorage] setAttributedString:linkText.get()]; + [showAllDownloadsLink_ setDelegate:self]; +} + +- (BOOL)textView:(NSTextView *)aTextView + clickedOnLink:(id)link + atIndex:(NSUInteger)charIndex { + bridge_->ShowAllDownloads(); + return YES; +} + // Initializes the download shelf at the bottom edge of |contentArea_|. - (void)positionBar { // Set the bar's height to zero and position it at the bottom of the |