summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 20:56:45 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 20:56:45 +0000
commit5d8128106e8bae8784d9468706198c61c505641b (patch)
treeabeff94d6378255269e0f07ffa3059e3455c9d02 /chrome/browser/cocoa
parent6c46084dc6d2973779b23524e33e2fab4fe2f9ab (diff)
downloadchromium_src-5d8128106e8bae8784d9468706198c61c505641b.zip
chromium_src-5d8128106e8bae8784d9468706198c61c505641b.tar.gz
chromium_src-5d8128106e8bae8784d9468706198c61c505641b.tar.bz2
Make links in the cocoa about dialog clickable.
This replaces an NSTextField with an NSTextView so the file owner can implement some of NSTextView's delegate interface to respond to links. While we're here, also add an additional newline between the main text and the Google build's terms and conditions. BUG=20493 BUG=20855 Review URL: http://codereview.chromium.org/203084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/about_window_controller.h3
-rw-r--r--chrome/browser/cocoa/about_window_controller.mm29
2 files changed, 23 insertions, 9 deletions
diff --git a/chrome/browser/cocoa/about_window_controller.h b/chrome/browser/cocoa/about_window_controller.h
index f9c7528..d69a938 100644
--- a/chrome/browser/cocoa/about_window_controller.h
+++ b/chrome/browser/cocoa/about_window_controller.h
@@ -21,7 +21,8 @@
IBOutlet NSTextField* version_;
IBOutlet BackgroundTileView* backgroundView_;
IBOutlet NSImageView* logoView_;
- IBOutlet NSTextField* legalBlock_;
+ IBOutlet NSView* legalBlock_;
+ IBOutlet NSTextView* legalText_;
IBOutlet NSView* updateBlock_; // Holds everything related to updates
IBOutlet NSProgressIndicator* spinner_;
IBOutlet NSImageView* updateStatusIndicator_;
diff --git a/chrome/browser/cocoa/about_window_controller.mm b/chrome/browser/cocoa/about_window_controller.mm
index 2dff4ed..01f21d9 100644
--- a/chrome/browser/cocoa/about_window_controller.mm
+++ b/chrome/browser/cocoa/about_window_controller.mm
@@ -10,6 +10,7 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#import "chrome/app/keystone_glue.h"
+#include "chrome/browser/browser_list.h"
#import "chrome/browser/cocoa/about_window_controller.h"
#import "chrome/browser/cocoa/background_tile_view.h"
#include "chrome/browser/cocoa/restart_browser.h"
@@ -162,7 +163,7 @@ NSAttributedString* BuildLegalTextBlock() {
NSString* about_terms = base::SysWideToNSString(w_about_terms);
NSString* terms_link_text = l10n_util::GetNSString(IDS_TERMS_OF_SERVICE);
- AttributedStringAppendString(legal_block, @"\n");
+ AttributedStringAppendString(legal_block, @"\n\n");
sub_str = [about_terms substringToIndex:url_offsets[0]];
AttributedStringAppendString(legal_block, sub_str);
AttributedStringAppendHyperlink(legal_block, terms_link_text, kTOS);
@@ -209,9 +210,16 @@ NSAttributedString* BuildLegalTextBlock() {
DCHECK(logoImage);
[logoView_ setImage:logoImage];
- // Put the legal text into
- [legalBlock_ setAttributedStringValue:BuildLegalTextBlock()];
+ [legalText_ insertText:BuildLegalTextBlock()];
+ // Resize our text view now so that the |updateShift| below is set correctly.
+ NSRect oldLegalRect = [legalBlock_ frame];
+ [legalText_ sizeToFit];
+ NSRect newRect = oldLegalRect;
+ newRect.size.height = [legalText_ frame].size.height;
+ [legalBlock_ setFrame:newRect];
+ CGFloat legalShift = newRect.size.height - oldLegalRect.size.height;
+
KeystoneGlue* keystone = [self defaultKeystoneGlue];
CGFloat updateShift = 0.0;
if (keystone) {
@@ -226,12 +234,8 @@ NSAttributedString* BuildLegalTextBlock() {
// (and it's spacing).
updateShift = NSMinY([legalBlock_ frame]) - NSMinY([updateBlock_ frame]);
}
-
+
// Adjust the sizes/locations.
-
- CGFloat legalShift =
- [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:legalBlock_];
-
NSRect rect = [legalBlock_ frame];
rect.origin.y -= updateShift;
[legalBlock_ setFrame:rect];
@@ -380,6 +384,15 @@ NSAttributedString* BuildLegalTextBlock() {
}
}
+- (BOOL)textView:(NSTextView *)aTextView
+ clickedOnLink:(id)link
+ atIndex:(NSUInteger)charIndex {
+ BrowserList::GetLastActive()->
+ OpenURL(GURL([link UTF8String]), GURL(), NEW_WINDOW,
+ PageTransition::LINK);
+ return YES;
+}
+
- (NSButton*)updateButton {
return updateNowButton_;
}