Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / notifications / message_center_notification_manager_win.cc
blob43525d20733e674fc12e008db12f392516d99f9a
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 "chrome/common/pref_names.h"
8 #include "ui/message_center/message_center_tray.h"
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();
17 void MessageCenterNotificationManager::SetFirstRunTimeoutForTest(
18 base::TimeDelta timeout) {
19 first_run_idle_timeout_ = timeout;
22 bool MessageCenterNotificationManager::FirstRunTimerIsActive() const {
23 return first_run_balloon_timer_.IsRunning();
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;
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;
44 // No need to restart the timer if it's already going.
45 if (first_run_balloon_timer_.IsRunning())
46 return;
48 first_run_balloon_timer_.Start(
49 FROM_HERE,
50 first_run_idle_timeout_,
51 base::Bind(&MessageCenterNotificationManager::DisplayFirstRunBalloon,
52 weak_factory_.GetWeakPtr()));