diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 14:12:58 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 14:12:58 +0000 |
commit | 7d9fb9604607d94b8606eac97b2d64f923923a08 (patch) | |
tree | 22cf4eb0b6503d28b1dd9c009ef9184bb814b771 | |
parent | 4390566bc73e8fb05433b04de73a73f190a724da (diff) | |
download | chromium_src-7d9fb9604607d94b8606eac97b2d64f923923a08.zip chromium_src-7d9fb9604607d94b8606eac97b2d64f923923a08.tar.gz chromium_src-7d9fb9604607d94b8606eac97b2d64f923923a08.tar.bz2 |
Allow the about window to create a new window to handle loading web pages if there is none currently available.
BUG=24234
TEST=clicking links in about window with and without browsers open.
Review URL: http://codereview.chromium.org/272013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28814 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/about_window_controller.h | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/about_window_controller.mm | 16 | ||||
-rw-r--r-- | chrome/browser/cocoa/about_window_controller_unittest.mm | 2 |
4 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index a45907e..9690a81 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -646,7 +646,7 @@ // Otherwise bring up our special dialog (e.g. with an auto-update button). if (!aboutController_) { aboutController_.reset([[AboutWindowController alloc] - initWithWindowNibName:@"About"]); + initWithProfile:[self defaultProfile]]); if (!aboutController_) { // If we get here something is wacky. I managed to do it when // testing by explicitly forcing an auto-update to an older diff --git a/chrome/browser/cocoa/about_window_controller.h b/chrome/browser/cocoa/about_window_controller.h index 63ed4f1..d3117bb 100644 --- a/chrome/browser/cocoa/about_window_controller.h +++ b/chrome/browser/cocoa/about_window_controller.h @@ -10,6 +10,7 @@ #import "chrome/app/keystone_glue.h" @class BackgroundTileView; +class Profile; // Returns an NSAttributedString that contains the locale specific legal text. NSAttributedString* BuildAboutWindowLegalTextBlock(); @@ -33,11 +34,16 @@ NSAttributedString* BuildAboutWindowLegalTextBlock(); IBOutlet NSButton* updateNowButton_; BOOL updateTriggered_; // Has an update ever been triggered? + Profile* profile_; // Weak, probably the default profile. // The version we got told about by Keystone scoped_nsobject<NSString> newVersionAvailable_; } +// Initialize the controller with the given profile, but does not show it. +// Callers still need to call showWindow: to put it on screen. +- (id)initWithProfile:(Profile*)profile; + // Trigger an update right now, as initiated by a button. - (IBAction)updateNow:(id)sender; diff --git a/chrome/browser/cocoa/about_window_controller.mm b/chrome/browser/cocoa/about_window_controller.mm index f6fe70d..936dc8a 100644 --- a/chrome/browser/cocoa/about_window_controller.mm +++ b/chrome/browser/cocoa/about_window_controller.mm @@ -189,10 +189,13 @@ NSAttributedString* BuildAboutWindowLegalTextBlock() { @implementation AboutWindowController -- (id)initWithWindowNibName:(NSString*)nibName { - NSString* nibpath = [mac_util::MainAppBundle() pathForResource:nibName +- (id)initWithProfile:(Profile*)profile { + NSString* nibpath = [mac_util::MainAppBundle() pathForResource:@"About" ofType:@"nib"]; self = [super initWithWindowNibPath:nibpath owner:self]; + if (self) { + profile_ = profile; + } return self; } @@ -404,9 +407,12 @@ NSAttributedString* BuildAboutWindowLegalTextBlock() { - (BOOL)textView:(NSTextView *)aTextView clickedOnLink:(id)link atIndex:(NSUInteger)charIndex { - BrowserList::GetLastActive()-> - OpenURL(GURL([link UTF8String]), GURL(), NEW_WINDOW, - PageTransition::LINK); + // We always create a new window, so there's no need to try to re-use + // an existing one just to pass in the NEW_WINDOW disposition. + Browser* browser = Browser::Create(profile_); + if (browser) + browser->OpenURL(GURL([link UTF8String]), GURL(), NEW_WINDOW, + PageTransition::LINK); return YES; } diff --git a/chrome/browser/cocoa/about_window_controller_unittest.mm b/chrome/browser/cocoa/about_window_controller_unittest.mm index 2ce86ac..3117b08 100644 --- a/chrome/browser/cocoa/about_window_controller_unittest.mm +++ b/chrome/browser/cocoa/about_window_controller_unittest.mm @@ -18,7 +18,7 @@ class AboutWindowControllerTest : public PlatformTest { virtual void SetUp() { PlatformTest::SetUp(); about_window_controller_.reset([[AboutWindowController alloc] - initWithWindowNibName:@"About"]); + initWithProfile:nil]); // make sure the nib is loaded [about_window_controller_ window]; } |