From 4afa7915843c700dda93cf397c66b907a6ec3272 Mon Sep 17 00:00:00 2001 From: "dewittj@chromium.org" Date: Fri, 20 Sep 2013 07:26:40 +0000 Subject: [PATCH] Record when the settings dialog becomes visible on Mac. This supports the notifications UMA collection, which relies on consistent recording of the visibility status of the message center. BUG=228974 Review URL: https://chromiumcodereview.appspot.com/24243006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224324 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/message_center/cocoa/tray_controller.mm | 2 +- ui/message_center/cocoa/tray_view_controller.h | 6 +++++- ui/message_center/cocoa/tray_view_controller.mm | 16 +++++++++++----- ui/message_center/cocoa/tray_view_controller_unittest.mm | 4 +++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ui/message_center/cocoa/tray_controller.mm b/ui/message_center/cocoa/tray_controller.mm index f911ec983538..672525f29dc5 100644 --- a/ui/message_center/cocoa/tray_controller.mm +++ b/ui/message_center/cocoa/tray_controller.mm @@ -105,7 +105,7 @@ // The settings bubble data structures assume that the settings dialog is // visible only for short periods of time: There's a fixed list of permissions // for example. - [viewController_ hideSettings:self]; + [viewController_ cleanupSettings]; tray_->HideMessageCenterBubble(); } diff --git a/ui/message_center/cocoa/tray_view_controller.h b/ui/message_center/cocoa/tray_view_controller.h index cb9379b877c8..d5f9f1f88763 100644 --- a/ui/message_center/cocoa/tray_view_controller.h +++ b/ui/message_center/cocoa/tray_view_controller.h @@ -134,7 +134,11 @@ MESSAGE_CENTER_EXPORT - (void)updateSettings; // Hides the settings dialog if it's open. -- (void)hideSettings:(id)sender; +- (void)showMessages:(id)sender; + +// Cleans up settings data structures. Called when messages are shown and when +// closing the center directly from the settings. +- (void)cleanupSettings; // Scroll to the topmost notification in the tray. - (void)scrollToTop; diff --git a/ui/message_center/cocoa/tray_view_controller.mm b/ui/message_center/cocoa/tray_view_controller.mm index 2290e7e29b29..17c24f73657b 100644 --- a/ui/message_center/cocoa/tray_view_controller.mm +++ b/ui/message_center/cocoa/tray_view_controller.mm @@ -280,7 +280,7 @@ const CGFloat kTrayBottomMargin = 75; - (void)showSettings:(id)sender { if (settingsController_) - return [self hideSettings:sender]; + return [self showMessages:sender]; message_center::NotifierSettingsProvider* provider = messageCenter_->GetNotifierSettingsProvider(); @@ -300,6 +300,7 @@ const CGFloat kTrayBottomMargin = 75; [scrollView_ setHidden:YES]; [[[self view] window] recalculateKeyViewLoop]; + messageCenter_->SetVisibility(message_center::VISIBILITY_SETTINGS); [self updateTrayViewAndWindow]; } @@ -315,7 +316,14 @@ const CGFloat kTrayBottomMargin = 75; [self updateTrayViewAndWindow]; } -- (void)hideSettings:(id)sender { +- (void)showMessages:(id)sender { + messageCenter_->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); + [self cleanupSettings]; + [[[self view] window] recalculateKeyViewLoop]; + [self updateTrayViewAndWindow]; +} + +- (void)cleanupSettings { [scrollView_ setHidden:NO]; [[settingsController_ view] removeFromSuperview]; @@ -327,8 +335,6 @@ const CGFloat kTrayBottomMargin = 75; [backButton_ setHidden:YES]; [clearAllButton_ setEnabled:YES]; - [[[self view] window] recalculateKeyViewLoop]; - [self updateTrayViewAndWindow]; } - (void)scrollToTop { @@ -427,7 +433,7 @@ const CGFloat kTrayBottomMargin = 75; rb.GetNativeImageNamed(IDR_NOTIFICATION_ARROW_HOVER).ToNSImage()]; [backButton_ setPressedImage: rb.GetNativeImageNamed(IDR_NOTIFICATION_ARROW_PRESSED).ToNSImage()]; - [backButton_ setAction:@selector(hideSettings:)]; + [backButton_ setAction:@selector(showMessages:)]; configureButton(backButton_); [backButton_ setHidden:YES]; [backButton_ setKeyEquivalent:@"\e"]; diff --git a/ui/message_center/cocoa/tray_view_controller_unittest.mm b/ui/message_center/cocoa/tray_view_controller_unittest.mm index ce9b080a31ac..03207d965d29 100644 --- a/ui/message_center/cocoa/tray_view_controller_unittest.mm +++ b/ui/message_center/cocoa/tray_view_controller_unittest.mm @@ -225,13 +225,15 @@ TEST_F(TrayViewControllerTest, Settings) { EXPECT_EQ(0, provider.closed_called_count()); [tray_ showSettings:nil]; + EXPECT_FALSE(center_->IsMessageCenterVisible()); // There are 0 notifications, but 2 notifiers. The settings pane should be // higher than the empty tray bubble. EXPECT_LT(trayHeight, NSHeight([[tray_ view] frame])); - [tray_ hideSettings:nil]; + [tray_ showMessages:nil]; EXPECT_EQ(1, provider.closed_called_count()); + EXPECT_TRUE(center_->IsMessageCenterVisible()); // The tray should be back at its previous height now. EXPECT_EQ(trayHeight, NSHeight([[tray_ view] frame])); -- 2.11.4.GIT