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

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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 delete entry; 414 delete entry;
415 entry = value.DeepCopy(); 415 entry = value.DeepCopy();
416 if (VLOG_IS_ON(2)) { 416 if (VLOG_IS_ON(2)) {
417 std::string value_json; 417 std::string value_json;
418 base::JSONWriter::Write(&value, true, &value_json); 418 base::JSONWriter::Write(&value, true, &value_json);
419 VLOG(2) << "Updated property map on network: " 419 VLOG(2) << "Updated property map on network: "
420 << unique_id() << "[" << index << "] = " << value_json; 420 << unique_id() << "[" << index << "] = " << value_json;
421 } 421 }
422 } 422 }
423 423
424 bool Network::GetProperty(PropertyIndex index,
425 const base::Value** value) const {
426 PropertyMap::const_iterator i = property_map_.find(index);
427 if (i == property_map_.end())
428 return false;
429 if (value != NULL)
430 *value = i->second;
431 return true;
432 }
433
424 void Network::SetState(ConnectionState new_state) { 434 void Network::SetState(ConnectionState new_state) {
425 if (new_state == state_) 435 if (new_state == state_)
426 return; 436 return;
427 ConnectionState old_state = state_; 437 ConnectionState old_state = state_;
428 state_ = new_state; 438 state_ = new_state;
429 if (!IsConnectingState(new_state)) 439 if (!IsConnectingState(new_state))
430 set_connection_started(false); 440 set_connection_started(false);
431 if (new_state == STATE_FAILURE) { 441 if (new_state == STATE_FAILURE) {
432 if (old_state != STATE_UNKNOWN && 442 if (old_state != STATE_UNKNOWN &&
433 old_state != STATE_IDLE) { 443 old_state != STATE_IDLE) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 user_passphrase, &user_passphrase_); 809 user_passphrase, &user_passphrase_);
800 SetStringProperty(flimflam::kL2tpIpsecGroupNameProperty, 810 SetStringProperty(flimflam::kL2tpIpsecGroupNameProperty,
801 group_name, &group_name_); 811 group_name, &group_name_);
802 } 812 }
803 813
804 void VirtualNetwork::SetOpenVPNCredentials( 814 void VirtualNetwork::SetOpenVPNCredentials(
805 const std::string& client_cert_id, 815 const std::string& client_cert_id,
806 const std::string& username, 816 const std::string& username,
807 const std::string& user_passphrase, 817 const std::string& user_passphrase,
808 const std::string& otp) { 818 const std::string& otp) {
819 // TODO(kmixter): Are we missing setting the CaCert property?
809 SetStringProperty(flimflam::kOpenVPNClientCertIdProperty, 820 SetStringProperty(flimflam::kOpenVPNClientCertIdProperty,
810 client_cert_id, &client_cert_id_); 821 client_cert_id, &client_cert_id_);
811 SetStringProperty(flimflam::kOpenVPNUserProperty, username, &username_); 822 SetStringProperty(flimflam::kOpenVPNUserProperty, username, &username_);
812 SetStringProperty(flimflam::kOpenVPNPasswordProperty, 823 SetStringProperty(flimflam::kOpenVPNPasswordProperty,
813 user_passphrase, &user_passphrase_); 824 user_passphrase, &user_passphrase_);
814 SetStringProperty(flimflam::kOpenVPNOTPProperty, otp, NULL); 825 SetStringProperty(flimflam::kOpenVPNOTPProperty, otp, NULL);
815 } 826 }
816 827
817 void VirtualNetwork::SetCertificateSlotAndPin( 828 void VirtualNetwork::SetCertificateSlotAndPin(
818 const std::string& slot, const std::string& pin) { 829 const std::string& slot, const std::string& pin) {
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 } 2848 }
2838 2849
2839 DictionaryValue dict; 2850 DictionaryValue dict;
2840 for (Network::PropertyMap::const_iterator props = 2851 for (Network::PropertyMap::const_iterator props =
2841 network->property_map_.begin(); 2852 network->property_map_.begin();
2842 props != network->property_map_.end(); ++props) { 2853 props != network->property_map_.end(); ++props) {
2843 std::string key = 2854 std::string key =
2844 NativeNetworkParser::property_mapper()->GetKey(props->first); 2855 NativeNetworkParser::property_mapper()->GetKey(props->first);
2845 if (!key.empty()) 2856 if (!key.empty())
2846 dict.SetWithoutPathExpansion(key, props->second->DeepCopy()); 2857 dict.SetWithoutPathExpansion(key, props->second->DeepCopy());
2858 else
2859 VLOG(2) << "Property " << props->first << " will not be sent";
2847 } 2860 }
2848 2861
2849 CallConfigureService(network->unique_id(), &dict); 2862 CallConfigureService(network->unique_id(), &dict);
2850 } 2863 }
2851 return parser.GetNetworkConfigsSize() != 0; 2864 return parser.GetNetworkConfigsSize() != 0;
2852 } 2865 }
2853 2866
2854 //////////////////////////////////////////////////////////////////////////// 2867 ////////////////////////////////////////////////////////////////////////////
2855 // Testing functions. 2868 // Testing functions.
2856 2869
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
3681 if (error != NETWORK_METHOD_ERROR_NONE) { 3694 if (error != NETWORK_METHOD_ERROR_NONE) {
3682 LOG(WARNING) << "Error from ConfigureService callback for: " 3695 LOG(WARNING) << "Error from ConfigureService callback for: "
3683 << service_path 3696 << service_path
3684 << " Error: " << error << " Message: " << error_message; 3697 << " Error: " << error << " Message: " << error_message;
3685 } 3698 }
3686 } 3699 }
3687 3700
3688 void NetworkLibraryImplCros::CallConfigureService(const std::string& identifier, 3701 void NetworkLibraryImplCros::CallConfigureService(const std::string& identifier,
3689 const DictionaryValue* info) { 3702 const DictionaryValue* info) {
3690 GHashTable* ghash = ConvertDictionaryValueToGValueMap(info); 3703 GHashTable* ghash = ConvertDictionaryValueToGValueMap(info);
3704 if (VLOG_IS_ON(2)) {
3705 scoped_ptr<DictionaryValue> dict(ConvertGHashTable(ghash));
3706 std::string dict_json;
3707 base::JSONWriter::Write(static_cast<Value*>(dict.get()), true, &dict_json);
3708 VLOG(2) << "ConfigureService will be called on:" << dict_json;
3709 }
3691 chromeos::ConfigureService(identifier.c_str(), ghash, 3710 chromeos::ConfigureService(identifier.c_str(), ghash,
3692 ConfigureServiceCallback, this); 3711 ConfigureServiceCallback, this);
3693 } 3712 }
3694 3713
3695 // static callback 3714 // static callback
3696 void NetworkLibraryImplCros::NetworkConnectCallback( 3715 void NetworkLibraryImplCros::NetworkConnectCallback(
3697 void* object, 3716 void* object,
3698 const char* service_path, 3717 const char* service_path,
3699 NetworkMethodErrorType error, 3718 NetworkMethodErrorType error,
3700 const char* error_message) { 3719 const char* error_message) {
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
5253 return impl; 5272 return impl;
5254 } 5273 }
5255 5274
5256 ///////////////////////////////////////////////////////////////////////////// 5275 /////////////////////////////////////////////////////////////////////////////
5257 5276
5258 } // namespace chromeos 5277 } // namespace chromeos
5259 5278
5260 // Allows InvokeLater without adding refcounting. This class is a Singleton and 5279 // Allows InvokeLater without adding refcounting. This class is a Singleton and
5261 // won't be deleted until its last InvokeLater is run. 5280 // won't be deleted until its last InvokeLater is run.
5262 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); 5281 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698