Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: chrome/browser/notifications/message_center_notification_manager_win.cc

Issue 17286015: Adds a first-run balloon to the Windows notification center. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added some tests. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/message_center_notification_manager.h"
6
7 #include "chrome/common/pref_names.h"
8 #include "ui/message_center/message_center_tray.h"
9
10 namespace {
11 // The first-run balloon will be shown |kFirstRunIdleDelaySeconds| after all
12 // popups go away and the user has notifications in the message center.
13 const int kFirstRunIdleDelaySeconds = 1;
14 } // namespace
15
16 void MessageCenterNotificationManager::DisplayFirstRunBalloon() {
17 // Store for posterity the fact that we've shown the first-run balloon.
18 DCHECK(tray_.get());
19 first_run_pref_.SetValue(true);
20 tray_->DisplayFirstRunBalloon();
21 }
22
23 void MessageCenterNotificationManager::CheckFirstRunTimer() {
24 // If there is no tray_, we can't display a balloon here anyway.
25 // Also, we only want to display the first run balloon once, so the pref will
26 // store the flag on disk based on whether we ever showed the balloon.
27 DCHECK(tray_.get());
28 if (first_run_pref_.GetValue())
29 return;
30
31 // If there are popups, the message center is visible, or there are no more
32 // notifications, don't continue the timer since it will be annoying or
33 // useless.
34 if (message_center_->HasPopupNotifications() ||
35 message_center_->IsMessageCenterVisible() ||
36 0 == message_center_->NotificationCount()) {
37 first_run_balloon_timer_.Stop();
38 return;
39 }
40
41 // No need to restart the timer if it's already going.
42 if (first_run_balloon_timer_.IsRunning())
43 return;
44
45 first_run_balloon_timer_.Start(
46 FROM_HERE,
47 first_run_idle_timeout_,
48 base::Bind(&MessageCenterNotificationManager::DisplayFirstRunBalloon,
49 weak_factory_.GetWeakPtr()));
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698