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

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

Issue 539573002: Elim 'Translated' from Managed ONC dictionary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "ui/base/resource/resource_bundle.h" 56 #include "ui/base/resource/resource_bundle.h"
57 #include "ui/base/webui/web_ui_util.h" 57 #include "ui/base/webui/web_ui_util.h"
58 #include "ui/chromeos/network/network_icon.h" 58 #include "ui/chromeos/network/network_icon.h"
59 #include "ui/gfx/image/image_skia.h" 59 #include "ui/gfx/image/image_skia.h"
60 60
61 namespace chromeos { 61 namespace chromeos {
62 namespace options { 62 namespace options {
63 63
64 namespace { 64 namespace {
65 65
66 // The key in a Managed Value dictionary for translated values.
67 // TODO(stevenjb): Consider making this part of the ONC spec.
68 const char kTranslatedKey[] = "Translated";
69
70 // Keys for the network description dictionary passed to the web ui. Make sure 66 // Keys for the network description dictionary passed to the web ui. Make sure
71 // to keep the strings in sync with what the JavaScript side uses. 67 // to keep the strings in sync with what the JavaScript side uses.
72 const char kNetworkInfoKeyIconURL[] = "iconURL"; 68 const char kNetworkInfoKeyIconURL[] = "iconURL";
73 const char kNetworkInfoKeyServicePath[] = "servicePath"; 69 const char kNetworkInfoKeyServicePath[] = "servicePath";
74 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; 70 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged";
75 71
76 // These are keys for getting IP information from the web ui. 72 // These are keys for getting IP information from the web ui.
77 const char kIpConfigAddress[] = "address"; 73 const char kIpConfigAddress[] = "address";
78 const char kIpConfigPrefixLength[] = "prefixLength"; 74 const char kIpConfigPrefixLength[] = "prefixLength";
79 const char kIpConfigNetmask[] = "netmask"; 75 const char kIpConfigNetmask[] = "netmask";
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 recommended = onc::IsRecommendedValue(onc, onc_key); 378 recommended = onc::IsRecommendedValue(onc, onc_key);
383 } 379 }
384 SetManagedValueDictionaryEx(settings_dict_key, 380 SetManagedValueDictionaryEx(settings_dict_key,
385 value, 381 value,
386 onc_source, 382 onc_source,
387 recommended, 383 recommended,
388 default_value, 384 default_value,
389 settings_dict); 385 settings_dict);
390 } 386 }
391 387
392 // Creates a GetManagedProperties style dictionary with an Active value and
393 // a Translated value, and adds it to |settings|.
394 // Note(stevenjb): This is bridge code until we use GetManagedProperties to
395 // retrieve Shill properties and include Translated values.
396 void SetTranslatedDictionary(const char* settings_dict_key,
397 const std::string& value,
398 const std::string& translated_value,
399 base::DictionaryValue* settings_dict) {
400 base::DictionaryValue* dict = new base::DictionaryValue();
401 settings_dict->Set(settings_dict_key, dict);
402 dict->SetString(::onc::kAugmentationActiveSetting, value);
403 dict->SetString(kTranslatedKey, translated_value);
404 }
405
406 // Fills |dictionary| with the configuration details of |vpn|. |onc| is required 388 // Fills |dictionary| with the configuration details of |vpn|. |onc| is required
407 // for augmenting the policy-managed information. 389 // for augmenting the policy-managed information.
408 void PopulateVPNDetails(const NetworkState* vpn, 390 void PopulateVPNDetails(const NetworkState* vpn,
409 const base::DictionaryValue& shill_properties, 391 const base::DictionaryValue& shill_properties,
410 base::DictionaryValue* dictionary) { 392 base::DictionaryValue* dictionary) {
411 // Name and Remembered are set in PopulateConnectionDetails(). 393 // Name and Remembered are set in PopulateConnectionDetails().
412 // Provider properties are stored in the "Provider" dictionary. 394 // Provider properties are stored in the "Provider" dictionary.
413 const base::DictionaryValue* shill_provider_properties = NULL; 395 const base::DictionaryValue* shill_provider_properties = NULL;
414 if (!shill_properties.GetDictionaryWithoutPathExpansion( 396 if (!shill_properties.GetDictionaryWithoutPathExpansion(
415 shill::kProviderProperty, &shill_provider_properties)) { 397 shill::kProviderProperty, &shill_provider_properties)) {
416 LOG(ERROR) << "No provider properties for VPN: " << vpn->path(); 398 LOG(ERROR) << "No provider properties for VPN: " << vpn->path();
417 return; 399 return;
418 } 400 }
419 base::DictionaryValue* vpn_dictionary = new base::DictionaryValue; 401 base::DictionaryValue* vpn_dictionary;
420 dictionary->Set(::onc::network_config::kVPN, vpn_dictionary); 402 if (!dictionary->GetDictionary(
403 ::onc::network_config::kVPN, &vpn_dictionary)) {
404 vpn_dictionary = new base::DictionaryValue;
405 dictionary->Set(::onc::network_config::kVPN, vpn_dictionary);
406 }
421 407
422 std::string shill_provider_type; 408 std::string shill_provider_type;
423 if (!shill_provider_properties->GetStringWithoutPathExpansion( 409 if (!shill_provider_properties->GetStringWithoutPathExpansion(
424 shill::kTypeProperty, &shill_provider_type)) { 410 shill::kTypeProperty, &shill_provider_type)) {
425 LOG(ERROR) << "Shill VPN has no Provider.Type: " << vpn->path(); 411 LOG(ERROR) << "Shill VPN has no Provider.Type: " << vpn->path();
426 return; 412 return;
427 } 413 }
428 std::string onc_provider_type; 414 std::string onc_provider_type;
429 onc::TranslateStringToONC( 415 onc::TranslateStringToONC(
430 onc::kVPNTypeTable, shill_provider_type, &onc_provider_type); 416 onc::kVPNTypeTable, shill_provider_type, &onc_provider_type);
431 SetTranslatedDictionary( 417 vpn_dictionary->SetString(::onc::vpn::kType, onc_provider_type);
432 ::onc::vpn::kType,
433 onc_provider_type,
434 internet_options_strings::ProviderTypeString(shill_provider_type,
435 *shill_provider_properties),
436 vpn_dictionary);
437 418
438 std::string provider_type_key; 419 std::string provider_type_key;
439 std::string username; 420 std::string username;
440 if (shill_provider_type == shill::kProviderOpenVpn) { 421 if (shill_provider_type == shill::kProviderOpenVpn) {
441 provider_type_key = ::onc::vpn::kOpenVPN; 422 provider_type_key = ::onc::vpn::kOpenVPN;
442 shill_provider_properties->GetStringWithoutPathExpansion( 423 shill_provider_properties->GetStringWithoutPathExpansion(
443 shill::kOpenVPNUserProperty, &username); 424 shill::kOpenVPNUserProperty, &username);
444 } else { 425 } else {
445 provider_type_key = ::onc::vpn::kL2TP; 426 provider_type_key = ::onc::vpn::kL2TP;
446 shill_provider_properties->GetStringWithoutPathExpansion( 427 shill_provider_properties->GetStringWithoutPathExpansion(
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 dictionary->SetBoolean( 1537 dictionary->SetBoolean(
1557 kTagWimaxAvailable, 1538 kTagWimaxAvailable,
1558 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 1539 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
1559 dictionary->SetBoolean( 1540 dictionary->SetBoolean(
1560 kTagWimaxEnabled, 1541 kTagWimaxEnabled,
1561 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 1542 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
1562 } 1543 }
1563 1544
1564 } // namespace options 1545 } // namespace options
1565 } // namespace chromeos 1546 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698