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