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

Side by Side Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 11568036: Add countdown when session time is limited (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
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 "chrome/browser/chromeos/system/ash_system_tray_delegate.h" 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/system/audio/audio_observer.h" 10 #include "ash/system/audio/audio_observer.h"
(...skipping 13 matching lines...) Expand all
24 #include "ash/system/user/update_observer.h" 24 #include "ash/system/user/update_observer.h"
25 #include "ash/system/user/user_observer.h" 25 #include "ash/system/user/user_observer.h"
26 #include "ash/volume_control_delegate.h" 26 #include "ash/volume_control_delegate.h"
27 #include "ash/wm/session_state_controller.h" 27 #include "ash/wm/session_state_controller.h"
28 #include "base/bind_helpers.h" 28 #include "base/bind_helpers.h"
29 #include "base/callback.h" 29 #include "base/callback.h"
30 #include "base/chromeos/chromeos_version.h" 30 #include "base/chromeos/chromeos_version.h"
31 #include "base/command_line.h" 31 #include "base/command_line.h"
32 #include "base/logging.h" 32 #include "base/logging.h"
33 #include "base/memory/weak_ptr.h" 33 #include "base/memory/weak_ptr.h"
34 #include "base/time.h"
34 #include "base/utf_string_conversions.h" 35 #include "base/utf_string_conversions.h"
35 #include "chrome/browser/browser_process.h" 36 #include "chrome/browser/browser_process.h"
36 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 37 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
37 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 38 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
38 #include "chrome/browser/chromeos/audio/audio_handler.h" 39 #include "chrome/browser/chromeos/audio/audio_handler.h"
39 #include "chrome/browser/chromeos/cros/cros_library.h" 40 #include "chrome/browser/chromeos/cros/cros_library.h"
40 #include "chrome/browser/chromeos/cros/network_library.h" 41 #include "chrome/browser/chromeos/cros/network_library.h"
41 #include "chrome/browser/chromeos/drive/drive_system_service.h" 42 #include "chrome/browser/chromeos/drive/drive_system_service.h"
42 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" 43 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
43 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 44 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 : ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST( 177 : ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(
177 new base::WeakPtrFactory<SystemTrayDelegate>(this))), 178 new base::WeakPtrFactory<SystemTrayDelegate>(this))),
178 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( 179 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST(
179 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 180 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
180 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( 181 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST(
181 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 182 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
182 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))), 183 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))),
183 clock_type_(base::k24HourClock), 184 clock_type_(base::k24HourClock),
184 search_key_mapped_to_(input_method::kSearchKey), 185 search_key_mapped_to_(input_method::kSearchKey),
185 screen_locked_(false), 186 screen_locked_(false),
187 is_session_length_limited_(false),
186 data_promo_notification_(new DataPromoNotification()), 188 data_promo_notification_(new DataPromoNotification()),
187 volume_control_delegate_(new VolumeController()) { 189 volume_control_delegate_(new VolumeController()) {
188 // Register notifications on construction so that events such as 190 // Register notifications on construction so that events such as
189 // PROFILE_CREATED do not get missed if they happen before Initialize(). 191 // PROFILE_CREATED do not get missed if they happen before Initialize().
190 registrar_.Add(this, 192 registrar_.Add(this,
191 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 193 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
192 content::NotificationService::AllSources()); 194 content::NotificationService::AllSources());
193 registrar_.Add(this, 195 registrar_.Add(this,
194 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 196 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
195 content::NotificationService::AllSources()); 197 content::NotificationService::AllSources());
196 if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) { 198 if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) {
197 registrar_.Add(this, 199 registrar_.Add(this,
198 chrome::NOTIFICATION_SESSION_STARTED, 200 chrome::NOTIFICATION_SESSION_STARTED,
199 content::NotificationService::AllSources()); 201 content::NotificationService::AllSources());
200 } 202 }
201 registrar_.Add(this, 203 registrar_.Add(this,
202 chrome::NOTIFICATION_PROFILE_CREATED, 204 chrome::NOTIFICATION_PROFILE_CREATED,
203 content::NotificationService::AllSources()); 205 content::NotificationService::AllSources());
204 registrar_.Add(this, 206 registrar_.Add(this,
205 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 207 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
206 content::NotificationService::AllSources()); 208 content::NotificationService::AllSources());
207 registrar_.Add( 209 registrar_.Add(
208 this, 210 this,
209 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, 211 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK,
210 content::NotificationService::AllSources()); 212 content::NotificationService::AllSources());
211 registrar_.Add( 213 registrar_.Add(
212 this, 214 this,
213 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, 215 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE,
214 content::NotificationService::AllSources()); 216 content::NotificationService::AllSources());
217 registrar_.Add(
218 this,
219 chrome::NOTIFICATION_SESSION_LENGTH_UNLIMITED,
220 content::NotificationService::AllSources());
221 registrar_.Add(
222 this,
223 chrome::NOTIFICATION_REMAINING_SESSION_TIME_CHANGED,
224 content::NotificationService::AllSources());
215 } 225 }
216 226
217 virtual void Initialize() OVERRIDE { 227 virtual void Initialize() OVERRIDE {
218 AudioHandler::GetInstance()->AddVolumeObserver(this); 228 AudioHandler::GetInstance()->AddVolumeObserver(this);
219 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); 229 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
220 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate( 230 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(
221 PowerManagerClient::UPDATE_INITIAL); 231 PowerManagerClient::UPDATE_INITIAL);
222 DBusThreadManager::Get()->GetRootPowerManagerClient()->AddObserver(this); 232 DBusThreadManager::Get()->GetRootPowerManagerClient()->AddObserver(this);
223 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 233 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
224 234
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 virtual ash::VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE 775 virtual ash::VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE
766 { 776 {
767 return volume_control_delegate_.get(); 777 return volume_control_delegate_.get();
768 } 778 }
769 779
770 virtual void SetVolumeControlDelegate( 780 virtual void SetVolumeControlDelegate(
771 scoped_ptr<ash::VolumeControlDelegate> delegate) OVERRIDE { 781 scoped_ptr<ash::VolumeControlDelegate> delegate) OVERRIDE {
772 volume_control_delegate_.swap(delegate); 782 volume_control_delegate_.swap(delegate);
773 } 783 }
774 784
785 virtual bool GetSessionLengthLimited() OVERRIDE {
786 return is_session_length_limited_;
787 }
788
789 virtual base::TimeDelta GetRemainingSessionTime() OVERRIDE {
790 return remaining_session_time_;
791 }
792
775 private: 793 private:
776 ash::SystemTray* GetPrimarySystemTray() { 794 ash::SystemTray* GetPrimarySystemTray() {
777 return ash::Shell::GetInstance()->GetPrimarySystemTray(); 795 return ash::Shell::GetInstance()->GetPrimarySystemTray();
778 } 796 }
779 797
780 ash::SystemTrayNotifier* GetSystemTrayNotifier() { 798 ash::SystemTrayNotifier* GetSystemTrayNotifier() {
781 return ash::Shell::GetInstance()->system_tray_notifier(); 799 return ash::Shell::GetInstance()->system_tray_notifier();
782 } 800 }
783 801
784 // Returns the last active browser. If there is no such browser, creates a new 802 // Returns the last active browser. If there is no such browser, creates a new
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 break; 1090 break;
1073 } 1091 }
1074 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK: 1092 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK:
1075 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE: { 1093 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE: {
1076 accessibility::AccessibilityStatusEventDetails* accessibility_status = 1094 accessibility::AccessibilityStatusEventDetails* accessibility_status =
1077 content::Details<accessibility::AccessibilityStatusEventDetails>( 1095 content::Details<accessibility::AccessibilityStatusEventDetails>(
1078 details).ptr(); 1096 details).ptr();
1079 OnAccessibilityModeChanged(accessibility_status->notify); 1097 OnAccessibilityModeChanged(accessibility_status->notify);
1080 break; 1098 break;
1081 } 1099 }
1100 case chrome::NOTIFICATION_SESSION_LENGTH_UNLIMITED:
1101 is_session_length_limited_ = false;
1102 remaining_session_time_ = base::TimeDelta();
1103 GetSystemTrayNotifier()->NotifySessionLengthUnlimited();
1104 break;
1105 case chrome::NOTIFICATION_REMAINING_SESSION_TIME_CHANGED:
1106 is_session_length_limited_ = true;
1107 remaining_session_time_ =
1108 *content::Details<const base::TimeDelta>(details).ptr();
1109 GetSystemTrayNotifier()->NotifyRemainingSessionTimeChanged(
1110 remaining_session_time_);
1111 break;
1082 default: 1112 default:
1083 NOTREACHED(); 1113 NOTREACHED();
1084 } 1114 }
1085 } 1115 }
1086 1116
1087 void OnLanguageRemapSearchKeyToChanged() { 1117 void OnLanguageRemapSearchKeyToChanged() {
1088 search_key_mapped_to_ = pref_registrar_->prefs()->GetInteger( 1118 search_key_mapped_to_ = pref_registrar_->prefs()->GetInteger(
1089 prefs::kLanguageRemapSearchKeyTo); 1119 prefs::kLanguageRemapSearchKeyTo);
1090 } 1120 }
1091 1121
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 scoped_ptr<NetworkMenuIcon> network_icon_dark_; 1277 scoped_ptr<NetworkMenuIcon> network_icon_dark_;
1248 scoped_ptr<NetworkMenu> network_menu_; 1278 scoped_ptr<NetworkMenu> network_menu_;
1249 content::NotificationRegistrar registrar_; 1279 content::NotificationRegistrar registrar_;
1250 scoped_ptr<PrefChangeRegistrar> pref_registrar_; 1280 scoped_ptr<PrefChangeRegistrar> pref_registrar_;
1251 std::string cellular_device_path_; 1281 std::string cellular_device_path_;
1252 std::string active_network_path_; 1282 std::string active_network_path_;
1253 PowerSupplyStatus power_supply_status_; 1283 PowerSupplyStatus power_supply_status_;
1254 base::HourClockType clock_type_; 1284 base::HourClockType clock_type_;
1255 int search_key_mapped_to_; 1285 int search_key_mapped_to_;
1256 bool screen_locked_; 1286 bool screen_locked_;
1287 bool is_session_length_limited_;
1288 base::TimeDelta remaining_session_time_;
1257 1289
1258 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; 1290 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
1259 1291
1260 scoped_ptr<DataPromoNotification> data_promo_notification_; 1292 scoped_ptr<DataPromoNotification> data_promo_notification_;
1261 1293
1262 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_; 1294 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_;
1263 1295
1264 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1296 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1265 }; 1297 };
1266 1298
1267 } // namespace 1299 } // namespace
1268 1300
1269 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1301 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1270 return new chromeos::SystemTrayDelegate(); 1302 return new chromeos::SystemTrayDelegate();
1271 } 1303 }
1272 1304
1273 } // namespace chromeos 1305 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698