| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/chromeos/network/network_list.h" | 5 #include "ash/common/system/chromeos/network/network_list.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/common/system/chromeos/network/network_icon.h" |
| 10 #include "ash/common/system/chromeos/network/network_icon_animation.h" |
| 11 #include "ash/common/system/chromeos/network/network_info.h" |
| 12 #include "ash/common/system/chromeos/network/network_list_delegate.h" |
| 9 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 10 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
| 11 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | 15 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
| 12 #include "chromeos/dbus/power_manager_client.h" | 16 #include "chromeos/dbus/power_manager_client.h" |
| 13 #include "chromeos/login/login_state.h" | 17 #include "chromeos/login/login_state.h" |
| 14 #include "chromeos/network/managed_network_configuration_handler.h" | 18 #include "chromeos/network/managed_network_configuration_handler.h" |
| 15 #include "chromeos/network/network_state.h" | 19 #include "chromeos/network/network_state.h" |
| 16 #include "chromeos/network/network_state_handler.h" | 20 #include "chromeos/network/network_state_handler.h" |
| 17 #include "chromeos/network/network_state_handler_observer.h" | 21 #include "chromeos/network/network_state_handler_observer.h" |
| 18 #include "components/device_event_log/device_event_log.h" | 22 #include "components/device_event_log/device_event_log.h" |
| 19 #include "grit/ui_chromeos_strings.h" | 23 #include "grit/ash_strings.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/chromeos/network/network_icon.h" | |
| 23 #include "ui/chromeos/network/network_icon_animation.h" | |
| 24 #include "ui/chromeos/network/network_info.h" | |
| 25 #include "ui/chromeos/network/network_list_delegate.h" | |
| 26 #include "ui/gfx/font.h" | 26 #include "ui/gfx/font.h" |
| 27 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
| 28 #include "ui/views/view.h" | 28 #include "ui/views/view.h" |
| 29 | 29 |
| 30 using chromeos::LoginState; | 30 using chromeos::LoginState; |
| 31 using chromeos::NetworkHandler; | 31 using chromeos::NetworkHandler; |
| 32 using chromeos::NetworkStateHandler; | 32 using chromeos::NetworkStateHandler; |
| 33 using chromeos::ManagedNetworkConfigurationHandler; | 33 using chromeos::ManagedNetworkConfigurationHandler; |
| 34 using chromeos::NetworkTypePattern; | 34 using chromeos::NetworkTypePattern; |
| 35 | 35 |
| 36 namespace ui { | 36 namespace ash { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 bool IsProhibitedByPolicy(const chromeos::NetworkState* network) { | 40 bool IsProhibitedByPolicy(const chromeos::NetworkState* network) { |
| 41 if (!NetworkTypePattern::WiFi().MatchesType(network->type())) | 41 if (!NetworkTypePattern::WiFi().MatchesType(network->type())) |
| 42 return false; | 42 return false; |
| 43 if (!LoginState::IsInitialized() || !LoginState::Get()->IsUserLoggedIn()) | 43 if (!LoginState::IsInitialized() || !LoginState::Get()->IsUserLoggedIn()) |
| 44 return false; | 44 return false; |
| 45 ManagedNetworkConfigurationHandler* managed_configuration_handler = | 45 ManagedNetworkConfigurationHandler* managed_configuration_handler = |
| 46 NetworkHandler::Get()->managed_network_configuration_handler(); | 46 NetworkHandler::Get()->managed_network_configuration_handler(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void NetworkListView::UpdateNetworks( | 97 void NetworkListView::UpdateNetworks( |
| 98 const NetworkStateHandler::NetworkStateList& networks) { | 98 const NetworkStateHandler::NetworkStateList& networks) { |
| 99 SCOPED_NET_LOG_IF_SLOW(); | 99 SCOPED_NET_LOG_IF_SLOW(); |
| 100 network_list_.clear(); | 100 network_list_.clear(); |
| 101 const NetworkTypePattern pattern = delegate_->GetNetworkTypePattern(); | 101 const NetworkTypePattern pattern = delegate_->GetNetworkTypePattern(); |
| 102 for (NetworkStateHandler::NetworkStateList::const_iterator iter = | 102 for (NetworkStateHandler::NetworkStateList::const_iterator iter = |
| 103 networks.begin(); | 103 networks.begin(); |
| 104 iter != networks.end(); | 104 iter != networks.end(); ++iter) { |
| 105 ++iter) { | |
| 106 const chromeos::NetworkState* network = *iter; | 105 const chromeos::NetworkState* network = *iter; |
| 107 if (!pattern.MatchesType(network->type())) | 106 if (!pattern.MatchesType(network->type())) |
| 108 continue; | 107 continue; |
| 109 network_list_.push_back(base::MakeUnique<NetworkInfo>(network->path())); | 108 network_list_.push_back(base::MakeUnique<NetworkInfo>(network->path())); |
| 110 } | 109 } |
| 111 } | 110 } |
| 112 | 111 |
| 113 void NetworkListView::UpdateNetworkIcons() { | 112 void NetworkListView::UpdateNetworkIcons() { |
| 114 SCOPED_NET_LOG_IF_SLOW(); | 113 SCOPED_NET_LOG_IF_SLOW(); |
| 115 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 114 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 void NetworkListView::UpdateNetworkListInternal() { | 148 void NetworkListView::UpdateNetworkListInternal() { |
| 150 SCOPED_NET_LOG_IF_SLOW(); | 149 SCOPED_NET_LOG_IF_SLOW(); |
| 151 // Get the updated list entries | 150 // Get the updated list entries |
| 152 network_map_.clear(); | 151 network_map_.clear(); |
| 153 std::set<std::string> new_service_paths; | 152 std::set<std::string> new_service_paths; |
| 154 bool needs_relayout = UpdateNetworkListEntries(&new_service_paths); | 153 bool needs_relayout = UpdateNetworkListEntries(&new_service_paths); |
| 155 | 154 |
| 156 // Remove old children | 155 // Remove old children |
| 157 std::set<std::string> remove_service_paths; | 156 std::set<std::string> remove_service_paths; |
| 158 for (ServicePathMap::const_iterator it = service_path_map_.begin(); | 157 for (ServicePathMap::const_iterator it = service_path_map_.begin(); |
| 159 it != service_path_map_.end(); | 158 it != service_path_map_.end(); ++it) { |
| 160 ++it) { | |
| 161 if (new_service_paths.find(it->first) == new_service_paths.end()) { | 159 if (new_service_paths.find(it->first) == new_service_paths.end()) { |
| 162 remove_service_paths.insert(it->first); | 160 remove_service_paths.insert(it->first); |
| 163 network_map_.erase(it->second); | 161 network_map_.erase(it->second); |
| 164 delete it->second; | 162 delete it->second; |
| 165 needs_relayout = true; | 163 needs_relayout = true; |
| 166 } | 164 } |
| 167 } | 165 } |
| 168 | 166 |
| 169 for (std::set<std::string>::const_iterator remove_it = | 167 for (std::set<std::string>::const_iterator remove_it = |
| 170 remove_service_paths.begin(); | 168 remove_service_paths.begin(); |
| 171 remove_it != remove_service_paths.end(); | 169 remove_it != remove_service_paths.end(); ++remove_it) { |
| 172 ++remove_it) { | |
| 173 service_path_map_.erase(*remove_it); | 170 service_path_map_.erase(*remove_it); |
| 174 } | 171 } |
| 175 | 172 |
| 176 if (needs_relayout) | 173 if (needs_relayout) |
| 177 HandleRelayout(); | 174 HandleRelayout(); |
| 178 } | 175 } |
| 179 | 176 |
| 180 void NetworkListView::HandleRelayout() { | 177 void NetworkListView::HandleRelayout() { |
| 181 views::View* selected_view = nullptr; | 178 views::View* selected_view = nullptr; |
| 182 for (auto& iter : service_path_map_) { | 179 for (auto& iter : service_path_map_) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 *label = nullptr; | 312 *label = nullptr; |
| 316 needs_relayout = true; | 313 needs_relayout = true; |
| 317 } | 314 } |
| 318 return needs_relayout; | 315 return needs_relayout; |
| 319 } | 316 } |
| 320 | 317 |
| 321 void NetworkListView::NetworkIconChanged() { | 318 void NetworkListView::NetworkIconChanged() { |
| 322 Update(); | 319 Update(); |
| 323 } | 320 } |
| 324 | 321 |
| 325 } // namespace ui | 322 } // namespace ash |
| OLD | NEW |