OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 namespace chromeos { | 111 namespace chromeos { |
112 | 112 |
113 namespace { | 113 namespace { |
114 | 114 |
115 // The minimum session length limit that can be set. | 115 // The minimum session length limit that can be set. |
116 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. | 116 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. |
117 | 117 |
118 // The maximum session length limit that can be set. | 118 // The maximum session length limit that can be set. |
119 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. | 119 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. |
120 | 120 |
| 121 bool UseNewAudioHandler() { |
| 122 return !CommandLine::ForCurrentProcess()-> |
| 123 HasSwitch(ash::switches::kAshDisableNewAudioHandler); |
| 124 } |
| 125 |
121 ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network) { | 126 ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network) { |
122 ash::NetworkIconInfo info; | 127 ash::NetworkIconInfo info; |
123 info.name = network->type() == TYPE_ETHERNET ? | 128 info.name = network->type() == TYPE_ETHERNET ? |
124 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET) : | 129 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET) : |
125 UTF8ToUTF16(network->name()); | 130 UTF8ToUTF16(network->name()); |
126 info.image = NetworkMenuIcon::GetImage(network, NetworkMenuIcon::COLOR_DARK); | 131 info.image = NetworkMenuIcon::GetImage(network, NetworkMenuIcon::COLOR_DARK); |
127 info.service_path = network->service_path(); | 132 info.service_path = network->service_path(); |
128 info.connecting = network->connecting(); | 133 info.connecting = network->connecting(); |
129 info.connected = network->connected(); | 134 info.connected = network->connected(); |
130 info.is_cellular = network->type() == TYPE_CELLULAR; | 135 info.is_cellular = network->type() == TYPE_CELLULAR; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 this, | 298 this, |
294 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, | 299 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, |
295 content::NotificationService::AllSources()); | 300 content::NotificationService::AllSources()); |
296 registrar_.Add( | 301 registrar_.Add( |
297 this, | 302 this, |
298 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, | 303 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, |
299 content::NotificationService::AllSources()); | 304 content::NotificationService::AllSources()); |
300 } | 305 } |
301 | 306 |
302 virtual void Initialize() OVERRIDE { | 307 virtual void Initialize() OVERRIDE { |
303 if (!CommandLine::ForCurrentProcess()-> | 308 if (!UseNewAudioHandler()) { |
304 HasSwitch(ash::switches::kAshEnableNewAudioHandler)) { | |
305 AudioHandler::GetInstance()->AddVolumeObserver(this); | 309 AudioHandler::GetInstance()->AddVolumeObserver(this); |
306 } | 310 } |
307 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 311 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
308 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate( | 312 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate( |
309 PowerManagerClient::UPDATE_INITIAL); | 313 PowerManagerClient::UPDATE_INITIAL); |
310 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 314 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
311 | 315 |
312 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); | 316 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); |
313 crosnet->AddNetworkManagerObserver(this); | 317 crosnet->AddNetworkManagerObserver(this); |
314 OnNetworkManagerChanged(crosnet); | 318 OnNetworkManagerChanged(crosnet); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 policy::BrowserPolicyConnector* policy_connector = | 361 policy::BrowserPolicyConnector* policy_connector = |
358 g_browser_process->browser_policy_connector(); | 362 g_browser_process->browser_policy_connector(); |
359 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 363 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
360 policy_connector->GetDeviceCloudPolicyManager(); | 364 policy_connector->GetDeviceCloudPolicyManager(); |
361 if (policy_manager) | 365 if (policy_manager) |
362 policy_manager->core()->store()->AddObserver(this); | 366 policy_manager->core()->store()->AddObserver(this); |
363 UpdateEnterpriseDomain(); | 367 UpdateEnterpriseDomain(); |
364 } | 368 } |
365 | 369 |
366 virtual ~SystemTrayDelegate() { | 370 virtual ~SystemTrayDelegate() { |
367 if (!CommandLine::ForCurrentProcess()-> | 371 if (!UseNewAudioHandler() && AudioHandler::GetInstance()) { |
368 HasSwitch(ash::switches::kAshEnableNewAudioHandler) && | |
369 AudioHandler::GetInstance()) { | |
370 AudioHandler::GetInstance()->RemoveVolumeObserver(this); | 372 AudioHandler::GetInstance()->RemoveVolumeObserver(this); |
371 } | 373 } |
372 | 374 |
373 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 375 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
374 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 376 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
375 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this); | 377 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this); |
376 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); | 378 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); |
377 if (crosnet) | 379 if (crosnet) |
378 crosnet->RemoveNetworkManagerObserver(this); | 380 crosnet->RemoveNetworkManagerObserver(this); |
379 input_method::GetInputMethodManager()->RemoveObserver(this); | 381 input_method::GetInputMethodManager()->RemoveObserver(this); |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1619 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
1618 }; | 1620 }; |
1619 | 1621 |
1620 } // namespace | 1622 } // namespace |
1621 | 1623 |
1622 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1624 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1623 return new chromeos::SystemTrayDelegate(); | 1625 return new chromeos::SystemTrayDelegate(); |
1624 } | 1626 } |
1625 | 1627 |
1626 } // namespace chromeos | 1628 } // namespace chromeos |
OLD | NEW |