diff options
author | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 01:47:41 +0000 |
---|---|---|
committer | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 01:47:41 +0000 |
commit | 94a7de34e8770c07c01ee6c2c2e07223b2c5b4a4 (patch) | |
tree | 451743081d176de62d2514c984a7279e66de7351 /chrome/browser/extensions | |
parent | af252b21eca786afcee6e24beb6c44cecce75212 (diff) | |
download | chromium_src-94a7de34e8770c07c01ee6c2c2e07223b2c5b4a4.zip chromium_src-94a7de34e8770c07c01ee6c2c2e07223b2c5b4a4.tar.gz chromium_src-94a7de34e8770c07c01ee6c2c2e07223b2c5b4a4.tar.bz2 |
Fix the BluetoothExtensionFunction refactoring.
Turns out that profile() is not available in the constructor of
extension functions, so this was actually crashing. (Not sure how I
missed this when I tried it. Must have gotten myself confused).
Change to a function that fetches the adapter on demand.
TEST=my toy demo app runs again
BUG=none
Review URL: http://codereview.chromium.org/10020050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131894 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/api/bluetooth/bluetooth_api.cc | 22 | ||||
-rw-r--r-- | chrome/browser/extensions/api/bluetooth/bluetooth_api.h | 11 |
2 files changed, 13 insertions, 20 deletions
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc index 76b5940..c882d65 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc @@ -25,36 +25,30 @@ namespace extensions { namespace api { #if defined(OS_CHROMEOS) -BluetoothExtensionFunction::BluetoothExtensionFunction() : adapter_( - profile()->GetExtensionService()->bluetooth_event_router()->adapter()) { +const chromeos::BluetoothAdapter* BluetoothExtensionFunction::adapter() const { + return profile()->GetExtensionService()->bluetooth_event_router()->adapter(); } bool BluetoothIsAvailableFunction::RunImpl() { - const BluetoothAdapter *adapter = - profile()->GetExtensionService()->bluetooth_event_router()->adapter(); - result_.reset(Value::CreateBooleanValue(adapter->IsPresent())); + result_.reset(Value::CreateBooleanValue(adapter()->IsPresent())); return true; } bool BluetoothIsPoweredFunction::RunImpl() { - const BluetoothAdapter *adapter = - profile()->GetExtensionService()->bluetooth_event_router()->adapter(); - result_.reset(Value::CreateBooleanValue(adapter->IsPowered())); + result_.reset(Value::CreateBooleanValue(adapter()->IsPowered())); return true; } bool BluetoothGetAddressFunction::RunImpl() { - const chromeos::BluetoothAdapter *adapter = - profile()->GetExtensionService()->bluetooth_event_router()->adapter(); - result_.reset(Value::CreateStringValue(adapter->address())); - return false; + result_.reset(Value::CreateStringValue(adapter()->address())); + return true; } bool BluetoothGetDevicesWithServiceFunction::RunImpl() { scoped_ptr<GetDevicesWithService::Params> params( GetDevicesWithService::Params::Create(*args_)); - BluetoothAdapter::ConstDeviceList devices = adapter_->GetDevices(); + BluetoothAdapter::ConstDeviceList devices = adapter()->GetDevices(); ListValue* matches = new ListValue(); for (BluetoothAdapter::ConstDeviceList::const_iterator i = @@ -77,8 +71,6 @@ bool BluetoothGetDevicesWithServiceFunction::RunImpl() { #else -BluetoothExtensionFunction::BluetoothExtensionFunction() {} - // ----------------------------------------------------------------------------- // NIY stubs // ----------------------------------------------------------------------------- diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.h b/chrome/browser/extensions/api/bluetooth/bluetooth_api.h index ebad5b5..4be8f03 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.h +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.h @@ -9,19 +9,20 @@ #include "chrome/browser/extensions/extension_function.h" #if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" +namespace chromeos { + +class BluetoothAdapter; + +} // namespace chromeos #endif namespace extensions { namespace api { class BluetoothExtensionFunction : public SyncExtensionFunction { - public: - BluetoothExtensionFunction(); - protected: #if defined(OS_CHROMEOS) - const chromeos::BluetoothAdapter* adapter_; + const chromeos::BluetoothAdapter* adapter() const; #endif }; |