Index: chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc |
diff --git a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc |
index 2e48bc79ac219b2c76d3b087d3d00b747942ffec..2a31aa0fcb557428a0eb9f6a50108a4a50521e58 100644 |
--- a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc |
+++ b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc |
@@ -32,16 +32,14 @@ const int kUpdateDevicePasskeyIndex = 2; |
namespace chromeos { |
namespace options2 { |
-BluetoothOptionsHandler::BluetoothOptionsHandler() { |
+BluetoothOptionsHandler::BluetoothOptionsHandler() |
+ : bluetooth_enabled_(CommandLine::ForCurrentProcess() |
+ ->HasSwitch(switches::kEnableBluetooth)) { |
} |
BluetoothOptionsHandler::~BluetoothOptionsHandler() { |
- if (!CommandLine::ForCurrentProcess() |
- ->HasSwitch(switches::kEnableBluetooth)) { |
- return; |
- } |
- |
- adapter_->RemoveObserver(this); |
+ if (bluetooth_enabled_ && adapter_.get()) |
+ adapter_->RemoveObserver(this); |
} |
void BluetoothOptionsHandler::GetLocalizedValues( |
@@ -123,20 +121,20 @@ void BluetoothOptionsHandler::GetLocalizedValues( |
IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED)); |
} |
-void BluetoothOptionsHandler::Initialize() { |
+void BluetoothOptionsHandler::InitializeHandler() { |
// Bluetooth support is a work in progress. Supress the feature unless |
// explicitly enabled via a command line flag. |
- if (!CommandLine::ForCurrentProcess() |
- ->HasSwitch(switches::kEnableBluetooth)) { |
- return; |
+ if (bluetooth_enabled_) { |
+ adapter_.reset(BluetoothAdapter::CreateDefaultAdapter()); |
+ adapter_->AddObserver(this); |
} |
+} |
- adapter_.reset(BluetoothAdapter::CreateDefaultAdapter()); |
- adapter_->AddObserver(this); |
- |
- // Show or hide the bluetooth settings and update the checkbox based |
- // on the current present/powered state. |
- AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); |
+void BluetoothOptionsHandler::InitializePage() { |
+ // Show or hide the bluetooth settings and update the checkbox based on the |
+ // current present/powered state. |
+ if (bluetooth_enabled_) |
+ AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); |
} |
void BluetoothOptionsHandler::AdapterPresentChanged(BluetoothAdapter* adapter, |