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

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

Issue 15350002: Deprecate kAshDisableNewNetworkStatusArea (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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
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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "chrome/browser/chromeos/login/login_wizard.h" 59 #include "chrome/browser/chromeos/login/login_wizard.h"
60 #include "chrome/browser/chromeos/login/startup_utils.h" 60 #include "chrome/browser/chromeos/login/startup_utils.h"
61 #include "chrome/browser/chromeos/login/user.h" 61 #include "chrome/browser/chromeos/login/user.h"
62 #include "chrome/browser/chromeos/login/user_manager.h" 62 #include "chrome/browser/chromeos/login/user_manager.h"
63 #include "chrome/browser/chromeos/mobile_config.h" 63 #include "chrome/browser/chromeos/mobile_config.h"
64 #include "chrome/browser/chromeos/options/network_config_view.h" 64 #include "chrome/browser/chromeos/options/network_config_view.h"
65 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 65 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
66 #include "chrome/browser/chromeos/sim_dialog_delegate.h" 66 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
67 #include "chrome/browser/chromeos/status/data_promo_notification.h" 67 #include "chrome/browser/chromeos/status/data_promo_notification.h"
68 #include "chrome/browser/chromeos/status/network_menu.h" 68 #include "chrome/browser/chromeos/status/network_menu.h"
69 #include "chrome/browser/chromeos/status/network_menu_icon.h"
70 #include "chrome/browser/chromeos/system/timezone_settings.h" 69 #include "chrome/browser/chromeos/system/timezone_settings.h"
71 #include "chrome/browser/chromeos/system_key_event_listener.h" 70 #include "chrome/browser/chromeos/system_key_event_listener.h"
72 #include "chrome/browser/google/google_util.h" 71 #include "chrome/browser/google/google_util.h"
73 #include "chrome/browser/google_apis/drive_service_interface.h" 72 #include "chrome/browser/google_apis/drive_service_interface.h"
74 #include "chrome/browser/lifetime/application_lifetime.h" 73 #include "chrome/browser/lifetime/application_lifetime.h"
75 #include "chrome/browser/policy/browser_policy_connector.h" 74 #include "chrome/browser/policy/browser_policy_connector.h"
76 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 75 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
77 #include "chrome/browser/profiles/profile_manager.h" 76 #include "chrome/browser/profiles/profile_manager.h"
78 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" 77 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
79 #include "chrome/browser/ui/browser.h" 78 #include "chrome/browser/ui/browser.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 namespace chromeos { 116 namespace chromeos {
118 117
119 namespace { 118 namespace {
120 119
121 // The minimum session length limit that can be set. 120 // The minimum session length limit that can be set.
122 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. 121 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds.
123 122
124 // The maximum session length limit that can be set. 123 // The maximum session length limit that can be set.
125 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. 124 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours.
126 125
127 ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network) {
128 ash::NetworkIconInfo info;
129 info.name = network->type() == TYPE_ETHERNET ?
130 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET) :
131 UTF8ToUTF16(network->name());
132 info.image = NetworkMenuIcon::GetImage(network, NetworkMenuIcon::COLOR_DARK);
133 info.service_path = network->service_path();
134 info.connecting = network->connecting();
135 info.connected = network->connected();
136 info.is_cellular = network->type() == TYPE_CELLULAR;
137 return info;
138 }
139
140 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, 126 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime,
141 const input_method::InputMethodUtil& util, 127 const input_method::InputMethodUtil& util,
142 ash::IMEInfo* info) { 128 ash::IMEInfo* info) {
143 info->id = ime.id(); 129 info->id = ime.id();
144 info->name = util.GetInputMethodLongName(ime); 130 info->name = util.GetInputMethodLongName(ime);
145 info->medium_name = util.GetInputMethodMediumName(ime); 131 info->medium_name = util.GetInputMethodMediumName(ime);
146 info->short_name = util.GetInputMethodShortName(ime); 132 info->short_name = util.GetInputMethodShortName(ime);
147 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); 133 info->third_party = extension_ime_util::IsExtensionIME(ime.id());
148 } 134 }
149 135
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if (cellular->network_technology() == NETWORK_TECHNOLOGY_LTE || 218 if (cellular->network_technology() == NETWORK_TECHNOLOGY_LTE ||
233 cellular->network_technology() == NETWORK_TECHNOLOGY_LTE_ADVANCED) 219 cellular->network_technology() == NETWORK_TECHNOLOGY_LTE_ADVANCED)
234 return ash::NetworkObserver::NETWORK_CELLULAR_LTE; 220 return ash::NetworkObserver::NETWORK_CELLULAR_LTE;
235 return ash::NetworkObserver::NETWORK_CELLULAR; 221 return ash::NetworkObserver::NETWORK_CELLULAR;
236 } 222 }
237 223
238 class SystemTrayDelegate : public ash::SystemTrayDelegate, 224 class SystemTrayDelegate : public ash::SystemTrayDelegate,
239 public AudioHandler::VolumeObserver, 225 public AudioHandler::VolumeObserver,
240 public PowerManagerClient::Observer, 226 public PowerManagerClient::Observer,
241 public SessionManagerClient::Observer, 227 public SessionManagerClient::Observer,
242 public NetworkMenuIcon::Delegate,
243 public NetworkMenu::Delegate, 228 public NetworkMenu::Delegate,
244 public NetworkLibrary::NetworkManagerObserver, 229 public NetworkLibrary::NetworkManagerObserver,
245 public NetworkLibrary::NetworkObserver,
246 public drive::JobListObserver, 230 public drive::JobListObserver,
247 public content::NotificationObserver, 231 public content::NotificationObserver,
248 public input_method::InputMethodManager::Observer, 232 public input_method::InputMethodManager::Observer,
249 public system::TimezoneSettings::Observer, 233 public system::TimezoneSettings::Observer,
250 public chromeos::SystemClockClient::Observer, 234 public chromeos::SystemClockClient::Observer,
251 public device::BluetoothAdapter::Observer, 235 public device::BluetoothAdapter::Observer,
252 public SystemKeyEventListener::CapsLockObserver, 236 public SystemKeyEventListener::CapsLockObserver,
253 public ash::NetworkTrayDelegate, 237 public ash::NetworkTrayDelegate,
254 public policy::CloudPolicyStore::Observer { 238 public policy::CloudPolicyStore::Observer {
255 public: 239 public:
256 SystemTrayDelegate() 240 SystemTrayDelegate()
257 : ui_weak_ptr_factory_( 241 : ui_weak_ptr_factory_(
258 new base::WeakPtrFactory<SystemTrayDelegate>(this)), 242 new base::WeakPtrFactory<SystemTrayDelegate>(this)),
259 network_icon_(new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE)),
260 network_icon_dark_(
261 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE)),
262 network_icon_vpn_(
263 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE)),
264 network_menu_(new NetworkMenu(this)),
265 clock_type_(base::k24HourClock), 243 clock_type_(base::k24HourClock),
266 search_key_mapped_to_(input_method::kSearchKey), 244 search_key_mapped_to_(input_method::kSearchKey),
267 screen_locked_(false), 245 screen_locked_(false),
268 have_session_start_time_(false), 246 have_session_start_time_(false),
269 have_session_length_limit_(false), 247 have_session_length_limit_(false),
270 data_promo_notification_(new DataPromoNotification()), 248 data_promo_notification_(new DataPromoNotification()),
271 cellular_activating_(false), 249 cellular_activating_(false),
272 cellular_out_of_credits_(false), 250 cellular_out_of_credits_(false),
273 volume_control_delegate_(new VolumeController()) { 251 volume_control_delegate_(new VolumeController()) {
252 if (!CommandLine::ForCurrentProcess()->HasSwitch(
253 chromeos::switches::kUseNewNetworkConfigurationHandlers)) {
254 network_menu_.reset(new NetworkMenu(this));
255 }
256
274 // Register notifications on construction so that events such as 257 // Register notifications on construction so that events such as
275 // PROFILE_CREATED do not get missed if they happen before Initialize(). 258 // PROFILE_CREATED do not get missed if they happen before Initialize().
276 registrar_.Add(this, 259 registrar_.Add(this,
277 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 260 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
278 content::NotificationService::AllSources()); 261 content::NotificationService::AllSources());
279 registrar_.Add(this, 262 registrar_.Add(this,
280 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 263 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
281 content::NotificationService::AllSources()); 264 content::NotificationService::AllSources());
282 if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) { 265 if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) {
283 registrar_.Add(this, 266 registrar_.Add(this,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 OnNetworkManagerChanged(crosnet); 299 OnNetworkManagerChanged(crosnet);
317 300
318 input_method::InputMethodManager::Get()->AddObserver(this); 301 input_method::InputMethodManager::Get()->AddObserver(this);
319 302
320 system::TimezoneSettings::GetInstance()->AddObserver(this); 303 system::TimezoneSettings::GetInstance()->AddObserver(this);
321 DBusThreadManager::Get()->GetSystemClockClient()->AddObserver(this); 304 DBusThreadManager::Get()->GetSystemClockClient()->AddObserver(this);
322 305
323 if (SystemKeyEventListener::GetInstance()) 306 if (SystemKeyEventListener::GetInstance())
324 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); 307 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this);
325 308
326 network_icon_->SetResourceColorTheme(NetworkMenuIcon::COLOR_LIGHT);
327 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK);
328 network_icon_vpn_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK);
329
330 device::BluetoothAdapterFactory::GetAdapter( 309 device::BluetoothAdapterFactory::GetAdapter(
331 base::Bind(&SystemTrayDelegate::InitializeOnAdapterReady, 310 base::Bind(&SystemTrayDelegate::InitializeOnAdapterReady,
332 ui_weak_ptr_factory_->GetWeakPtr())); 311 ui_weak_ptr_factory_->GetWeakPtr()));
333 } 312 }
334 313
335 virtual void Shutdown() OVERRIDE { 314 virtual void Shutdown() OVERRIDE {
336 data_promo_notification_.reset(); 315 data_promo_notification_.reset();
337 } 316 }
338 317
339 void InitializeOnAdapterReady( 318 void InitializeOnAdapterReady(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED: 419 case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED:
441 return ash::user::LOGGED_IN_LOCALLY_MANAGED; 420 return ash::user::LOGGED_IN_LOCALLY_MANAGED;
442 case LoginState::LOGGED_IN_USER_KIOSK_APP: 421 case LoginState::LOGGED_IN_USER_KIOSK_APP:
443 return ash::user::LOGGED_IN_KIOSK_APP; 422 return ash::user::LOGGED_IN_KIOSK_APP;
444 } 423 }
445 NOTREACHED(); 424 NOTREACHED();
446 return ash::user::LOGGED_IN_NONE; 425 return ash::user::LOGGED_IN_NONE;
447 } 426 }
448 427
449 virtual bool IsOobeCompleted() const OVERRIDE { 428 virtual bool IsOobeCompleted() const OVERRIDE {
429 if (!base::chromeos::IsRunningOnChromeOS() &&
430 LoginState::Get()->GetLoggedInState() == LoginState::LOGGED_IN_ACTIVE)
431 return true;
450 return StartupUtils::IsOobeCompleted(); 432 return StartupUtils::IsOobeCompleted();
451 } 433 }
452 434
453 virtual void GetLoggedInUsers(ash::UserEmailList* users) OVERRIDE { 435 virtual void GetLoggedInUsers(ash::UserEmailList* users) OVERRIDE {
454 const UserList& logged_in_users = UserManager::Get()->GetLoggedInUsers(); 436 const UserList& logged_in_users = UserManager::Get()->GetLoggedInUsers();
455 for (UserList::const_iterator it = logged_in_users.begin(); 437 for (UserList::const_iterator it = logged_in_users.begin();
456 it != logged_in_users.end(); ++it) { 438 it != logged_in_users.end(); ++it) {
457 const User* user = (*it); 439 const User* user = (*it);
458 users->push_back(user->email()); 440 users->push_back(user->email());
459 } 441 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 virtual void GetDriveOperationStatusList( 753 virtual void GetDriveOperationStatusList(
772 ash::DriveOperationStatusList* list) OVERRIDE { 754 ash::DriveOperationStatusList* list) OVERRIDE {
773 DriveSystemService* system_service = FindDriveSystemService(); 755 DriveSystemService* system_service = FindDriveSystemService();
774 if (!system_service) 756 if (!system_service)
775 return; 757 return;
776 758
777 *list = ConvertToDriveStatusList( 759 *list = ConvertToDriveStatusList(
778 system_service->job_list()->GetJobInfoList()); 760 system_service->job_list()->GetJobInfoList());
779 } 761 }
780 762
781
782 virtual void GetMostRelevantNetworkIcon(ash::NetworkIconInfo* info,
783 bool dark) OVERRIDE {
784 NetworkMenuIcon* icon =
785 dark ? network_icon_dark_.get() : network_icon_.get();
786 info->image = icon->GetIconAndText(&info->description);
787 info->tray_icon_visible = icon->ShouldShowIconInTray();
788 }
789
790 virtual void GetVirtualNetworkIcon(ash::NetworkIconInfo* info) OVERRIDE {
791 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
792 if (crosnet->virtual_network_connected()) {
793 NetworkMenuIcon* icon = network_icon_vpn_.get();
794 info->image = icon->GetVpnIconAndText(&info->description);
795 info->tray_icon_visible = false;
796 } else {
797 gfx::ImageSkia* image = NetworkMenuIcon::GetVirtualNetworkImage();
798 info->image = *image;
799 info->description = l10n_util::GetStringUTF16(
800 IDS_ASH_STATUS_TRAY_VPN_DISCONNECTED);
801 }
802 }
803
804 virtual void GetAvailableNetworks(
805 std::vector<ash::NetworkIconInfo>* list) OVERRIDE {
806 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
807
808 std::set<const Network*> added;
809
810 // Add the active network first.
811 if (crosnet->active_nonvirtual_network())
812 AddNetworkToList(list, &added, crosnet->active_nonvirtual_network());
813
814 if (crosnet->ethernet_network() &&
815 crosnet->ethernet_network()->connecting_or_connected()) {
816 AddNetworkToList(list, &added, crosnet->ethernet_network());
817 }
818 if (crosnet->cellular_network()
819 && crosnet->cellular_network()->connecting_or_connected()) {
820 AddNetworkToList(list, &added, crosnet->cellular_network());
821 }
822 if (crosnet->wimax_network()
823 && crosnet->wimax_network()->connecting_or_connected()) {
824 AddNetworkToList(list, &added, crosnet->wimax_network());
825 }
826 if (crosnet->wifi_network()
827 && crosnet->wifi_network()->connecting_or_connected()) {
828 AddNetworkToList(list, &added, crosnet->wifi_network());
829 }
830
831 // Add remaining networks by type.
832
833 // Ethernet.
834 if (crosnet->ethernet_available() && crosnet->ethernet_enabled()) {
835 const EthernetNetwork* ethernet_network = crosnet->ethernet_network();
836 if (ethernet_network)
837 AddNetworkToList(list, &added, ethernet_network);
838 }
839
840 // Cellular.
841 if (crosnet->cellular_available() && crosnet->cellular_enabled()) {
842 const CellularNetworkVector& cell = crosnet->cellular_networks();
843 for (size_t i = 0; i < cell.size(); ++i)
844 AddNetworkToList(list, &added, cell[i]);
845 }
846
847 // Wimax.
848 if (crosnet->wimax_available() && crosnet->wimax_enabled()) {
849 const WimaxNetworkVector& wimax = crosnet->wimax_networks();
850 for (size_t i = 0; i < wimax.size(); ++i)
851 AddNetworkToList(list, &added, wimax[i]);
852 }
853
854 // Wifi.
855 if (crosnet->wifi_available() && crosnet->wifi_enabled()) {
856 const WifiNetworkVector& wifi = crosnet->wifi_networks();
857 for (size_t i = 0; i < wifi.size(); ++i)
858 AddNetworkToList(list, &added, wifi[i]);
859 }
860 }
861
862 virtual void GetVirtualNetworks(
863 std::vector<ash::NetworkIconInfo>* list) OVERRIDE {
864 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
865 std::set<const Network*> added;
866
867 // Add connected/connecting vpn first.
868 if (crosnet->virtual_network()
869 && crosnet->virtual_network()->connecting_or_connected()) {
870 AddNetworkToList(list, &added, crosnet->virtual_network());
871 }
872
873 // VPN (only if logged in).
874 if (GetUserLoginStatus() != ash::user::LOGGED_IN_NONE &&
875 (crosnet->connected_network() ||
876 crosnet->virtual_network_connected())) {
877 const VirtualNetworkVector& vpns = crosnet->virtual_networks();
878 for (size_t i = 0; i < vpns.size(); ++i)
879 AddNetworkToList(list, &added, vpns[i]);
880 }
881 }
882
883 virtual void GetNetworkAddresses(std::string* ip_address,
884 std::string* ethernet_mac_address,
885 std::string* wifi_mac_address) OVERRIDE {
886 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
887 if (crosnet->Connected())
888 *ip_address = crosnet->IPAddress();
889 else
890 *ip_address = std::string();
891
892 *ethernet_mac_address = std::string();
893 const NetworkDevice* ether = crosnet->FindEthernetDevice();
894 if (ether)
895 crosnet->GetIPConfigsAndBlock(ether->device_path(), ethernet_mac_address,
896 NetworkLibrary::FORMAT_COLON_SEPARATED_HEX);
897
898 *wifi_mac_address = std::string();
899 const NetworkDevice* wifi = crosnet->wifi_enabled() ?
900 crosnet->FindWifiDevice() : NULL;
901 if (wifi)
902 crosnet->GetIPConfigsAndBlock(wifi->device_path(), wifi_mac_address,
903 NetworkLibrary::FORMAT_COLON_SEPARATED_HEX);
904 }
905
906 virtual void ConfigureNetwork(const std::string& network_id) OVERRIDE { 763 virtual void ConfigureNetwork(const std::string& network_id) OVERRIDE {
907 const chromeos::NetworkState* network = network_id.empty() ? NULL : 764 const chromeos::NetworkState* network = network_id.empty() ? NULL :
908 chromeos::NetworkStateHandler::Get()->GetNetworkState(network_id); 765 chromeos::NetworkStateHandler::Get()->GetNetworkState(network_id);
909 if (!network) { 766 if (!network) {
910 LOG(ERROR) << "ConfigureNetwork: Network not found: " << network_id; 767 LOG(ERROR) << "ConfigureNetwork: Network not found: " << network_id;
911 return; 768 return;
912 } 769 }
913 if (network->type() == flimflam::kTypeWifi || 770 if (network->type() == flimflam::kTypeWifi ||
914 network->type() == flimflam::kTypeWimax || 771 network->type() == flimflam::kTypeWimax ||
915 network->type() == flimflam::kTypeVPN) { 772 network->type() == flimflam::kTypeVPN) {
(...skipping 17 matching lines...) Expand all
933 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch( 790 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(
934 chromeos::switches::kUseNewNetworkConfigurationHandlers)); 791 chromeos::switches::kUseNewNetworkConfigurationHandlers));
935 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 792 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
936 Network* network = crosnet->FindNetworkByPath(network_id); 793 Network* network = crosnet->FindNetworkByPath(network_id);
937 if (network) 794 if (network)
938 network_menu_->ConnectToNetwork(network); // Shows settings if connected 795 network_menu_->ConnectToNetwork(network); // Shows settings if connected
939 else 796 else
940 ShowNetworkSettings(""); 797 ShowNetworkSettings("");
941 } 798 }
942 799
943 virtual void RequestNetworkScan() OVERRIDE {
944 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
945 crosnet->RequestNetworkScan();
946 }
947
948 virtual void AddBluetoothDevice() OVERRIDE { 800 virtual void AddBluetoothDevice() OVERRIDE {
949 // Open the Bluetooth device dialog, which automatically starts the 801 // Open the Bluetooth device dialog, which automatically starts the
950 // discovery process. 802 // discovery process.
951 content::RecordAction( 803 content::RecordAction(
952 content::UserMetricsAction("OpenAddBluetoothDeviceDialog")); 804 content::UserMetricsAction("OpenAddBluetoothDeviceDialog"));
953 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), 805 chrome::ShowSettingsSubPage(GetAppropriateBrowser(),
954 chrome::kBluetoothAddDeviceSubPage); 806 chrome::kBluetoothAddDeviceSubPage);
955 } 807 }
956 808
957 virtual void ToggleAirplaneMode() OVERRIDE {
958 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
959 crosnet->EnableOfflineMode(!crosnet->offline_mode());
960 }
961
962 virtual void ToggleWifi() OVERRIDE {
963 GetSystemTrayNotifier()->NotifyWillToggleWifi();
964 network_menu_->ToggleWifi();
965 }
966
967 virtual void ToggleMobile() OVERRIDE {
968 network_menu_->ToggleMobile();
969 }
970
971 virtual void ToggleBluetooth() OVERRIDE { 809 virtual void ToggleBluetooth() OVERRIDE {
972 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(), 810 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(),
973 base::Bind(&base::DoNothing), 811 base::Bind(&base::DoNothing),
974 base::Bind(&BluetoothPowerFailure)); 812 base::Bind(&BluetoothPowerFailure));
975 } 813 }
976 814
977 virtual void ShowMobileSimDialog() OVERRIDE { 815 virtual void ShowMobileSimDialog() OVERRIDE {
978 SimDialogDelegate::ShowDialog(GetNativeWindow(), 816 SimDialogDelegate::ShowDialog(GetNativeWindow(),
979 SimDialogDelegate::SIM_DIALOG_UNLOCK); 817 SimDialogDelegate::SIM_DIALOG_UNLOCK);
980 } 818 }
981 819
982 virtual void ShowOtherWifi() OVERRIDE { 820 virtual void ShowOtherWifi() OVERRIDE {
983 network_menu_->ShowOtherWifi(); 821 NetworkConfigView::ShowForType(chromeos::TYPE_WIFI, GetNativeWindow());
984 } 822 }
985 823
986 virtual void ShowOtherVPN() OVERRIDE { 824 virtual void ShowOtherVPN() OVERRIDE {
987 network_menu_->ShowOtherVPN(); 825 NetworkConfigView::ShowForType(chromeos::TYPE_VPN, GetNativeWindow());
988 } 826 }
989 827
990 virtual void ShowOtherCellular() OVERRIDE { 828 virtual void ShowOtherCellular() OVERRIDE {
991 network_menu_->ShowOtherCellular(); 829 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
992 }
993
994 virtual bool IsNetworkConnected() OVERRIDE {
995 return CrosLibrary::Get()->GetNetworkLibrary()->Connected();
996 }
997
998 virtual bool GetWifiAvailable() OVERRIDE {
999 return CrosLibrary::Get()->GetNetworkLibrary()->wifi_available();
1000 }
1001
1002 virtual bool GetMobileAvailable() OVERRIDE {
1003 return CrosLibrary::Get()->GetNetworkLibrary()->mobile_available();
1004 } 830 }
1005 831
1006 virtual bool GetBluetoothAvailable() OVERRIDE { 832 virtual bool GetBluetoothAvailable() OVERRIDE {
1007 return bluetooth_adapter_->IsPresent(); 833 return bluetooth_adapter_->IsPresent();
1008 } 834 }
1009 835
1010 virtual bool GetWifiEnabled() OVERRIDE {
1011 return CrosLibrary::Get()->GetNetworkLibrary()->wifi_enabled();
1012 }
1013
1014 virtual bool GetMobileEnabled() OVERRIDE {
1015 return CrosLibrary::Get()->GetNetworkLibrary()->mobile_enabled();
1016 }
1017
1018 virtual bool GetBluetoothEnabled() OVERRIDE { 836 virtual bool GetBluetoothEnabled() OVERRIDE {
1019 return bluetooth_adapter_->IsPowered(); 837 return bluetooth_adapter_->IsPowered();
1020 } 838 }
1021 839
1022 virtual bool GetMobileScanSupported() OVERRIDE {
1023 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
1024 const NetworkDevice* mobile = crosnet->FindMobileDevice();
1025 return mobile ? mobile->support_network_scan() : false;
1026 }
1027
1028 virtual bool GetCellularCarrierInfo(std::string* carrier_id, 840 virtual bool GetCellularCarrierInfo(std::string* carrier_id,
1029 std::string* topup_url, 841 std::string* topup_url,
1030 std::string* setup_url) OVERRIDE { 842 std::string* setup_url) OVERRIDE {
1031 bool result = false; 843 bool result = false;
1032 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 844 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
1033 const NetworkDevice* cellular = crosnet->FindCellularDevice(); 845 const NetworkDevice* cellular = crosnet->FindCellularDevice();
1034 if (!cellular) 846 if (!cellular)
1035 return false; 847 return false;
1036 848
1037 MobileConfig* config = MobileConfig::GetInstance(); 849 MobileConfig* config = MobileConfig::GetInstance();
(...skipping 10 matching lines...) Expand all
1048 // Only link to setup URL if SIM card is not inserted. 860 // Only link to setup URL if SIM card is not inserted.
1049 if (cellular->is_sim_absent()) { 861 if (cellular->is_sim_absent()) {
1050 *setup_url = locale_config->setup_url(); 862 *setup_url = locale_config->setup_url();
1051 result = true; 863 result = true;
1052 } 864 }
1053 } 865 }
1054 } 866 }
1055 return result; 867 return result;
1056 } 868 }
1057 869
1058 virtual bool GetWifiScanning() OVERRIDE {
1059 return CrosLibrary::Get()->GetNetworkLibrary()->wifi_scanning();
1060 }
1061
1062 virtual bool GetCellularInitializing() OVERRIDE {
1063 return CrosLibrary::Get()->GetNetworkLibrary()->cellular_initializing();
1064 }
1065
1066 virtual void ShowCellularURL(const std::string& url) OVERRIDE { 870 virtual void ShowCellularURL(const std::string& url) OVERRIDE {
1067 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(url)); 871 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(url));
1068 } 872 }
1069 873
1070 virtual void ChangeProxySettings() OVERRIDE { 874 virtual void ChangeProxySettings() OVERRIDE {
1071 CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE); 875 CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE);
1072 LoginDisplayHostImpl::default_host()->OpenProxySettings(); 876 LoginDisplayHostImpl::default_host()->OpenProxySettings();
1073 } 877 }
1074 878
1075 virtual ash::VolumeControlDelegate* 879 virtual ash::VolumeControlDelegate*
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 std::min(std::max(local_state->GetInteger(prefs::kSessionLengthLimit), 997 std::min(std::max(local_state->GetInteger(prefs::kSessionLengthLimit),
1194 kSessionLengthLimitMinMs), 998 kSessionLengthLimitMinMs),
1195 kSessionLengthLimitMaxMs)); 999 kSessionLengthLimitMaxMs));
1196 } else { 1000 } else {
1197 have_session_length_limit_ = false; 1001 have_session_length_limit_ = false;
1198 session_length_limit_ = base::TimeDelta(); 1002 session_length_limit_ = base::TimeDelta();
1199 } 1003 }
1200 GetSystemTrayNotifier()->NotifySessionLengthLimitChanged(); 1004 GetSystemTrayNotifier()->NotifySessionLengthLimitChanged();
1201 } 1005 }
1202 1006
1203 void NotifyRefreshNetwork() {
1204 chromeos::NetworkLibrary* crosnet =
1205 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
1206 const Network* network = crosnet->connected_network();
1207 ash::NetworkIconInfo info;
1208 if (network)
1209 info = CreateNetworkIconInfo(network);
1210 info.image = network_icon_->GetIconAndText(&info.description);
1211 info.tray_icon_visible = network_icon_->ShouldShowIconInTray();
1212 GetSystemTrayNotifier()->NotifyRefreshNetwork(info);
1213 GetSystemTrayNotifier()->NotifyVpnRefreshNetwork(info);
1214 }
1215
1216 void RefreshNetworkObserver(NetworkLibrary* crosnet) {
1217 const Network* network = crosnet->active_nonvirtual_network();
1218 std::string new_path = network ? network->service_path() : std::string();
1219 if (active_network_path_ != new_path) {
1220 if (!active_network_path_.empty())
1221 crosnet->RemoveNetworkObserver(active_network_path_, this);
1222 if (!new_path.empty())
1223 crosnet->AddNetworkObserver(new_path, this);
1224 active_network_path_ = new_path;
1225 }
1226 }
1227
1228 void AddNetworkToList(std::vector<ash::NetworkIconInfo>* list,
1229 std::set<const Network*>* added,
1230 const Network* network) {
1231 // Only add networks to the list once.
1232 if (added->find(network) != added->end())
1233 return;
1234
1235 ash::NetworkIconInfo info = CreateNetworkIconInfo(network);
1236 switch (network->type()) {
1237 case TYPE_ETHERNET:
1238 if (info.name.empty()) {
1239 info.name =
1240 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
1241 }
1242 break;
1243 case TYPE_CELLULAR: {
1244 const CellularNetwork* cellular =
1245 static_cast<const CellularNetwork*>(network);
1246 ActivationState state = cellular->activation_state();
1247 if (state == ACTIVATION_STATE_NOT_ACTIVATED ||
1248 state == ACTIVATION_STATE_PARTIALLY_ACTIVATED) {
1249 // If a cellular network needs to be activated,
1250 // then do not show it in the lock screen.
1251 if (GetUserLoginStatus() == ash::user::LOGGED_IN_LOCKED)
1252 return;
1253
1254 info.description = l10n_util::GetStringFUTF16(
1255 IDS_ASH_STATUS_TRAY_NETWORK_LIST_ACTIVATE, info.name);
1256 } else if (state == ACTIVATION_STATE_ACTIVATING) {
1257 info.description = l10n_util::GetStringFUTF16(
1258 IDS_ASH_STATUS_TRAY_NETWORK_LIST_ACTIVATING, info.name);
1259 } else if (network->connecting()) {
1260 info.description = l10n_util::GetStringFUTF16(
1261 IDS_STATUSBAR_NETWORK_DEVICE_STATUS,
1262 info.name, l10n_util::GetStringUTF16(
1263 IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING));
1264 }
1265 break;
1266 }
1267 case TYPE_VPN:
1268 case TYPE_WIFI:
1269 case TYPE_WIMAX:
1270 case TYPE_BLUETOOTH:
1271 case TYPE_UNKNOWN:
1272 break;
1273 }
1274 if (network->connecting()) {
1275 info.description = l10n_util::GetStringFUTF16(
1276 IDS_STATUSBAR_NETWORK_DEVICE_STATUS,
1277 info.name,
1278 l10n_util::GetStringUTF16(
1279 IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING));
1280 }
1281 added->insert(network);
1282 list->push_back(info);
1283 }
1284
1285 // Overridden from AudioHandler::VolumeObserver. 1007 // Overridden from AudioHandler::VolumeObserver.
1286 virtual void OnVolumeChanged() OVERRIDE { 1008 virtual void OnVolumeChanged() OVERRIDE {
1287 float level = AudioHandler::GetInstance()->GetVolumePercent() / 100.f; 1009 float level = AudioHandler::GetInstance()->GetVolumePercent() / 100.f;
1288 GetSystemTrayNotifier()->NotifyVolumeChanged(level); 1010 GetSystemTrayNotifier()->NotifyVolumeChanged(level);
1289 } 1011 }
1290 1012
1291 // Overridden from AudioHandler::VolumeObserver. 1013 // Overridden from AudioHandler::VolumeObserver.
1292 virtual void OnMuteToggled() OVERRIDE { 1014 virtual void OnMuteToggled() OVERRIDE {
1293 GetSystemTrayNotifier()->NotifyMuteToggled(); 1015 GetSystemTrayNotifier()->NotifyMuteToggled();
1294 } 1016 }
(...skipping 17 matching lines...) Expand all
1312 } 1034 }
1313 1035
1314 virtual void UnlockScreen() OVERRIDE { 1036 virtual void UnlockScreen() OVERRIDE {
1315 screen_locked_ = false; 1037 screen_locked_ = false;
1316 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( 1038 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(
1317 GetUserLoginStatus()); 1039 GetUserLoginStatus());
1318 } 1040 }
1319 1041
1320 // TODO(sad): Override more from PowerManagerClient::Observer here. 1042 // TODO(sad): Override more from PowerManagerClient::Observer here.
1321 1043
1322 // Overridden from NetworkMenuIcon::Delegate.
1323 virtual void NetworkMenuIconChanged() OVERRIDE {
1324 NotifyRefreshNetwork();
1325 }
1326
1327 // Overridden from NetworkMenu::Delegate. 1044 // Overridden from NetworkMenu::Delegate.
1328 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE { 1045 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE {
1329 return GetNativeWindowByStatus(GetUserLoginStatus()); 1046 return GetNativeWindowByStatus(GetUserLoginStatus());
1330 } 1047 }
1331 1048
1332 virtual void OpenButtonOptions() OVERRIDE { 1049 virtual void OpenButtonOptions() OVERRIDE {
1333 } 1050 }
1334 1051
1335 virtual bool ShouldOpenButtonOptions() const OVERRIDE { 1052 virtual bool ShouldOpenButtonOptions() const OVERRIDE {
1336 return false; 1053 return false;
1337 } 1054 }
1338 1055
1339 // Overridden from NetworkLibrary::NetworkManagerObserver. 1056 // Overridden from NetworkLibrary::NetworkManagerObserver.
1340 virtual void OnNetworkManagerChanged(NetworkLibrary* crosnet) OVERRIDE { 1057 virtual void OnNetworkManagerChanged(NetworkLibrary* crosnet) OVERRIDE {
1341 RefreshNetworkObserver(crosnet); 1058 // TODO(stevenjb): Migrate to NetworkStateHandler.
1342 data_promo_notification_->ShowOptionalMobileDataPromoNotification( 1059 data_promo_notification_->ShowOptionalMobileDataPromoNotification(
1343 crosnet, GetPrimarySystemTray(), this); 1060 crosnet, GetPrimarySystemTray(), this);
1344 UpdateCellular(); 1061 UpdateCellular();
1345
1346 NotifyRefreshNetwork();
1347 }
1348
1349 // Overridden from NetworkLibrary::NetworkObserver.
1350 virtual void OnNetworkChanged(NetworkLibrary* crosnet,
1351 const Network* network) OVERRIDE {
1352 NotifyRefreshNetwork();
1353 } 1062 }
1354 1063
1355 // content::NotificationObserver implementation. 1064 // content::NotificationObserver implementation.
1356 virtual void Observe(int type, 1065 virtual void Observe(int type,
1357 const content::NotificationSource& source, 1066 const content::NotificationSource& source,
1358 const content::NotificationDetails& details) OVERRIDE { 1067 const content::NotificationDetails& details) OVERRIDE {
1359 switch (type) { 1068 switch (type) {
1360 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { 1069 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
1361 UpgradeDetector* detector = 1070 UpgradeDetector* detector =
1362 content::Source<UpgradeDetector>(source).ptr(); 1071 content::Source<UpgradeDetector>(source).ptr();
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 if (cellular->activation_state() == ACTIVATION_STATE_ACTIVATING) { 1303 if (cellular->activation_state() == ACTIVATION_STATE_ACTIVATING) {
1595 cellular_activating_ = true; 1304 cellular_activating_ = true;
1596 } else if (cellular->activated() && cellular_activating_) { 1305 } else if (cellular->activated() && cellular_activating_) {
1597 cellular_activating_ = false; 1306 cellular_activating_ = false;
1598 ash::NetworkObserver::NetworkType type = NetworkTypeForCellular(cellular); 1307 ash::NetworkObserver::NetworkType type = NetworkTypeForCellular(cellular);
1599 ash::Shell::GetInstance()->system_tray_notifier()-> 1308 ash::Shell::GetInstance()->system_tray_notifier()->
1600 NotifySetNetworkMessage( 1309 NotifySetNetworkMessage(
1601 NULL, 1310 NULL,
1602 ash::NetworkObserver::MESSAGE_DATA_PROMO, 1311 ash::NetworkObserver::MESSAGE_DATA_PROMO,
1603 type, 1312 type,
1604 l10n_util::GetStringUTF16( 1313 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE),
1605 IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), 1314 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED,
1606 l10n_util::GetStringFUTF16( 1315 UTF8ToUTF16((cellular->name()))),
1607 IDS_NETWORK_CELLULAR_ACTIVATED, 1316 std::vector<string16>());
1608 UTF8ToUTF16((cellular->name()))),
1609 std::vector<string16>());
1610 }
1611 if (!CommandLine::ForCurrentProcess()->HasSwitch(
1612 ash::switches::kAshDisableNewNetworkStatusArea)) {
1613 return;
1614 }
1615 // Trigger "Out of credits" notification (for NetworkLibrary impl)
1616 if (cellular->out_of_credits() && !cellular_out_of_credits_) {
1617 cellular_out_of_credits_ = true;
1618 ash::NetworkObserver::NetworkType type = NetworkTypeForCellular(cellular);
1619 std::vector<string16> links;
1620 links.push_back(
1621 l10n_util::GetStringFUTF16(IDS_NETWORK_OUT_OF_CREDITS_LINK,
1622 UTF8ToUTF16(cellular->name())));
1623 ash::Shell::GetInstance()->system_tray_notifier()->
1624 NotifySetNetworkMessage(
1625 this, ash::NetworkObserver::ERROR_OUT_OF_CREDITS, type,
1626 l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_TITLE),
1627 l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_BODY),
1628 links);
1629 } else if (!cellular->out_of_credits() && cellular_out_of_credits_) {
1630 cellular_out_of_credits_ = false;
1631 } 1317 }
1632 } 1318 }
1633 1319
1634 scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_; 1320 scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_;
1635 scoped_ptr<NetworkMenuIcon> network_icon_;
1636 scoped_ptr<NetworkMenuIcon> network_icon_dark_;
1637 scoped_ptr<NetworkMenuIcon> network_icon_vpn_;
1638 scoped_ptr<NetworkMenu> network_menu_; 1321 scoped_ptr<NetworkMenu> network_menu_;
1639 content::NotificationRegistrar registrar_; 1322 content::NotificationRegistrar registrar_;
1640 PrefChangeRegistrar local_state_registrar_; 1323 PrefChangeRegistrar local_state_registrar_;
1641 scoped_ptr<PrefChangeRegistrar> user_pref_registrar_; 1324 scoped_ptr<PrefChangeRegistrar> user_pref_registrar_;
1642 std::string active_network_path_; 1325 std::string active_network_path_;
1643 base::HourClockType clock_type_; 1326 base::HourClockType clock_type_;
1644 int search_key_mapped_to_; 1327 int search_key_mapped_to_;
1645 bool screen_locked_; 1328 bool screen_locked_;
1646 bool have_session_start_time_; 1329 bool have_session_start_time_;
1647 base::TimeTicks session_start_time_; 1330 base::TimeTicks session_start_time_;
(...skipping 12 matching lines...) Expand all
1660 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1343 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1661 }; 1344 };
1662 1345
1663 } // namespace 1346 } // namespace
1664 1347
1665 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1348 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1666 return new chromeos::SystemTrayDelegate(); 1349 return new chromeos::SystemTrayDelegate();
1667 } 1350 }
1668 1351
1669 } // namespace chromeos 1352 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698