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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc

Issue 314183002: Cache network icon urls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Address feedback Created 6 years, 6 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
« no previous file with comments | « ash/system/chromeos/network/network_icon.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
305 NetworkHandler::Get() 305 NetworkHandler::Get()
306 ->network_state_handler() 306 ->network_state_handler()
307 ->GetFavoriteStateFromServicePath(network->path(), 307 ->GetFavoriteStateFromServicePath(network->path(),
308 true /* configured_only */); 308 true /* configured_only */);
309 if (!favorite) 309 if (!favorite)
310 return false; 310 return false;
311 return HasPolicyForFavorite(favorite, profile_prefs); 311 return HasPolicyForFavorite(favorite, profile_prefs);
312 } 312 }
313 313
314 void SetCommonNetworkInfo(const ManagedState* state, 314 void SetCommonNetworkInfo(const ManagedState* state,
315 const gfx::ImageSkia& icon, 315 const std::string& icon_url,
316 float icon_scale_factor,
317 base::DictionaryValue* network_info) { 316 base::DictionaryValue* network_info) {
318 gfx::ImageSkiaRep image_rep =
319 icon.GetRepresentation(icon_scale_factor);
320 std::string icon_url =
321 icon.isNull() ? "" : webui::GetBitmapDataUrl(image_rep.sk_bitmap());
322 network_info->SetString(kNetworkInfoKeyIconURL, icon_url); 317 network_info->SetString(kNetworkInfoKeyIconURL, icon_url);
323 318
324 std::string name = state->name(); 319 std::string name = state->name();
325 if (state->Matches(NetworkTypePattern::Ethernet())) { 320 if (state->Matches(NetworkTypePattern::Ethernet())) {
326 name = internet_options_strings::NetworkDeviceTypeString( 321 name = internet_options_strings::NetworkDeviceTypeString(
327 shill::kTypeEthernet); 322 shill::kTypeEthernet);
328 } 323 }
329 network_info->SetString(kNetworkInfoKeyNetworkName, name); 324 network_info->SetString(kNetworkInfoKeyNetworkName, name);
330 network_info->SetString(kNetworkInfoKeyNetworkType, state->type()); 325 network_info->SetString(kNetworkInfoKeyNetworkType, state->type());
331 network_info->SetString(kNetworkInfoKeyServicePath, state->path()); 326 network_info->SetString(kNetworkInfoKeyServicePath, state->path());
332 } 327 }
333 328
334 // Builds a dictionary with network information and an icon used for the 329 // Builds a dictionary with network information and an icon used for the
335 // NetworkList on the settings page. Ownership of the returned pointer is 330 // NetworkList on the settings page. Ownership of the returned pointer is
336 // transferred to the caller. 331 // transferred to the caller.
337 base::DictionaryValue* BuildNetworkDictionary( 332 base::DictionaryValue* BuildNetworkDictionary(
338 const NetworkState* network, 333 const NetworkState* network,
339 float icon_scale_factor, 334 float icon_scale_factor,
340 const PrefService* profile_prefs) { 335 const PrefService* profile_prefs) {
341 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); 336 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue());
342 network_info->SetBoolean(kNetworkInfoKeyConnectable, network->connectable()); 337 network_info->SetBoolean(kNetworkInfoKeyConnectable, network->connectable());
343 network_info->SetBoolean(kNetworkInfoKeyConnected, 338 network_info->SetBoolean(kNetworkInfoKeyConnected,
344 network->IsConnectedState()); 339 network->IsConnectedState());
345 network_info->SetBoolean(kNetworkInfoKeyConnecting, 340 network_info->SetBoolean(kNetworkInfoKeyConnecting,
346 network->IsConnectingState()); 341 network->IsConnectingState());
347 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, 342 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged,
348 HasPolicyForNetwork(network, profile_prefs)); 343 HasPolicyForNetwork(network, profile_prefs));
349 344
350 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork( 345 std::string icon_url = ash::network_icon::GetImageUrlForNetwork(
351 network, ash::network_icon::ICON_TYPE_LIST); 346 network, ash::network_icon::ICON_TYPE_LIST, icon_scale_factor);
352 SetCommonNetworkInfo(network, icon, icon_scale_factor, network_info.get()); 347 SetCommonNetworkInfo(network, icon_url, network_info.get());
353 return network_info.release(); 348 return network_info.release();
354 } 349 }
355 350
356 base::DictionaryValue* BuildFavoriteDictionary( 351 base::DictionaryValue* BuildFavoriteDictionary(
357 const FavoriteState* favorite, 352 const FavoriteState* favorite,
358 float icon_scale_factor, 353 float icon_scale_factor,
359 const PrefService* profile_prefs) { 354 const PrefService* profile_prefs) {
360 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); 355 scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue());
361 network_info->SetBoolean(kNetworkInfoKeyConnectable, false); 356 network_info->SetBoolean(kNetworkInfoKeyConnectable, false);
362 network_info->SetBoolean(kNetworkInfoKeyConnected, false); 357 network_info->SetBoolean(kNetworkInfoKeyConnected, false);
363 network_info->SetBoolean(kNetworkInfoKeyConnecting, false); 358 network_info->SetBoolean(kNetworkInfoKeyConnecting, false);
364 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, 359 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged,
365 HasPolicyForFavorite(favorite, profile_prefs)); 360 HasPolicyForFavorite(favorite, profile_prefs));
366 361
367 gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork( 362 std::string icon_url = ash::network_icon::GetImageUrlForDisconnectedNetwork(
368 ash::network_icon::ICON_TYPE_LIST, favorite->type()); 363 ash::network_icon::ICON_TYPE_LIST, favorite->type(), icon_scale_factor);
369 SetCommonNetworkInfo(favorite, icon, icon_scale_factor, network_info.get()); 364 SetCommonNetworkInfo(favorite, icon_url, network_info.get());
370 return network_info.release(); 365 return network_info.release();
371 } 366 }
372 367
373 // Pulls IP information out of a shill service properties dictionary. If 368 // 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 369 // |static_ip| is true, then it fetches "StaticIP.*" properties. If not, then it
375 // fetches "SavedIP.*" properties. Caller must take ownership of returned 370 // fetches "SavedIP.*" properties. Caller must take ownership of returned
376 // dictionary. If non-NULL, |ip_parameters_set| returns a count of the number 371 // dictionary. If non-NULL, |ip_parameters_set| returns a count of the number
377 // of IP routing parameters that get set. 372 // of IP routing parameters that get set.
378 base::DictionaryValue* BuildIPInfoDictionary( 373 base::DictionaryValue* BuildIPInfoDictionary(
379 const base::DictionaryValue& shill_properties, 374 const base::DictionaryValue& shill_properties,
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 dictionary->SetBoolean( 1818 dictionary->SetBoolean(
1824 kTagWimaxAvailable, 1819 kTagWimaxAvailable,
1825 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 1820 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
1826 dictionary->SetBoolean( 1821 dictionary->SetBoolean(
1827 kTagWimaxEnabled, 1822 kTagWimaxEnabled,
1828 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 1823 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
1829 } 1824 }
1830 1825
1831 } // namespace options 1826 } // namespace options
1832 } // namespace chromeos 1827 } // namespace chromeos
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/network_icon.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698