Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / notifications / message_center_notification_manager_win.cc
blob4325f50dba3f9ae41a100a8c7ea2118a53e8f67d
1 // Copyright 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.
5 #include "chrome/browser/notifications/message_center_notification_manager.h"
7 #include "ui/message_center/message_center_tray.h"
9 void MessageCenterNotificationManager::DisplayFirstRunBalloon() {
10 // Store for posterity the fact that we've shown the first-run balloon.
11 DCHECK(tray_.get());
12 first_run_pref_.SetValue(true);
13 tray_->DisplayFirstRunBalloon();
16 void MessageCenterNotificationManager::SetFirstRunTimeoutForTest(
17 base::TimeDelta timeout) {
18 first_run_idle_timeout_ = timeout;
21 bool MessageCenterNotificationManager::FirstRunTimerIsActive() const {
22 return first_run_balloon_timer_.IsRunning();
25 void MessageCenterNotificationManager::CheckFirstRunTimer() {
26 // If there is no tray_, we can't display a balloon here anyway.
27 // Also, we only want to display the first run balloon once, so the pref will
28 // store the flag on disk based on whether we ever showed the balloon.
29 DCHECK(tray_.get());
30 if (first_run_pref_.GetValue())
31 return;
33 // If there are popups, the message center is visible, or there are no more
34 // notifications, don't continue the timer since it will be annoying or
35 // useless.
36 if (message_center_->HasPopupNotifications() ||
37 message_center_->IsMessageCenterVisible() ||
38 0 == message_center_->NotificationCount()) {
39 first_run_balloon_timer_.Stop();
40 return;
43 // No need to restart the timer if it's already going.
44 if (first_run_balloon_timer_.IsRunning())
45 return;
47 first_run_balloon_timer_.Start(
48 FROM_HERE,
49 first_run_idle_timeout_,
50 base::Bind(&MessageCenterNotificationManager::DisplayFirstRunBalloon,
51 weak_factory_.GetWeakPtr()));