diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 22:34:33 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 22:34:33 +0000 |
commit | 7c137a880f1e4f80d72bfa05ca5598613c8cf6cc (patch) | |
tree | 41798e3b58690fb6b9e9f6060d359aa0595cb2e7 | |
parent | ca94643b96d80e3ca1f62be7684601a4a1965cb9 (diff) | |
download | chromium_src-7c137a880f1e4f80d72bfa05ca5598613c8cf6cc.zip chromium_src-7c137a880f1e4f80d72bfa05ca5598613c8cf6cc.tar.gz chromium_src-7c137a880f1e4f80d72bfa05ca5598613c8cf6cc.tar.bz2 |
Use NetworkConfigurationHandler to connect from status area
BUG=161869
For chrome/browser/ui/webui/options/chromeos
TBR=nkostylev@chromium.org
Review URL: https://codereview.chromium.org/11428158
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172156 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/system/chromeos/network/network_state_list_detailed_view.cc | 18 | ||||
-rw-r--r-- | chrome/browser/chromeos/chrome_browser_main_chromeos.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/system/ash_system_tray_delegate.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc | 4 | ||||
-rw-r--r-- | chromeos/dbus/shill_device_client.cc | 32 | ||||
-rw-r--r-- | chromeos/dbus/shill_ipconfig_client.cc | 8 | ||||
-rw-r--r-- | chromeos/dbus/shill_manager_client.cc | 41 | ||||
-rw-r--r-- | chromeos/dbus/shill_profile_client.cc | 6 | ||||
-rw-r--r-- | chromeos/dbus/shill_service_client.cc | 55 | ||||
-rw-r--r-- | chromeos/dbus/sms_client.cc | 2 | ||||
-rw-r--r-- | chromeos/network/network_configuration_handler.cc | 22 | ||||
-rw-r--r-- | chromeos/network/network_configuration_handler.h | 13 |
12 files changed, 191 insertions, 29 deletions
diff --git a/ash/system/chromeos/network/network_state_list_detailed_view.cc b/ash/system/chromeos/network/network_state_list_detailed_view.cc index 8c2aa5a..b28bd65 100644 --- a/ash/system/chromeos/network/network_state_list_detailed_view.cc +++ b/ash/system/chromeos/network/network_state_list_detailed_view.cc @@ -14,6 +14,7 @@ #include "ash/system/tray/tray_views.h" #include "base/utf_string_conversions.h" #include "chromeos/network/device_state.h" +#include "chromeos/network/network_configuration_handler.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" #include "grit/ash_resources.h" @@ -234,8 +235,21 @@ void NetworkStateListDetailedView::ClickedOn(views::View* sender) { std::map<views::View*, std::string>::iterator found = network_map_.find(sender); if (found != network_map_.end()) { - std::string network_id = found->second; - delegate->ConnectToNetwork(network_id); + std::string service_path = found->second; + const chromeos::NetworkState* network = + chromeos::NetworkStateHandler::Get()->GetNetworkState(service_path); + if (!network) + return; + if (!network->IsConnectedState()) { + chromeos::NetworkConfigurationHandler::Get()->Connect( + service_path, + base::Closure(), + chromeos::network_handler::ErrorCallback()); + } else { + // This will show the settings UI for a connected network. + // TODO(stevenjb): Change the API to explicitly show network settings. + delegate->ConnectToNetwork(service_path); + } } } } diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 8533823..08b03bd 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -82,6 +82,7 @@ #include "chromeos/dbus/session_manager_client.h" #include "chromeos/disks/disk_mount_manager.h" #include "chromeos/display/output_configurator.h" +#include "chromeos/network/network_configuration_handler.h" #include "chromeos/network/network_event_log.h" #include "chromeos/network/network_state_handler.h" #include "chromeos/power/power_state_override.h" @@ -274,6 +275,7 @@ class DBusServices { return; chromeos::network_event_log::Initialize(); chromeos::NetworkStateHandler::Initialize(); + chromeos::NetworkConfigurationHandler::Initialize(); network_handlers_initialized_ = true; } @@ -288,6 +290,7 @@ class DBusServices { if (network_handlers_initialized_) { chromeos::NetworkStateHandler::Shutdown(); + chromeos::NetworkConfigurationHandler::Shutdown(); chromeos::network_event_log::Shutdown(); } diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc index faab705..cfd87ab 100644 --- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc +++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc @@ -27,6 +27,7 @@ #include "base/bind_helpers.h" #include "base/callback.h" #include "base/chromeos/chromeos_version.h" +#include "base/command_line.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" #include "base/utf_string_conversions.h" @@ -67,6 +68,7 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power_manager_client.h" #include "chromeos/dbus/root_power_manager_client.h" @@ -629,8 +631,18 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, virtual void ConnectToNetwork(const std::string& network_id) OVERRIDE { NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); Network* network = crosnet->FindNetworkByPath(network_id); - if (network) - network_menu_->ConnectToNetwork(network); + if (CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kEnableNewNetworkHandlers)) { + // If the new network handlers are enabled, this should always trigger + // displaying the network settings UI. + if (network) + network_menu_->ShowTabbedNetworkSettings(network); + else + ShowNetworkSettings(); + } else { + if (network) + network_menu_->ConnectToNetwork(network); + } } virtual void RequestNetworkScan() OVERRIDE { diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc index 39506dd..5d3ae7c 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -1181,6 +1181,8 @@ void InternetOptionsHandler::PopulateDictionaryDetails( void InternetOptionsHandler::PopulateDictionaryDetailsCallback( const std::string& service_path, const base::DictionaryValue* shill_properties) { + if (!shill_properties) + return; chromeos::Network* network = cros_->FindNetworkByPath(service_path); if (!network) return; @@ -1201,6 +1203,8 @@ void InternetOptionsHandler::PopulateIPConfigsCallback( base::DictionaryValue* shill_properties, const chromeos::NetworkIPConfigVector& ipconfigs, const std::string& hardware_address) { + if (!shill_properties) + return; if (VLOG_IS_ON(2)) { std::string properties_json; base::JSONWriter::WriteWithOptions(shill_properties, diff --git a/chromeos/dbus/shill_device_client.cc b/chromeos/dbus/shill_device_client.cc index 2f23db7..efde010 100644 --- a/chromeos/dbus/shill_device_client.cc +++ b/chromeos/dbus/shill_device_client.cc @@ -237,6 +237,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, virtual void GetProperties(const dbus::ObjectPath& device_path, const DictionaryValueCallback& callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillDeviceClientStubImpl::PassStubDeviceProperties, @@ -266,18 +268,22 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { std::string error_name("org.chromium.flimflam.Error.Failure"); std::string error_message("Failed"); - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(error_callback, - error_name, - error_message)); + if (!error_callback.is_null()) { + MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(error_callback, + error_name, + error_message)); + } return; } device_properties->Set(name, value.DeepCopy()); - MessageLoop::current()->PostTask(FROM_HERE, callback); MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillDeviceClientStubImpl::NotifyObserversPropertyChanged, weak_ptr_factory_.GetWeakPtr(), device_path, name)); + if (callback.is_null()) + return; + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void ClearProperty(const dbus::ObjectPath& device_path, @@ -296,6 +302,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, const dbus::ObjectPath& device_path, const std::string& method, const ObjectPathDBusMethodCallback& callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, @@ -307,6 +315,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, bool require, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -314,6 +324,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, const std::string& pin, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -322,6 +334,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, const std::string& pin, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -330,6 +344,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, const std::string& new_pin, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -337,6 +353,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, const std::string& network_id, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -344,6 +362,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, const std::string& carrier, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -406,6 +426,8 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, // Posts a task to run a void callback with status code |status|. void PostVoidCallback(const VoidDBusMethodCallback& callback, DBusMethodCallStatus status) { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, status)); } diff --git a/chromeos/dbus/shill_ipconfig_client.cc b/chromeos/dbus/shill_ipconfig_client.cc index 79e81f5..fa99a2b 100644 --- a/chromeos/dbus/shill_ipconfig_client.cc +++ b/chromeos/dbus/shill_ipconfig_client.cc @@ -190,6 +190,8 @@ class ShillIPConfigClientStubImpl : public ShillIPConfigClient { virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, const DictionaryValueCallback& callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillIPConfigClientStubImpl::PassProperties, weak_ptr_factory_.GetWeakPtr(), @@ -205,6 +207,8 @@ class ShillIPConfigClientStubImpl : public ShillIPConfigClient { const std::string& name, const base::Value& value, const VoidDBusMethodCallback& callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); } @@ -212,12 +216,16 @@ class ShillIPConfigClientStubImpl : public ShillIPConfigClient { virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path, const std::string& name, const VoidDBusMethodCallback& callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); } virtual void Remove(const dbus::ObjectPath& ipconfig_path, const VoidDBusMethodCallback& callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); } diff --git a/chromeos/dbus/shill_manager_client.cc b/chromeos/dbus/shill_manager_client.cc index da61c33..6b946a1 100644 --- a/chromeos/dbus/shill_manager_client.cc +++ b/chromeos/dbus/shill_manager_client.cc @@ -175,8 +175,8 @@ class ShillManagerClientImpl : public ShillManagerClient { // Used to compare values for finding entries to erase in a ListValue. // (ListValue only implements a const_iterator version of Find). struct ValueEquals { - ValueEquals(const Value* first) : first_(first) {} - bool operator ()(const Value* second) const { + explicit ValueEquals(const Value* first) : first_(first) {} + bool operator()(const Value* second) const { return first_->Equals(second); } const Value* first_; @@ -208,6 +208,8 @@ class ShillManagerClientStubImpl : public ShillManagerClient, } virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind( &ShillManagerClientStubImpl::PassStubProperties, @@ -224,16 +226,20 @@ class ShillManagerClientStubImpl : public ShillManagerClient, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { stub_properties_.Set(name, value.DeepCopy()); + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void RequestScan(const std::string& type, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { - MessageLoop::current()->PostTask(FROM_HERE, callback); const int kScanDelayMilliseconds = 3000; CallNotifyObserversPropertyChanged( flimflam::kServicesProperty, kScanDelayMilliseconds); + if (callback.is_null()) + return; + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void EnableTechnology( @@ -243,15 +249,20 @@ class ShillManagerClientStubImpl : public ShillManagerClient, base::ListValue* enabled_list = NULL; if (!stub_properties_.GetListWithoutPathExpansion( flimflam::kEnabledTechnologiesProperty, &enabled_list)) { - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(error_callback, "StubError", "Property not found")); + if (!error_callback.is_null()) { + MessageLoop::current()->PostTask(FROM_HERE, callback); + MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(error_callback, "StubError", "Property not found")); + } return; } - MessageLoop::current()->PostTask(FROM_HERE, callback); enabled_list->AppendIfNotPresent(new base::StringValue(type)); CallNotifyObserversPropertyChanged( flimflam::kEnabledTechnologiesProperty, 0); + if (callback.is_null()) + return; + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void DisableTechnology( @@ -261,22 +272,28 @@ class ShillManagerClientStubImpl : public ShillManagerClient, base::ListValue* enabled_list = NULL; if (!stub_properties_.GetListWithoutPathExpansion( flimflam::kEnabledTechnologiesProperty, &enabled_list)) { - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(error_callback, "StubError", "Property not found")); + if (!error_callback.is_null()) { + MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(error_callback, "StubError", "Property not found")); + } return; } - MessageLoop::current()->PostTask(FROM_HERE, callback); base::StringValue type_value(type); enabled_list->Remove(type_value, NULL); CallNotifyObserversPropertyChanged( flimflam::kEnabledTechnologiesProperty, 0); + if (callback.is_null()) + return; + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void ConfigureService( const base::DictionaryValue& properties, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -284,6 +301,8 @@ class ShillManagerClientStubImpl : public ShillManagerClient, const base::DictionaryValue& properties, const ObjectPathCallback& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, dbus::ObjectPath())); } diff --git a/chromeos/dbus/shill_profile_client.cc b/chromeos/dbus/shill_profile_client.cc index 6b2544c..8fbd95a 100644 --- a/chromeos/dbus/shill_profile_client.cc +++ b/chromeos/dbus/shill_profile_client.cc @@ -140,6 +140,8 @@ class ShillProfileClientStubImpl : public ShillProfileClient { const dbus::ObjectPath& profile_path, const DictionaryValueCallbackWithoutStatus& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillProfileClientStubImpl::PassEmptyDictionaryValue, @@ -151,6 +153,8 @@ class ShillProfileClientStubImpl : public ShillProfileClient { const std::string& entry_path, const DictionaryValueCallbackWithoutStatus& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillProfileClientStubImpl::PassEmptyDictionaryValue, @@ -162,6 +166,8 @@ class ShillProfileClientStubImpl : public ShillProfileClient { const std::string& entry_path, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } diff --git a/chromeos/dbus/shill_service_client.cc b/chromeos/dbus/shill_service_client.cc index f0e601d..16d7767 100644 --- a/chromeos/dbus/shill_service_client.cc +++ b/chromeos/dbus/shill_service_client.cc @@ -226,6 +226,8 @@ class ShillServiceClientStubImpl : public ShillServiceClient, virtual void GetProperties(const dbus::ObjectPath& service_path, const DictionaryValueCallback& callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillServiceClientStubImpl::PassStubDictionaryValue, @@ -246,11 +248,13 @@ class ShillServiceClientStubImpl : public ShillServiceClient, return; } dict->SetWithoutPathExpansion(name, value.DeepCopy()); - MessageLoop::current()->PostTask(FROM_HERE, callback); MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillServiceClientStubImpl::NotifyObserversPropertyChanged, weak_ptr_factory_.GetWeakPtr(), service_path, name)); + if (callback.is_null()) + return; + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void ClearProperty(const dbus::ObjectPath& service_path, @@ -264,11 +268,13 @@ class ShillServiceClientStubImpl : public ShillServiceClient, return; } dict->Remove(name, NULL); - MessageLoop::current()->PostTask(FROM_HERE, callback); MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillServiceClientStubImpl::NotifyObserversPropertyChanged, weak_ptr_factory_.GetWeakPtr(), service_path, name)); + if (callback.is_null()) + return; + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void ClearProperties(const dbus::ObjectPath& service_path, @@ -287,10 +293,6 @@ class ShillServiceClientStubImpl : public ShillServiceClient, dict->Remove(*iter, NULL); results->AppendBoolean(true); } - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&ShillServiceClientStubImpl::PassStubListValue, - callback, base::Owned(results.release()))); for (std::vector<std::string>::const_iterator iter = names.begin(); iter != names.end(); ++iter) { MessageLoop::current()->PostTask( @@ -299,23 +301,58 @@ class ShillServiceClientStubImpl : public ShillServiceClient, &ShillServiceClientStubImpl::NotifyObserversPropertyChanged, weak_ptr_factory_.GetWeakPtr(), service_path, *iter)); } + if (callback.is_null()) + return; + MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&ShillServiceClientStubImpl::PassStubListValue, + callback, base::Owned(results.release()))); } virtual void Connect(const dbus::ObjectPath& service_path, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { - MessageLoop::current()->PostTask(FROM_HERE, callback); + // Set Associating + base::StringValue associating_value(flimflam::kStateAssociation); + SetServiceProperty(service_path.value(), + flimflam::kStateProperty, + associating_value); + // Set Online after a delay + const int kConnectDelaySeconds = 5; + base::StringValue online_value(flimflam::kStateOnline); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&ShillServiceClientStubImpl::SetProperty, + weak_ptr_factory_.GetWeakPtr(), + service_path, + flimflam::kStateProperty, + online_value, + callback, error_callback), + base::TimeDelta::FromSeconds(kConnectDelaySeconds)); } virtual void Disconnect(const dbus::ObjectPath& service_path, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { - MessageLoop::current()->PostTask(FROM_HERE, callback); + // Set Idle after a delay + const int kConnectDelaySeconds = 2; + base::StringValue idle_value(flimflam::kStateIdle); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&ShillServiceClientStubImpl::SetProperty, + weak_ptr_factory_.GetWeakPtr(), + service_path, + flimflam::kStateProperty, + idle_value, + callback, error_callback), + base::TimeDelta::FromSeconds(kConnectDelaySeconds)); } virtual void Remove(const dbus::ObjectPath& service_path, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -324,6 +361,8 @@ class ShillServiceClientStubImpl : public ShillServiceClient, const std::string& carrier, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; MessageLoop::current()->PostTask(FROM_HERE, callback); } diff --git a/chromeos/dbus/sms_client.cc b/chromeos/dbus/sms_client.cc index 9aa79f2..2b578d0 100644 --- a/chromeos/dbus/sms_client.cc +++ b/chromeos/dbus/sms_client.cc @@ -99,6 +99,8 @@ class SMSClientStubImpl : public SMSClient { sms->SetString("Timestamp", "Fri Jun 8 13:26:04 EDT 2012"); // Run callback asynchronously. + if (callback.is_null()) + return; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&SMSClientStubImpl::OnGetAll, diff --git a/chromeos/network/network_configuration_handler.cc b/chromeos/network/network_configuration_handler.cc index 56ee934..2f3ebb28 100644 --- a/chromeos/network/network_configuration_handler.cc +++ b/chromeos/network/network_configuration_handler.cc @@ -20,6 +20,8 @@ namespace chromeos { +static NetworkConfigurationHandler* g_network_configuration_handler = NULL; + namespace { const char kLogModule[] = "NetworkConfigurationHandler"; @@ -105,6 +107,26 @@ NetworkConfigurationHandler::NetworkConfigurationHandler() { NetworkConfigurationHandler::~NetworkConfigurationHandler() { } +// static +void NetworkConfigurationHandler::Initialize() { + CHECK(!g_network_configuration_handler); + g_network_configuration_handler = new NetworkConfigurationHandler(); +} + +// static +void NetworkConfigurationHandler::Shutdown() { + CHECK(g_network_configuration_handler); + delete g_network_configuration_handler; + g_network_configuration_handler = NULL; +} + +// static +NetworkConfigurationHandler* NetworkConfigurationHandler::Get() { + CHECK(g_network_configuration_handler) + << "NetworkConfigurationHandler::Get() called before Initialize()"; + return g_network_configuration_handler; +} + void NetworkConfigurationHandler::GetProperties( const std::string& service_path, const network_handler::DictionaryResultCallback& callback, diff --git a/chromeos/network/network_configuration_handler.h b/chromeos/network/network_configuration_handler.h index a92756c..c7f6a82 100644 --- a/chromeos/network/network_configuration_handler.h +++ b/chromeos/network/network_configuration_handler.h @@ -40,9 +40,17 @@ namespace chromeos { class CHROMEOS_EXPORT NetworkConfigurationHandler { public: - NetworkConfigurationHandler(); ~NetworkConfigurationHandler(); + // Sets the global instance. Must be called before any calls to Get(). + static void Initialize(); + + // Destroys the global instance. + static void Shutdown(); + + // Gets the global instance. Initialize() must be called first. + static NetworkConfigurationHandler* Get(); + // Gets the properties of the network with id |service_path|. See note on // |callback| and |error_callback|, in class description above. void GetProperties( @@ -103,6 +111,9 @@ class CHROMEOS_EXPORT NetworkConfigurationHandler { const network_handler::ErrorCallback& error_callback) const; private: + friend class NetworkConfigurationHandlerTest; + NetworkConfigurationHandler(); + DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationHandler); }; |