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

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: dimich comments. 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 void MessageCenterNotificationManager::DisplayFirstRunBalloon() {
11 // Store for posterity the fact that we've shown the first-run balloon.
12 DCHECK(tray_.get());
13 first_run_pref_.SetValue(true);
14 tray_->DisplayFirstRunBalloon();
15 }
16
17 void MessageCenterNotificationManager::SetFirstRunTimeoutForTest(
18 base::TimeDelta timeout) {
19 first_run_idle_timeout_ = timeout;
20 }
21
22 bool MessageCenterNotificationManager::FirstRunTimerIsActive() const {
23 return first_run_balloon_timer_.IsRunning();
24 }
25
26 void MessageCenterNotificationManager::CheckFirstRunTimer() {
27 // If there is no tray_, we can't display a balloon here anyway.
28 // Also, we only want to display the first run balloon once, so the pref will
29 // store the flag on disk based on whether we ever showed the balloon.
30 DCHECK(tray_.get());
31 if (first_run_pref_.GetValue())
32 return;
33
34 // If there are popups, the message center is visible, or there are no more
35 // notifications, don't continue the timer since it will be annoying or
36 // useless.
37 if (message_center_->HasPopupNotifications() ||
38 message_center_->IsMessageCenterVisible() ||
39 0 == message_center_->NotificationCount()) {
40 first_run_balloon_timer_.Stop();
41 return;
42 }
43
44 // No need to restart the timer if it's already going.
45 if (first_run_balloon_timer_.IsRunning())
46 return;
47
48 first_run_balloon_timer_.Start(
49 FROM_HERE,
50 first_run_idle_timeout_,
51 base::Bind(&MessageCenterNotificationManager::DisplayFirstRunBalloon,
52 weak_factory_.GetWeakPtr()));
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698