Mac: Support 10.10's -[NSViewController viewDidLoad] for BookmarkBarController
This is to prevent a crash which appears to be triggered from an unexpected codepath during NIB loading. After linking to the 10.10 SDK, a similar crash during NIB loading for the ToolbarController began. This was fixed by supporting initialization via the newly introduced -[NSViewController viewDidLoad] on 10.10, and via [NSViewController awakeFromNib] on older OSes. However, crash logs suggest that the fault moved on to the next NIB load, in BookmarkBarController, which happens just after ToolbarController in -[BrowserWindowController initWithBrowser:..]. To fix, apply a similar fix to the one for BookmarkBarController in r346604. BUG=528136 Review URL: https://codereview.chromium.org/1356023002 Cr-Commit-Position: refs/heads/master@{#350264}
This commit is contained in:
base/mac
chrome/browser/ui/cocoa
@ -491,6 +491,10 @@ BASE_EXPORT extern NSString* const NSAppearanceNameVibrantDark;
|
||||
- (NSString*)UUIDString;
|
||||
@end
|
||||
|
||||
@interface NSViewController (YosemiteSDK)
|
||||
- (void)viewDidLoad;
|
||||
@end
|
||||
|
||||
#endif // MAC_OS_X_VERSION_10_10
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -5,6 +5,7 @@
|
||||
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
|
||||
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/sdk_forward_declarations.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@ -151,7 +152,7 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface BookmarkBarController(Private)
|
||||
@interface BookmarkBarController ()
|
||||
|
||||
// Moves to the given next state (from the current state), possibly animating.
|
||||
// If |animate| is NO, it will stop any running animation and jump to the given
|
||||
@ -224,7 +225,6 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
||||
- (void)clearMenuTagMap;
|
||||
- (int)preferredHeight;
|
||||
- (void)addButtonsToView;
|
||||
- (BOOL)setBookmarkButtonVisibility;
|
||||
- (BOOL)setManagedBookmarksButtonVisibility;
|
||||
- (BOOL)setSupervisedBookmarksButtonVisibility;
|
||||
- (BOOL)setOtherBookmarksButtonVisibility;
|
||||
@ -400,6 +400,17 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
||||
}
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[self viewDidLoad];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
if (bridge_) {
|
||||
// When running on 10.10, expect both -awakeFromNib and -viewDidLoad to be
|
||||
// called, but only initialize once.
|
||||
DCHECK(base::mac::IsOSYosemiteOrLater());
|
||||
return;
|
||||
}
|
||||
|
||||
// We default to NOT open, which means height=0.
|
||||
DCHECK([[self view] isHidden]); // Hidden so it's OK to change.
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/sdk_forward_declarations.h"
|
||||
#include "base/memory/singleton.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@ -121,10 +122,6 @@ CGFloat BrowserActionsContainerDelegate::GetMaxAllowedWidth() {
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface ToolbarController (YosemiteSDK)
|
||||
- (void)viewDidLoad;
|
||||
@end
|
||||
|
||||
@interface ToolbarController()
|
||||
@property(assign, nonatomic) Browser* browser;
|
||||
- (void)cleanUp;
|
||||
@ -265,12 +262,7 @@ class NotificationBridge : public WrenchMenuBadgeController::Delegate {
|
||||
// When linking and running on 10.10+, both -awakeFromNib and -viewDidLoad may
|
||||
// be called, don't initialize twice.
|
||||
if (locationBarView_) {
|
||||
#if defined(MAC_OS_X_VERSION_10_10) && \
|
||||
MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
|
||||
DCHECK(base::mac::IsOSYosemiteOrLater());
|
||||
#else
|
||||
NOTREACHED();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user