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

Side by Side Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 8759014: Add ONC VPN support for OpenVPN and L2TP/IPsec VPNs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/cros/network_library.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include <dbus/dbus-glib.h> 7 #include <dbus/dbus-glib.h>
8 #include <dbus/dbus-gtype-specialized.h> 8 #include <dbus/dbus-gtype-specialized.h>
9 #include <glib-object.h> 9 #include <glib-object.h>
10 10
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 return new GValue(); 316 return new GValue();
317 } 317 }
318 318
319 GHashTable* ConvertDictionaryValueToGValueMap(const DictionaryValue* dict) { 319 GHashTable* ConvertDictionaryValueToGValueMap(const DictionaryValue* dict) {
320 GHashTable* ghash = 320 GHashTable* ghash =
321 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 321 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
322 for (DictionaryValue::key_iterator it = dict->begin_keys(); 322 for (DictionaryValue::key_iterator it = dict->begin_keys();
323 it != dict->end_keys(); ++it) { 323 it != dict->end_keys(); ++it) {
324 std::string key = *it; 324 std::string key = *it;
325 Value* val = NULL; 325 Value* val = NULL;
326 if (dict->Get(key, &val)) { 326 if (dict->GetWithoutPathExpansion(key, &val)) {
327 g_hash_table_insert(ghash, 327 g_hash_table_insert(ghash,
328 g_strdup(const_cast<char*>(key.c_str())), 328 g_strdup(const_cast<char*>(key.c_str())),
329 ConvertValueToGValue(val)); 329 ConvertValueToGValue(val));
330 } else {
331 VLOG(2) << "Could not insert key " << key << " into hash";
330 } 332 }
331 } 333 }
332 return ghash; 334 return ghash;
333 } 335 }
334 336
335 } // namespace 337 } // namespace
336 338
337 //////////////////////////////////////////////////////////////////////////////// 339 ////////////////////////////////////////////////////////////////////////////////
338 // FoundCellularNetwork 340 // FoundCellularNetwork
339 341
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 delete entry; 416 delete entry;
415 entry = value.DeepCopy(); 417 entry = value.DeepCopy();
416 if (VLOG_IS_ON(2)) { 418 if (VLOG_IS_ON(2)) {
417 std::string value_json; 419 std::string value_json;
418 base::JSONWriter::Write(&value, true, &value_json); 420 base::JSONWriter::Write(&value, true, &value_json);
419 VLOG(2) << "Updated property map on network: " 421 VLOG(2) << "Updated property map on network: "
420 << unique_id() << "[" << index << "] = " << value_json; 422 << unique_id() << "[" << index << "] = " << value_json;
421 } 423 }
422 } 424 }
423 425
426 bool Network::GetProperty(PropertyIndex index,
427 const base::Value** value) const {
428 PropertyMap::const_iterator i = property_map_.find(index);
429 if (i == property_map_.end())
430 return false;
431 if (value != NULL)
432 *value = i->second;
433 return true;
434 }
435
424 void Network::SetState(ConnectionState new_state) { 436 void Network::SetState(ConnectionState new_state) {
425 if (new_state == state_) 437 if (new_state == state_)
426 return; 438 return;
427 ConnectionState old_state = state_; 439 ConnectionState old_state = state_;
428 state_ = new_state; 440 state_ = new_state;
429 if (!IsConnectingState(new_state)) 441 if (!IsConnectingState(new_state))
430 set_connection_started(false); 442 set_connection_started(false);
431 if (new_state == STATE_FAILURE) { 443 if (new_state == STATE_FAILURE) {
432 if (old_state != STATE_UNKNOWN && 444 if (old_state != STATE_UNKNOWN &&
433 old_state != STATE_IDLE) { 445 old_state != STATE_IDLE) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 user_passphrase, &user_passphrase_); 811 user_passphrase, &user_passphrase_);
800 SetStringProperty(flimflam::kL2tpIpsecGroupNameProperty, 812 SetStringProperty(flimflam::kL2tpIpsecGroupNameProperty,
801 group_name, &group_name_); 813 group_name, &group_name_);
802 } 814 }
803 815
804 void VirtualNetwork::SetOpenVPNCredentials( 816 void VirtualNetwork::SetOpenVPNCredentials(
805 const std::string& client_cert_id, 817 const std::string& client_cert_id,
806 const std::string& username, 818 const std::string& username,
807 const std::string& user_passphrase, 819 const std::string& user_passphrase,
808 const std::string& otp) { 820 const std::string& otp) {
821 // TODO(kmixter): Are we missing setting the CaCert property?
809 SetStringProperty(flimflam::kOpenVPNClientCertIdProperty, 822 SetStringProperty(flimflam::kOpenVPNClientCertIdProperty,
810 client_cert_id, &client_cert_id_); 823 client_cert_id, &client_cert_id_);
811 SetStringProperty(flimflam::kOpenVPNUserProperty, username, &username_); 824 SetStringProperty(flimflam::kOpenVPNUserProperty, username, &username_);
812 SetStringProperty(flimflam::kOpenVPNPasswordProperty, 825 SetStringProperty(flimflam::kOpenVPNPasswordProperty,
813 user_passphrase, &user_passphrase_); 826 user_passphrase, &user_passphrase_);
814 SetStringProperty(flimflam::kOpenVPNOTPProperty, otp, NULL); 827 SetStringProperty(flimflam::kOpenVPNOTPProperty, otp, NULL);
815 } 828 }
816 829
817 void VirtualNetwork::SetCertificateSlotAndPin( 830 void VirtualNetwork::SetCertificateSlotAndPin(
818 const std::string& slot, const std::string& pin) { 831 const std::string& slot, const std::string& pin) {
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 if (!parser.ParseCertificate(i)) { 2838 if (!parser.ParseCertificate(i)) {
2826 DLOG(WARNING) << "Cannot parse certificate in ONC file"; 2839 DLOG(WARNING) << "Cannot parse certificate in ONC file";
2827 return false; 2840 return false;
2828 } 2841 }
2829 } 2842 }
2830 2843
2831 for (int i = 0; i < parser.GetNetworkConfigsSize(); i++) { 2844 for (int i = 0; i < parser.GetNetworkConfigsSize(); i++) {
2832 // Parse Open Network Configuration blob into a temporary Network object. 2845 // Parse Open Network Configuration blob into a temporary Network object.
2833 scoped_ptr<Network> network(parser.ParseNetwork(i)); 2846 scoped_ptr<Network> network(parser.ParseNetwork(i));
2834 if (!network.get()) { 2847 if (!network.get()) {
2835 DLOG(WARNING) << "Cannot parse networks in ONC file"; 2848 DLOG(WARNING) << "Cannot parse network in ONC file";
2836 return false; 2849 return false;
2837 } 2850 }
2838 2851
2839 DictionaryValue dict; 2852 DictionaryValue dict;
2840 for (Network::PropertyMap::const_iterator props = 2853 for (Network::PropertyMap::const_iterator props =
2841 network->property_map_.begin(); 2854 network->property_map_.begin();
2842 props != network->property_map_.end(); ++props) { 2855 props != network->property_map_.end(); ++props) {
2843 std::string key = 2856 std::string key =
2844 NativeNetworkParser::property_mapper()->GetKey(props->first); 2857 NativeNetworkParser::property_mapper()->GetKey(props->first);
2845 if (!key.empty()) 2858 if (!key.empty())
2846 dict.SetWithoutPathExpansion(key, props->second->DeepCopy()); 2859 dict.SetWithoutPathExpansion(key, props->second->DeepCopy());
2860 else
2861 VLOG(2) << "Property " << props->first << " will not be sent";
2847 } 2862 }
2848 2863
2849 CallConfigureService(network->unique_id(), &dict); 2864 CallConfigureService(network->unique_id(), &dict);
2850 } 2865 }
2851 return parser.GetNetworkConfigsSize() != 0; 2866 return parser.GetNetworkConfigsSize() != 0;
2852 } 2867 }
2853 2868
2854 //////////////////////////////////////////////////////////////////////////// 2869 ////////////////////////////////////////////////////////////////////////////
2855 // Testing functions. 2870 // Testing functions.
2856 2871
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
3681 if (error != NETWORK_METHOD_ERROR_NONE) { 3696 if (error != NETWORK_METHOD_ERROR_NONE) {
3682 LOG(WARNING) << "Error from ConfigureService callback for: " 3697 LOG(WARNING) << "Error from ConfigureService callback for: "
3683 << service_path 3698 << service_path
3684 << " Error: " << error << " Message: " << error_message; 3699 << " Error: " << error << " Message: " << error_message;
3685 } 3700 }
3686 } 3701 }
3687 3702
3688 void NetworkLibraryImplCros::CallConfigureService(const std::string& identifier, 3703 void NetworkLibraryImplCros::CallConfigureService(const std::string& identifier,
3689 const DictionaryValue* info) { 3704 const DictionaryValue* info) {
3690 GHashTable* ghash = ConvertDictionaryValueToGValueMap(info); 3705 GHashTable* ghash = ConvertDictionaryValueToGValueMap(info);
3706 if (VLOG_IS_ON(2)) {
3707 scoped_ptr<DictionaryValue> dict(ConvertGHashTable(ghash));
3708 std::string dict_json;
3709 base::JSONWriter::Write(static_cast<Value*>(dict.get()), true, &dict_json);
3710 VLOG(2) << "ConfigureService will be called on:" << dict_json;
3711 }
3691 chromeos::ConfigureService(identifier.c_str(), ghash, 3712 chromeos::ConfigureService(identifier.c_str(), ghash,
3692 ConfigureServiceCallback, this); 3713 ConfigureServiceCallback, this);
3693 } 3714 }
3694 3715
3695 // static callback 3716 // static callback
3696 void NetworkLibraryImplCros::NetworkConnectCallback( 3717 void NetworkLibraryImplCros::NetworkConnectCallback(
3697 void* object, 3718 void* object,
3698 const char* service_path, 3719 const char* service_path,
3699 NetworkMethodErrorType error, 3720 NetworkMethodErrorType error,
3700 const char* error_message) { 3721 const char* error_message) {
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
5253 return impl; 5274 return impl;
5254 } 5275 }
5255 5276
5256 ///////////////////////////////////////////////////////////////////////////// 5277 /////////////////////////////////////////////////////////////////////////////
5257 5278
5258 } // namespace chromeos 5279 } // namespace chromeos
5259 5280
5260 // Allows InvokeLater without adding refcounting. This class is a Singleton and 5281 // Allows InvokeLater without adding refcounting. This class is a Singleton and
5261 // won't be deleted until its last InvokeLater is run. 5282 // won't be deleted until its last InvokeLater is run.
5262 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); 5283 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698