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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc

Issue 2166503003: Fix bluetooth adapter access in SystemTrayDelegateChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not check on InputMethodManager::Get. Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/ash/system_tray_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 if (CrasAudioHandler::IsInitialized()) 256 if (CrasAudioHandler::IsInitialized())
257 CrasAudioHandler::Get()->AddAudioObserver(this); 257 CrasAudioHandler::Get()->AddAudioObserver(this);
258 258
259 BrowserList::AddObserver(this); 259 BrowserList::AddObserver(this);
260 } 260 }
261 261
262 void SystemTrayDelegateChromeOS::InitializeOnAdapterReady( 262 void SystemTrayDelegateChromeOS::InitializeOnAdapterReady(
263 scoped_refptr<device::BluetoothAdapter> adapter) { 263 scoped_refptr<device::BluetoothAdapter> adapter) {
264 bluetooth_adapter_ = adapter; 264 bluetooth_adapter_ = adapter;
265 CHECK(bluetooth_adapter_.get()); 265 CHECK(bluetooth_adapter_);
266 bluetooth_adapter_->AddObserver(this); 266 bluetooth_adapter_->AddObserver(this);
267 267
268 local_state_registrar_.reset(new PrefChangeRegistrar); 268 local_state_registrar_.reset(new PrefChangeRegistrar);
269 local_state_registrar_->Init(g_browser_process->local_state()); 269 local_state_registrar_->Init(g_browser_process->local_state());
270 270
271 UpdateSessionStartTime(); 271 UpdateSessionStartTime();
272 UpdateSessionLengthLimit(); 272 UpdateSessionLengthLimit();
273 273
274 local_state_registrar_->Add( 274 local_state_registrar_->Add(
275 prefs::kSessionStartTime, 275 prefs::kSessionStartTime,
(...skipping 21 matching lines...) Expand all
297 // Unregister content notifications before destroying any components. 297 // Unregister content notifications before destroying any components.
298 registrar_.reset(); 298 registrar_.reset();
299 299
300 // Unregister a11y status subscription. 300 // Unregister a11y status subscription.
301 accessibility_subscription_.reset(); 301 accessibility_subscription_.reset();
302 302
303 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); 303 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this);
304 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); 304 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
305 input_method::InputMethodManager::Get()->RemoveObserver(this); 305 input_method::InputMethodManager::Get()->RemoveObserver(this);
306 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); 306 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
307 bluetooth_adapter_->RemoveObserver(this); 307 if (bluetooth_adapter_)
308 bluetooth_adapter_->RemoveObserver(this);
308 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( 309 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(
309 this); 310 this);
310 311
311 if (CrasAudioHandler::IsInitialized()) 312 if (CrasAudioHandler::IsInitialized())
312 CrasAudioHandler::Get()->RemoveAudioObserver(this); 313 CrasAudioHandler::Get()->RemoveAudioObserver(this);
313 314
314 BrowserList::RemoveObserver(this); 315 BrowserList::RemoveObserver(this);
315 StopObservingAppWindowRegistry(); 316 StopObservingAppWindowRegistry();
316 StopObservingCustodianInfoChanges(); 317 StopObservingCustodianInfoChanges();
317 318
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 ash::WmShell::Get()->RecordUserMetricsAction( 673 ash::WmShell::Get()->RecordUserMetricsAction(
673 ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE); 674 ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE);
674 BluetoothPairingDialog* dialog = 675 BluetoothPairingDialog* dialog =
675 new BluetoothPairingDialog(GetNativeWindow(), device); 676 new BluetoothPairingDialog(GetNativeWindow(), device);
676 // The dialog deletes itself on close. 677 // The dialog deletes itself on close.
677 dialog->Show(); 678 dialog->Show();
678 } 679 }
679 } 680 }
680 681
681 bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() { 682 bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() {
682 return bluetooth_adapter_->IsDiscovering(); 683 return bluetooth_adapter_ && bluetooth_adapter_->IsDiscovering();
683 } 684 }
684 685
685 void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) { 686 void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) {
686 input_method::InputMethodManager* manager = 687 input_method::InputMethodManager* manager =
687 input_method::InputMethodManager::Get(); 688 input_method::InputMethodManager::Get();
688 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); 689 input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
689 input_method::InputMethodDescriptor ime = 690 input_method::InputMethodDescriptor ime =
690 manager->GetActiveIMEState()->GetCurrentInputMethod(); 691 manager->GetActiveIMEState()->GetCurrentInputMethod();
691 ExtractIMEInfo(ime, *util, info); 692 ExtractIMEInfo(ime, *util, info);
692 info->selected = true; 693 info->selected = true;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 void SystemTrayDelegateChromeOS::ShowOtherNetworkDialog( 753 void SystemTrayDelegateChromeOS::ShowOtherNetworkDialog(
753 const std::string& type) { 754 const std::string& type) {
754 if (type == shill::kTypeCellular) { 755 if (type == shill::kTypeCellular) {
755 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 756 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
756 return; 757 return;
757 } 758 }
758 NetworkConfigView::ShowForType(type, GetNativeWindow()); 759 NetworkConfigView::ShowForType(type, GetNativeWindow());
759 } 760 }
760 761
761 bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() { 762 bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() {
762 return bluetooth_adapter_->IsPresent(); 763 return bluetooth_adapter_ && bluetooth_adapter_->IsPresent();
763 } 764 }
764 765
765 bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() { 766 bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() {
766 return bluetooth_adapter_->IsPowered(); 767 return bluetooth_adapter_ && bluetooth_adapter_->IsPowered();
767 } 768 }
768 769
769 bool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() { 770 bool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() {
770 return (bluetooth_discovery_session_.get() && 771 return bluetooth_discovery_session_ &&
771 bluetooth_discovery_session_->IsActive()); 772 bluetooth_discovery_session_->IsActive();
772 } 773 }
773 774
774 void SystemTrayDelegateChromeOS::ChangeProxySettings() { 775 void SystemTrayDelegateChromeOS::ChangeProxySettings() {
775 CHECK(GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN); 776 CHECK(GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN);
776 LoginDisplayHost::default_host()->OpenProxySettings(); 777 LoginDisplayHost::default_host()->OpenProxySettings();
777 } 778 }
778 779
779 ash::CastConfigDelegate* SystemTrayDelegateChromeOS::GetCastConfigDelegate() { 780 ash::CastConfigDelegate* SystemTrayDelegateChromeOS::GetCastConfigDelegate() {
780 if (!cast_config_delegate_) 781 if (!cast_config_delegate_)
781 cast_config_delegate_ = CreateCastConfigDelegate(); 782 cast_config_delegate_ = CreateCastConfigDelegate();
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 1334 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
1334 << "ENABLE_SUPERVISED_USERS undefined."; 1335 << "ENABLE_SUPERVISED_USERS undefined.";
1335 return base::string16(); 1336 return base::string16();
1336 } 1337 }
1337 1338
1338 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1339 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1339 return new SystemTrayDelegateChromeOS(); 1340 return new SystemTrayDelegateChromeOS();
1340 } 1341 }
1341 1342
1342 } // namespace chromeos 1343 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698