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

Unified Diff: chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc

Issue 9693032: [uber page] Split up initialization of handlers from initialization of webui pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros compile fix, still issues Created 8 years, 9 months 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 side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698