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

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

Issue 2764643003: cros: Move TrayBluetoothHelper out of chrome into ash (Closed)
Patch Set: rebase fix Created 3 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 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 <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "ash/common/login_status.h" 16 #include "ash/common/login_status.h"
17 #include "ash/common/shell_delegate.h" 17 #include "ash/common/shell_delegate.h"
18 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h"
18 #include "ash/common/system/chromeos/power/power_status.h" 19 #include "ash/common/system/chromeos/power/power_status.h"
19 #include "ash/common/system/chromeos/session/logout_button_observer.h" 20 #include "ash/common/system/chromeos/session/logout_button_observer.h"
20 #include "ash/common/system/date/clock_observer.h" 21 #include "ash/common/system/date/clock_observer.h"
21 #include "ash/common/system/ime/ime_observer.h" 22 #include "ash/common/system/ime/ime_observer.h"
22 #include "ash/common/system/tray/system_tray_notifier.h" 23 #include "ash/common/system/tray/system_tray_notifier.h"
23 #include "ash/common/system/tray_accessibility.h" 24 #include "ash/common/system/tray_accessibility.h"
24 #include "ash/common/system/user/user_observer.h" 25 #include "ash/common/system/user/user_observer.h"
25 #include "ash/common/wm_shell.h" 26 #include "ash/common/wm_shell.h"
26 #include "ash/shell.h" 27 #include "ash/shell.h"
27 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" 28 #include "ash/system/chromeos/rotation/tray_rotation_lock.h"
(...skipping 17 matching lines...) Expand all
45 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 46 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
46 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 47 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
47 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 48 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
48 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 49 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
49 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" 50 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h"
50 #include "chrome/browser/chromeos/profiles/profile_helper.h" 51 #include "chrome/browser/chromeos/profiles/profile_helper.h"
51 #include "chrome/browser/profiles/profile_manager.h" 52 #include "chrome/browser/profiles/profile_manager.h"
52 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 53 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
53 #include "chrome/browser/ui/ash/networking_config_delegate_chromeos.h" 54 #include "chrome/browser/ui/ash/networking_config_delegate_chromeos.h"
54 #include "chrome/browser/ui/ash/system_tray_client.h" 55 #include "chrome/browser/ui/ash/system_tray_client.h"
55 #include "chrome/browser/ui/ash/tray_bluetooth_helper.h"
56 #include "chrome/browser/ui/browser.h" 56 #include "chrome/browser/ui/browser.h"
57 #include "chrome/browser/ui/browser_list.h" 57 #include "chrome/browser/ui/browser_list.h"
58 #include "chrome/browser/ui/chrome_pages.h" 58 #include "chrome/browser/ui/chrome_pages.h"
59 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 59 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
60 #include "chrome/browser/ui/singleton_tabs.h" 60 #include "chrome/browser/ui/singleton_tabs.h"
61 #include "chrome/common/chrome_switches.h" 61 #include "chrome/common/chrome_switches.h"
62 #include "chrome/common/features.h" 62 #include "chrome/common/features.h"
63 #include "chrome/common/pref_names.h" 63 #include "chrome/common/pref_names.h"
64 #include "chrome/common/url_constants.h" 64 #include "chrome/common/url_constants.h"
65 #include "chrome/grit/generated_resources.h" 65 #include "chrome/grit/generated_resources.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 UserAddingScreen::Get()->Start(); 117 UserAddingScreen::Get()->Start();
118 } 118 }
119 119
120 bool IsSessionInSecondaryLoginScreen() { 120 bool IsSessionInSecondaryLoginScreen() {
121 return session_manager::SessionManager::Get()->IsInSecondaryLoginScreen(); 121 return session_manager::SessionManager::Get()->IsInSecondaryLoginScreen();
122 } 122 }
123 123
124 } // namespace 124 } // namespace
125 125
126 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() 126 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS()
127 : bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), 127 : networking_config_delegate_(
128 networking_config_delegate_(
129 base::MakeUnique<NetworkingConfigDelegateChromeos>()) { 128 base::MakeUnique<NetworkingConfigDelegateChromeos>()) {
130 // Register notifications on construction so that events such as 129 // Register notifications on construction so that events such as
131 // PROFILE_CREATED do not get missed if they happen before Initialize(). 130 // PROFILE_CREATED do not get missed if they happen before Initialize().
132 registrar_.reset(new content::NotificationRegistrar); 131 registrar_.reset(new content::NotificationRegistrar);
133 if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) { 132 if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) {
134 registrar_->Add(this, 133 registrar_->Add(this,
135 chrome::NOTIFICATION_SESSION_STARTED, 134 chrome::NOTIFICATION_SESSION_STARTED,
136 content::NotificationService::AllSources()); 135 content::NotificationService::AllSources());
137 } 136 }
138 registrar_->Add(this, 137 registrar_->Add(this,
(...skipping 13 matching lines...) Expand all
152 user_manager::UserManager::Get()->AddSessionStateObserver(this); 151 user_manager::UserManager::Get()->AddSessionStateObserver(this);
153 } 152 }
154 153
155 void SystemTrayDelegateChromeOS::Initialize() { 154 void SystemTrayDelegateChromeOS::Initialize() {
156 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 155 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
157 156
158 input_method::InputMethodManager::Get()->AddObserver(this); 157 input_method::InputMethodManager::Get()->AddObserver(this);
159 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); 158 input_method::InputMethodManager::Get()->AddImeMenuObserver(this);
160 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); 159 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
161 160
162 bluetooth_helper_->Initialize();
163
164 BrowserList::AddObserver(this); 161 BrowserList::AddObserver(this);
165 162
166 local_state_registrar_.reset(new PrefChangeRegistrar); 163 local_state_registrar_.reset(new PrefChangeRegistrar);
167 local_state_registrar_->Init(g_browser_process->local_state()); 164 local_state_registrar_->Init(g_browser_process->local_state());
168 165
169 UpdateSessionStartTime(); 166 UpdateSessionStartTime();
170 UpdateSessionLengthLimit(); 167 UpdateSessionLengthLimit();
171 168
172 local_state_registrar_->Add( 169 local_state_registrar_->Add(
173 prefs::kSessionStartTime, 170 prefs::kSessionStartTime,
(...skipping 21 matching lines...) Expand all
195 // Unregister content notifications before destroying any components. 192 // Unregister content notifications before destroying any components.
196 registrar_.reset(); 193 registrar_.reset();
197 194
198 // Unregister a11y status subscription. 195 // Unregister a11y status subscription.
199 accessibility_subscription_.reset(); 196 accessibility_subscription_.reset();
200 197
201 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); 198 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
202 input_method::InputMethodManager::Get()->RemoveObserver(this); 199 input_method::InputMethodManager::Get()->RemoveObserver(this);
203 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); 200 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
204 201
205 bluetooth_helper_.reset();
206
207 BrowserList::RemoveObserver(this); 202 BrowserList::RemoveObserver(this);
208 StopObservingAppWindowRegistry(); 203 StopObservingAppWindowRegistry();
209 StopObservingCustodianInfoChanges(); 204 StopObservingCustodianInfoChanges();
210 205
211 policy::BrowserPolicyConnectorChromeOS* connector = 206 policy::BrowserPolicyConnectorChromeOS* connector =
212 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 207 g_browser_process->platform_part()->browser_policy_connector_chromeos();
213 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 208 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
214 connector->GetDeviceCloudPolicyManager(); 209 connector->GetDeviceCloudPolicyManager();
215 if (policy_manager) 210 if (policy_manager)
216 policy_manager->core()->store()->RemoveObserver(this); 211 policy_manager->core()->store()->RemoveObserver(this);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 base::Bind(&OnAcceptMultiprofilesIntro); 336 base::Bind(&OnAcceptMultiprofilesIntro);
342 ShowMultiprofilesIntroDialog(on_accept); 337 ShowMultiprofilesIntroDialog(on_accept);
343 } else { 338 } else {
344 UserAddingScreen::Get()->Start(); 339 UserAddingScreen::Get()->Start();
345 } 340 }
346 } 341 }
347 } 342 }
348 343
349 void SystemTrayDelegateChromeOS::GetAvailableBluetoothDevices( 344 void SystemTrayDelegateChromeOS::GetAvailableBluetoothDevices(
350 ash::BluetoothDeviceList* list) { 345 ash::BluetoothDeviceList* list) {
351 bluetooth_helper_->GetAvailableDevices(list); 346 ash::Shell::Get()->tray_bluetooth_helper()->GetAvailableDevices(list);
352 } 347 }
353 348
354 void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() { 349 void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() {
355 bluetooth_helper_->StartDiscovering(); 350 ash::Shell::Get()->tray_bluetooth_helper()->StartDiscovering();
356 } 351 }
357 352
358 void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() { 353 void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() {
359 bluetooth_helper_->StopDiscovering(); 354 ash::Shell::Get()->tray_bluetooth_helper()->StopDiscovering();
360 } 355 }
361 356
362 void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice( 357 void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice(
363 const std::string& address) { 358 const std::string& address) {
364 bluetooth_helper_->ConnectToDevice(address); 359 ash::Shell::Get()->tray_bluetooth_helper()->ConnectToDevice(address);
365 } 360 }
366 361
367 bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() const { 362 bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() const {
368 return bluetooth_helper_->IsDiscovering(); 363 return ash::Shell::Get()->tray_bluetooth_helper()->IsDiscovering();
369 } 364 }
370 365
371 void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) { 366 void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) {
372 input_method::InputMethodManager* manager = 367 input_method::InputMethodManager* manager =
373 input_method::InputMethodManager::Get(); 368 input_method::InputMethodManager::Get();
374 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); 369 input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
375 input_method::InputMethodDescriptor ime = 370 input_method::InputMethodDescriptor ime =
376 manager->GetActiveIMEState()->GetCurrentInputMethod(); 371 manager->GetActiveIMEState()->GetCurrentInputMethod();
377 ExtractIMEInfo(ime, *util, info); 372 ExtractIMEInfo(ime, *util, info);
378 info->selected = true; 373 info->selected = true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 ->ChangeInputMethod(ime_id, false /* show_message */); 417 ->ChangeInputMethod(ime_id, false /* show_message */);
423 input_method::InputMethodSwitchRecorder::Get()->RecordSwitch( 418 input_method::InputMethodSwitchRecorder::Get()->RecordSwitch(
424 true /* by_tray_menu */); 419 true /* by_tray_menu */);
425 } 420 }
426 421
427 void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { 422 void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) {
428 input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key); 423 input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key);
429 } 424 }
430 425
431 void SystemTrayDelegateChromeOS::ToggleBluetooth() { 426 void SystemTrayDelegateChromeOS::ToggleBluetooth() {
432 bluetooth_helper_->ToggleEnabled(); 427 ash::Shell::Get()->tray_bluetooth_helper()->ToggleEnabled();
433 } 428 }
434 429
435 bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() { 430 bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() {
436 return bluetooth_helper_->GetAvailable(); 431 return ash::Shell::Get()->tray_bluetooth_helper()->GetAvailable();
437 } 432 }
438 433
439 bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() { 434 bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() {
440 return bluetooth_helper_->GetEnabled(); 435 return ash::Shell::Get()->tray_bluetooth_helper()->GetEnabled();
441 } 436 }
442 437
443 bool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() { 438 bool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() {
444 return bluetooth_helper_->HasDiscoverySession(); 439 return ash::Shell::Get()->tray_bluetooth_helper()->HasDiscoverySession();
445 } 440 }
446 441
447 ash::NetworkingConfigDelegate* 442 ash::NetworkingConfigDelegate*
448 SystemTrayDelegateChromeOS::GetNetworkingConfigDelegate() const { 443 SystemTrayDelegateChromeOS::GetNetworkingConfigDelegate() const {
449 return networking_config_delegate_.get(); 444 return networking_config_delegate_.get();
450 } 445 }
451 446
452 bool SystemTrayDelegateChromeOS::GetSessionStartTime( 447 bool SystemTrayDelegateChromeOS::GetSessionStartTime(
453 base::TimeTicks* session_start_time) { 448 base::TimeTicks* session_start_time) {
454 *session_start_time = session_start_time_; 449 *session_start_time = session_start_time_;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 830 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
836 << "ENABLE_SUPERVISED_USERS undefined."; 831 << "ENABLE_SUPERVISED_USERS undefined.";
837 return base::string16(); 832 return base::string16();
838 } 833 }
839 834
840 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 835 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
841 return new SystemTrayDelegateChromeOS(); 836 return new SystemTrayDelegateChromeOS();
842 } 837 }
843 838
844 } // namespace chromeos 839 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_chromeos.h ('k') | chrome/browser/ui/ash/tray_bluetooth_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698