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

Side by Side Diff: ash/system/session_length_limit/tray_session_length_limit.cc

Issue 23464044: Prevents session_length_timeout reappearing when it's already dismissed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/session_length_limit/tray_session_length_limit.h" 5 #include "ash/system/session_length_limit/tray_session_length_limit.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/shelf/shelf_types.h" 9 #include "ash/shelf/shelf_types.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return base::IntToString16(value); 69 return base::IntToString16(value);
70 } 70 }
71 71
72 base::string16 FormatRemainingSessionTimeNotification( 72 base::string16 FormatRemainingSessionTimeNotification(
73 const base::TimeDelta& remaining_session_time) { 73 const base::TimeDelta& remaining_session_time) {
74 return l10n_util::GetStringFUTF16( 74 return l10n_util::GetStringFUTF16(
75 IDS_ASH_STATUS_TRAY_REMAINING_SESSION_TIME_NOTIFICATION, 75 IDS_ASH_STATUS_TRAY_REMAINING_SESSION_TIME_NOTIFICATION,
76 ui::TimeFormat::TimeDurationLong(remaining_session_time)); 76 ui::TimeFormat::TimeDurationLong(remaining_session_time));
77 } 77 }
78 78
79 // Creates, or updates the notification for session length timeout with
80 // |remaining_time|. |state_changed| is true when it's internal state has been
bartfab (slow) 2013/09/09 20:36:30 Nit: s/it's/its/
Jun Mukai 2013/09/09 20:44:25 Done.
81 // changed from another.
79 void CreateOrUpdateNotification(const base::TimeDelta& remaining_time, 82 void CreateOrUpdateNotification(const base::TimeDelta& remaining_time,
80 bool enable_spoken_feedback) { 83 bool state_changed) {
84 message_center::MessageCenter* message_center =
85 message_center::MessageCenter::Get();
86
87 // Do not create a new notification if no state has changed. It may happen
88 // when the notification is already closed by the user, see crbug.com/285941.
89 if (!state_changed &&
90 !message_center->HasNotification(kSessionLengthTimeoutNotificationId)) {
91 return;
92 }
93
81 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 94 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
82 message_center::RichNotificationData data; 95 message_center::RichNotificationData data;
83 data.should_make_spoken_feedback_for_popup_updates = enable_spoken_feedback; 96 // Makes the spoken feedback only when the state has been changed.
97 data.should_make_spoken_feedback_for_popup_updates = state_changed;
84 scoped_ptr<Notification> notification(new Notification( 98 scoped_ptr<Notification> notification(new Notification(
85 message_center::NOTIFICATION_TYPE_SIMPLE, 99 message_center::NOTIFICATION_TYPE_SIMPLE,
86 kSessionLengthTimeoutNotificationId, 100 kSessionLengthTimeoutNotificationId,
87 FormatRemainingSessionTimeNotification(remaining_time), 101 FormatRemainingSessionTimeNotification(remaining_time),
88 base::string16() /* message */, 102 base::string16() /* message */,
89 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SESSION_LENGTH_LIMIT_TIMER), 103 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SESSION_LENGTH_LIMIT_TIMER),
90 base::string16() /* display_source */, 104 base::string16() /* display_source */,
91 message_center::NotifierId(NOTIFIER_SESSION_LENGTH_TIMEOUT), 105 message_center::NotifierId(NOTIFIER_SESSION_LENGTH_TIMEOUT),
92 data, 106 data,
93 NULL /* delegate */)); 107 NULL /* delegate */));
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 368 }
355 369
356 // Update the tray view last so that it can check whether the notification 370 // Update the tray view last so that it can check whether the notification
357 // view is currently visible or not. 371 // view is currently visible or not.
358 if (tray_view_) 372 if (tray_view_)
359 tray_view_->Update(); 373 tray_view_->Update();
360 } 374 }
361 375
362 } // namespace internal 376 } // namespace internal
363 } // namespace ash 377 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698