| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 const FavoriteState* favorite = | 305 const FavoriteState* favorite = |
| 306 NetworkHandler::Get()->network_state_handler()->GetFavoriteState( | 306 NetworkHandler::Get()->network_state_handler()->GetFavoriteState( |
| 307 network->path()); | 307 network->path()); |
| 308 if (!favorite) | 308 if (!favorite) |
| 309 return false; | 309 return false; |
| 310 return HasPolicyForFavorite(favorite, profile_prefs); | 310 return HasPolicyForFavorite(favorite, profile_prefs); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void SetCommonNetworkInfo(const ManagedState* state, | 313 void SetCommonNetworkInfo(const ManagedState* state, |
| 314 const gfx::ImageSkia& icon, | 314 const gfx::ImageSkia& icon, |
| 315 ui::ScaleFactor icon_scale_factor, | 315 float icon_scale_factor, |
| 316 base::DictionaryValue* network_info) { | 316 base::DictionaryValue* network_info) { |
| 317 gfx::ImageSkiaRep image_rep = | 317 gfx::ImageSkiaRep image_rep = |
| 318 icon.GetRepresentation(ui::GetImageScale(icon_scale_factor)); | 318 icon.GetRepresentation(icon_scale_factor); |
| 319 std::string icon_url = | 319 std::string icon_url = |
| 320 icon.isNull() ? "" : webui::GetBitmapDataUrl(image_rep.sk_bitmap()); | 320 icon.isNull() ? "" : webui::GetBitmapDataUrl(image_rep.sk_bitmap()); |
| 321 network_info->SetString(kNetworkInfoKeyIconURL, icon_url); | 321 network_info->SetString(kNetworkInfoKeyIconURL, icon_url); |
| 322 | 322 |
| 323 std::string name = state->name(); | 323 std::string name = state->name(); |
| 324 if (state->Matches(NetworkTypePattern::Ethernet())) { | 324 if (state->Matches(NetworkTypePattern::Ethernet())) { |
| 325 name = internet_options_strings::NetworkDeviceTypeString( | 325 name = internet_options_strings::NetworkDeviceTypeString( |
| 326 shill::kTypeEthernet); | 326 shill::kTypeEthernet); |
| 327 } | 327 } |
| 328 network_info->SetString(kNetworkInfoKeyNetworkName, name); | 328 network_info->SetString(kNetworkInfoKeyNetworkName, name); |
| 329 network_info->SetString(kNetworkInfoKeyNetworkType, state->type()); | 329 network_info->SetString(kNetworkInfoKeyNetworkType, state->type()); |
| 330 network_info->SetString(kNetworkInfoKeyServicePath, state->path()); | 330 network_info->SetString(kNetworkInfoKeyServicePath, state->path()); |
| 331 } | 331 } |
| 332 | 332 |
| 333 // Builds a dictionary with network information and an icon used for the | 333 // Builds a dictionary with network information and an icon used for the |
| 334 // NetworkList on the settings page. Ownership of the returned pointer is | 334 // NetworkList on the settings page. Ownership of the returned pointer is |
| 335 // transferred to the caller. | 335 // transferred to the caller. |
| 336 base::DictionaryValue* BuildNetworkDictionary( | 336 base::DictionaryValue* BuildNetworkDictionary( |
| 337 const NetworkState* network, | 337 const NetworkState* network, |
| 338 ui::ScaleFactor icon_scale_factor, | 338 float icon_scale_factor, |
| 339 const PrefService* profile_prefs) { | 339 const PrefService* profile_prefs) { |
| 340 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); | 340 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); |
| 341 network_info->SetBoolean(kNetworkInfoKeyConnectable, network->connectable()); | 341 network_info->SetBoolean(kNetworkInfoKeyConnectable, network->connectable()); |
| 342 network_info->SetBoolean(kNetworkInfoKeyConnected, | 342 network_info->SetBoolean(kNetworkInfoKeyConnected, |
| 343 network->IsConnectedState()); | 343 network->IsConnectedState()); |
| 344 network_info->SetBoolean(kNetworkInfoKeyConnecting, | 344 network_info->SetBoolean(kNetworkInfoKeyConnecting, |
| 345 network->IsConnectingState()); | 345 network->IsConnectingState()); |
| 346 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, | 346 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, |
| 347 HasPolicyForNetwork(network, profile_prefs)); | 347 HasPolicyForNetwork(network, profile_prefs)); |
| 348 | 348 |
| 349 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork( | 349 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork( |
| 350 network, ash::network_icon::ICON_TYPE_LIST); | 350 network, ash::network_icon::ICON_TYPE_LIST); |
| 351 SetCommonNetworkInfo(network, icon, icon_scale_factor, network_info.get()); | 351 SetCommonNetworkInfo(network, icon, icon_scale_factor, network_info.get()); |
| 352 return network_info.release(); | 352 return network_info.release(); |
| 353 } | 353 } |
| 354 | 354 |
| 355 base::DictionaryValue* BuildFavoriteDictionary( | 355 base::DictionaryValue* BuildFavoriteDictionary( |
| 356 const FavoriteState* favorite, | 356 const FavoriteState* favorite, |
| 357 ui::ScaleFactor icon_scale_factor, | 357 float icon_scale_factor, |
| 358 const PrefService* profile_prefs) { | 358 const PrefService* profile_prefs) { |
| 359 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); | 359 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); |
| 360 network_info->SetBoolean(kNetworkInfoKeyConnectable, false); | 360 network_info->SetBoolean(kNetworkInfoKeyConnectable, false); |
| 361 network_info->SetBoolean(kNetworkInfoKeyConnected, false); | 361 network_info->SetBoolean(kNetworkInfoKeyConnected, false); |
| 362 network_info->SetBoolean(kNetworkInfoKeyConnecting, false); | 362 network_info->SetBoolean(kNetworkInfoKeyConnecting, false); |
| 363 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, | 363 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, |
| 364 HasPolicyForFavorite(favorite, profile_prefs)); | 364 HasPolicyForFavorite(favorite, profile_prefs)); |
| 365 | 365 |
| 366 gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork( | 366 gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork( |
| 367 ash::network_icon::ICON_TYPE_LIST, favorite->type()); | 367 ash::network_icon::ICON_TYPE_LIST, favorite->type()); |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 | 1253 |
| 1254 void InternetOptionsHandler::RefreshNetworksCallback( | 1254 void InternetOptionsHandler::RefreshNetworksCallback( |
| 1255 const base::ListValue* args) { | 1255 const base::ListValue* args) { |
| 1256 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 1256 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 std::string InternetOptionsHandler::GetIconDataUrl(int resource_id) const { | 1259 std::string InternetOptionsHandler::GetIconDataUrl(int resource_id) const { |
| 1260 gfx::ImageSkia* icon = | 1260 gfx::ImageSkia* icon = |
| 1261 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); | 1261 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); |
| 1262 gfx::ImageSkiaRep image_rep = icon->GetRepresentation( | 1262 gfx::ImageSkiaRep image_rep = icon->GetRepresentation( |
| 1263 ui::GetImageScale(web_ui()->GetDeviceScaleFactor())); | 1263 web_ui()->GetDeviceScaleFactor()); |
| 1264 return webui::GetBitmapDataUrl(image_rep.sk_bitmap()); | 1264 return webui::GetBitmapDataUrl(image_rep.sk_bitmap()); |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 void InternetOptionsHandler::RefreshNetworkData() { | 1267 void InternetOptionsHandler::RefreshNetworkData() { |
| 1268 base::DictionaryValue dictionary; | 1268 base::DictionaryValue dictionary; |
| 1269 FillNetworkInfo(&dictionary); | 1269 FillNetworkInfo(&dictionary); |
| 1270 web_ui()->CallJavascriptFunction( | 1270 web_ui()->CallJavascriptFunction( |
| 1271 kRefreshNetworkDataFunction, dictionary); | 1271 kRefreshNetworkDataFunction, dictionary); |
| 1272 } | 1272 } |
| 1273 | 1273 |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 dictionary->SetBoolean( | 1819 dictionary->SetBoolean( |
| 1820 kTagWimaxAvailable, | 1820 kTagWimaxAvailable, |
| 1821 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1821 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
| 1822 dictionary->SetBoolean( | 1822 dictionary->SetBoolean( |
| 1823 kTagWimaxEnabled, | 1823 kTagWimaxEnabled, |
| 1824 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1824 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
| 1825 } | 1825 } |
| 1826 | 1826 |
| 1827 } // namespace options | 1827 } // namespace options |
| 1828 } // namespace chromeos | 1828 } // namespace chromeos |
| OLD | NEW |