| 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/ui/webui/options/chromeos/internet_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/chromeos/options/network_property_ui_data.h" | 29 #include "chrome/browser/chromeos/options/network_property_ui_data.h" |
| 30 #include "chrome/browser/chromeos/settings/cros_settings.h" | 30 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 31 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 31 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 32 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 32 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 33 #include "chrome/browser/chromeos/ui/mobile_config_ui.h" | 33 #include "chrome/browser/chromeos/ui/mobile_config_ui.h" |
| 34 #include "chrome/browser/chromeos/ui_proxy_config_service.h" | 34 #include "chrome/browser/chromeos/ui_proxy_config_service.h" |
| 35 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler
.h" | 35 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler
.h" |
| 36 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri
ngs.h" | 36 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri
ngs.h" |
| 37 #include "chromeos/chromeos_switches.h" | 37 #include "chromeos/chromeos_switches.h" |
| 38 #include "chromeos/network/device_state.h" | 38 #include "chromeos/network/device_state.h" |
| 39 #include "chromeos/network/favorite_state.h" | |
| 40 #include "chromeos/network/managed_network_configuration_handler.h" | 39 #include "chromeos/network/managed_network_configuration_handler.h" |
| 41 #include "chromeos/network/network_configuration_handler.h" | 40 #include "chromeos/network/network_configuration_handler.h" |
| 42 #include "chromeos/network/network_connection_handler.h" | 41 #include "chromeos/network/network_connection_handler.h" |
| 43 #include "chromeos/network/network_device_handler.h" | 42 #include "chromeos/network/network_device_handler.h" |
| 44 #include "chromeos/network/network_event_log.h" | 43 #include "chromeos/network/network_event_log.h" |
| 45 #include "chromeos/network/network_ip_config.h" | 44 #include "chromeos/network/network_ip_config.h" |
| 46 #include "chromeos/network/network_profile.h" | 45 #include "chromeos/network/network_profile.h" |
| 47 #include "chromeos/network/network_profile_handler.h" | 46 #include "chromeos/network/network_profile_handler.h" |
| 48 #include "chromeos/network/network_state.h" | 47 #include "chromeos/network/network_state.h" |
| 49 #include "chromeos/network/network_state_handler.h" | 48 #include "chromeos/network/network_state_handler.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 return kTagLoggedInUserPublicAccount; | 285 return kTagLoggedInUserPublicAccount; |
| 287 case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED: | 286 case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED: |
| 288 return kTagLoggedInUserLocallyManaged; | 287 return kTagLoggedInUserLocallyManaged; |
| 289 case LoginState::LOGGED_IN_USER_KIOSK_APP: | 288 case LoginState::LOGGED_IN_USER_KIOSK_APP: |
| 290 return kTagLoggedInUserKioskApp; | 289 return kTagLoggedInUserKioskApp; |
| 291 } | 290 } |
| 292 NOTREACHED(); | 291 NOTREACHED(); |
| 293 return std::string(); | 292 return std::string(); |
| 294 } | 293 } |
| 295 | 294 |
| 296 bool HasPolicyForFavorite(const FavoriteState* favorite, | 295 void SetCommonNetworkInfo(const NetworkState* state, |
| 297 const PrefService* profile_prefs) { | |
| 298 return onc::HasPolicyForFavoriteNetwork( | |
| 299 profile_prefs, g_browser_process->local_state(), *favorite); | |
| 300 } | |
| 301 | |
| 302 bool HasPolicyForNetwork(const NetworkState* network, | |
| 303 const PrefService* profile_prefs) { | |
| 304 const FavoriteState* favorite = | |
| 305 NetworkHandler::Get() | |
| 306 ->network_state_handler() | |
| 307 ->GetFavoriteStateFromServicePath(network->path(), | |
| 308 true /* configured_only */); | |
| 309 if (!favorite) | |
| 310 return false; | |
| 311 return HasPolicyForFavorite(favorite, profile_prefs); | |
| 312 } | |
| 313 | |
| 314 void SetCommonNetworkInfo(const ManagedState* state, | |
| 315 const gfx::ImageSkia& icon, | 296 const gfx::ImageSkia& icon, |
| 316 float icon_scale_factor, | 297 float icon_scale_factor, |
| 317 base::DictionaryValue* network_info) { | 298 base::DictionaryValue* network_info) { |
| 318 gfx::ImageSkiaRep image_rep = | 299 gfx::ImageSkiaRep image_rep = |
| 319 icon.GetRepresentation(icon_scale_factor); | 300 icon.GetRepresentation(icon_scale_factor); |
| 320 std::string icon_url = | 301 std::string icon_url = |
| 321 icon.isNull() ? "" : webui::GetBitmapDataUrl(image_rep.sk_bitmap()); | 302 icon.isNull() ? "" : webui::GetBitmapDataUrl(image_rep.sk_bitmap()); |
| 322 network_info->SetString(kNetworkInfoKeyIconURL, icon_url); | 303 network_info->SetString(kNetworkInfoKeyIconURL, icon_url); |
| 323 | 304 |
| 324 std::string name = state->name(); | 305 std::string name = state->name(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 337 base::DictionaryValue* BuildNetworkDictionary( | 318 base::DictionaryValue* BuildNetworkDictionary( |
| 338 const NetworkState* network, | 319 const NetworkState* network, |
| 339 float icon_scale_factor, | 320 float icon_scale_factor, |
| 340 const PrefService* profile_prefs) { | 321 const PrefService* profile_prefs) { |
| 341 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); | 322 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); |
| 342 network_info->SetBoolean(kNetworkInfoKeyConnectable, network->connectable()); | 323 network_info->SetBoolean(kNetworkInfoKeyConnectable, network->connectable()); |
| 343 network_info->SetBoolean(kNetworkInfoKeyConnected, | 324 network_info->SetBoolean(kNetworkInfoKeyConnected, |
| 344 network->IsConnectedState()); | 325 network->IsConnectedState()); |
| 345 network_info->SetBoolean(kNetworkInfoKeyConnecting, | 326 network_info->SetBoolean(kNetworkInfoKeyConnecting, |
| 346 network->IsConnectingState()); | 327 network->IsConnectingState()); |
| 347 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, | 328 bool has_policy = onc::HasPolicyForNetwork( |
| 348 HasPolicyForNetwork(network, profile_prefs)); | 329 profile_prefs, g_browser_process->local_state(), *network); |
| 330 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, has_policy); |
| 349 | 331 |
| 350 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork( | 332 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork( |
| 351 network, ash::network_icon::ICON_TYPE_LIST); | 333 network, ash::network_icon::ICON_TYPE_LIST); |
| 352 SetCommonNetworkInfo(network, icon, icon_scale_factor, network_info.get()); | 334 SetCommonNetworkInfo(network, icon, icon_scale_factor, network_info.get()); |
| 353 return network_info.release(); | 335 return network_info.release(); |
| 354 } | 336 } |
| 355 | 337 |
| 356 base::DictionaryValue* BuildFavoriteDictionary( | |
| 357 const FavoriteState* favorite, | |
| 358 float icon_scale_factor, | |
| 359 const PrefService* profile_prefs) { | |
| 360 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); | |
| 361 network_info->SetBoolean(kNetworkInfoKeyConnectable, false); | |
| 362 network_info->SetBoolean(kNetworkInfoKeyConnected, false); | |
| 363 network_info->SetBoolean(kNetworkInfoKeyConnecting, false); | |
| 364 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, | |
| 365 HasPolicyForFavorite(favorite, profile_prefs)); | |
| 366 | |
| 367 gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork( | |
| 368 ash::network_icon::ICON_TYPE_LIST, favorite->type()); | |
| 369 SetCommonNetworkInfo(favorite, icon, icon_scale_factor, network_info.get()); | |
| 370 return network_info.release(); | |
| 371 } | |
| 372 | |
| 373 // Pulls IP information out of a shill service properties dictionary. If | 338 // Pulls IP information out of a shill service properties dictionary. If |
| 374 // |static_ip| is true, then it fetches "StaticIP.*" properties. If not, then it | 339 // |static_ip| is true, then it fetches "StaticIP.*" properties. If not, then it |
| 375 // fetches "SavedIP.*" properties. Caller must take ownership of returned | 340 // fetches "SavedIP.*" properties. Caller must take ownership of returned |
| 376 // dictionary. If non-NULL, |ip_parameters_set| returns a count of the number | 341 // dictionary. If non-NULL, |ip_parameters_set| returns a count of the number |
| 377 // of IP routing parameters that get set. | 342 // of IP routing parameters that get set. |
| 378 base::DictionaryValue* BuildIPInfoDictionary( | 343 base::DictionaryValue* BuildIPInfoDictionary( |
| 379 const base::DictionaryValue& shill_properties, | 344 const base::DictionaryValue& shill_properties, |
| 380 bool static_ip, | 345 bool static_ip, |
| 381 int* routing_parameters_set) { | 346 int* routing_parameters_set) { |
| 382 std::string address_key; | 347 std::string address_key; |
| (...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 web_ui()->GetDeviceScaleFactor(), | 1702 web_ui()->GetDeviceScaleFactor(), |
| 1738 Profile::FromWebUI(web_ui())->GetPrefs())); | 1703 Profile::FromWebUI(web_ui())->GetPrefs())); |
| 1739 return list; | 1704 return list; |
| 1740 } | 1705 } |
| 1741 | 1706 |
| 1742 base::ListValue* InternetOptionsHandler::GetWirelessList() { | 1707 base::ListValue* InternetOptionsHandler::GetWirelessList() { |
| 1743 base::ListValue* list = new base::ListValue(); | 1708 base::ListValue* list = new base::ListValue(); |
| 1744 | 1709 |
| 1745 NetworkStateHandler::NetworkStateList networks; | 1710 NetworkStateHandler::NetworkStateList networks; |
| 1746 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( | 1711 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( |
| 1747 NetworkTypePattern::Wireless(), &networks); | 1712 NetworkTypePattern::Wireless(), |
| 1713 false /* configured_only */, |
| 1714 true /* visible_only */, |
| 1715 0 /* no limit */, |
| 1716 &networks); |
| 1748 for (NetworkStateHandler::NetworkStateList::const_iterator iter = | 1717 for (NetworkStateHandler::NetworkStateList::const_iterator iter = |
| 1749 networks.begin(); iter != networks.end(); ++iter) { | 1718 networks.begin(); iter != networks.end(); ++iter) { |
| 1750 list->Append( | 1719 list->Append( |
| 1751 BuildNetworkDictionary(*iter, | 1720 BuildNetworkDictionary(*iter, |
| 1752 web_ui()->GetDeviceScaleFactor(), | 1721 web_ui()->GetDeviceScaleFactor(), |
| 1753 Profile::FromWebUI(web_ui())->GetPrefs())); | 1722 Profile::FromWebUI(web_ui())->GetPrefs())); |
| 1754 } | 1723 } |
| 1755 | 1724 |
| 1756 return list; | 1725 return list; |
| 1757 } | 1726 } |
| 1758 | 1727 |
| 1759 base::ListValue* InternetOptionsHandler::GetVPNList() { | 1728 base::ListValue* InternetOptionsHandler::GetVPNList() { |
| 1760 base::ListValue* list = new base::ListValue(); | 1729 base::ListValue* list = new base::ListValue(); |
| 1761 | 1730 |
| 1762 NetworkStateHandler::NetworkStateList networks; | 1731 NetworkStateHandler::NetworkStateList networks; |
| 1763 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( | 1732 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( |
| 1764 NetworkTypePattern::VPN(), &networks); | 1733 NetworkTypePattern::VPN(), |
| 1734 false /* configured_only */, |
| 1735 true /* visible_only */, |
| 1736 0 /* no limit */, |
| 1737 &networks); |
| 1765 for (NetworkStateHandler::NetworkStateList::const_iterator iter = | 1738 for (NetworkStateHandler::NetworkStateList::const_iterator iter = |
| 1766 networks.begin(); iter != networks.end(); ++iter) { | 1739 networks.begin(); iter != networks.end(); ++iter) { |
| 1767 list->Append( | 1740 list->Append( |
| 1768 BuildNetworkDictionary(*iter, | 1741 BuildNetworkDictionary(*iter, |
| 1769 web_ui()->GetDeviceScaleFactor(), | 1742 web_ui()->GetDeviceScaleFactor(), |
| 1770 Profile::FromWebUI(web_ui())->GetPrefs())); | 1743 Profile::FromWebUI(web_ui())->GetPrefs())); |
| 1771 } | 1744 } |
| 1772 | 1745 |
| 1773 return list; | 1746 return list; |
| 1774 } | 1747 } |
| 1775 | 1748 |
| 1776 base::ListValue* InternetOptionsHandler::GetRememberedList() { | 1749 base::ListValue* InternetOptionsHandler::GetRememberedList() { |
| 1777 base::ListValue* list = new base::ListValue(); | 1750 base::ListValue* list = new base::ListValue(); |
| 1778 | 1751 |
| 1779 NetworkStateHandler::FavoriteStateList favorites; | 1752 NetworkStateHandler::NetworkStateList networks; |
| 1780 NetworkHandler::Get()->network_state_handler()->GetFavoriteList(&favorites); | 1753 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( |
| 1781 for (NetworkStateHandler::FavoriteStateList::const_iterator iter = | 1754 NetworkTypePattern::Default(), |
| 1782 favorites.begin(); iter != favorites.end(); ++iter) { | 1755 true /* configured_only */, |
| 1783 const FavoriteState* favorite = *iter; | 1756 false /* visible_only */, |
| 1784 if (favorite->type() != shill::kTypeWifi && | 1757 0 /* no limit */, |
| 1785 favorite->type() != shill::kTypeVPN) | 1758 &networks); |
| 1759 for (NetworkStateHandler::NetworkStateList::const_iterator iter = |
| 1760 networks.begin(); iter != networks.end(); ++iter) { |
| 1761 const NetworkState* network = *iter; |
| 1762 if (network->type() != shill::kTypeWifi && |
| 1763 network->type() != shill::kTypeVPN) |
| 1786 continue; | 1764 continue; |
| 1787 list->Append( | 1765 list->Append( |
| 1788 BuildFavoriteDictionary(favorite, | 1766 BuildNetworkDictionary(network, |
| 1789 web_ui()->GetDeviceScaleFactor(), | 1767 web_ui()->GetDeviceScaleFactor(), |
| 1790 Profile::FromWebUI(web_ui())->GetPrefs())); | 1768 Profile::FromWebUI(web_ui())->GetPrefs())); |
| 1791 } | 1769 } |
| 1792 | 1770 |
| 1793 return list; | 1771 return list; |
| 1794 } | 1772 } |
| 1795 | 1773 |
| 1796 void InternetOptionsHandler::FillNetworkInfo( | 1774 void InternetOptionsHandler::FillNetworkInfo( |
| 1797 base::DictionaryValue* dictionary) { | 1775 base::DictionaryValue* dictionary) { |
| 1798 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 1776 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| 1799 dictionary->Set(kTagWiredList, GetWiredList()); | 1777 dictionary->Set(kTagWiredList, GetWiredList()); |
| 1800 dictionary->Set(kTagWirelessList, GetWirelessList()); | 1778 dictionary->Set(kTagWirelessList, GetWirelessList()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1823 dictionary->SetBoolean( | 1801 dictionary->SetBoolean( |
| 1824 kTagWimaxAvailable, | 1802 kTagWimaxAvailable, |
| 1825 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1803 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
| 1826 dictionary->SetBoolean( | 1804 dictionary->SetBoolean( |
| 1827 kTagWimaxEnabled, | 1805 kTagWimaxEnabled, |
| 1828 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1806 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
| 1829 } | 1807 } |
| 1830 | 1808 |
| 1831 } // namespace options | 1809 } // namespace options |
| 1832 } // namespace chromeos | 1810 } // namespace chromeos |
| OLD | NEW |