Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/accessibility/accessibility_manager.h" | 5 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "ash/autoclick/autoclick_controller.h" | 13 #include "ash/autoclick/autoclick_controller.h" |
| 14 #include "ash/autoclick/mus/public/interfaces/autoclick.mojom.h" | 14 #include "ash/autoclick/mus/public/interfaces/autoclick.mojom.h" |
| 15 #include "ash/common/ash_constants.h" | 15 #include "ash/common/ash_constants.h" |
| 16 #include "ash/common/session/session_state_delegate.h" | |
| 17 #include "ash/common/shelf/shelf_layout_manager.h" | 16 #include "ash/common/shelf/shelf_layout_manager.h" |
| 18 #include "ash/common/shelf/wm_shelf.h" | 17 #include "ash/common/shelf/wm_shelf.h" |
| 19 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 20 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
| 21 #include "ash/high_contrast/high_contrast_controller.h" | 20 #include "ash/high_contrast/high_contrast_controller.h" |
| 22 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
| 23 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 24 #include "ash/sticky_keys/sticky_keys_controller.h" | 23 #include "ash/sticky_keys/sticky_keys_controller.h" |
| 25 #include "base/callback.h" | 24 #include "base/callback.h" |
| 26 #include "base/callback_helpers.h" | 25 #include "base/callback_helpers.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 51 #include "chrome/browser/profiles/profile.h" | 50 #include "chrome/browser/profiles/profile.h" |
| 52 #include "chrome/browser/profiles/profile_manager.h" | 51 #include "chrome/browser/profiles/profile_manager.h" |
| 53 #include "chrome/browser/ui/ash/ash_util.h" | 52 #include "chrome/browser/ui/ash/ash_util.h" |
| 54 #include "chrome/common/chrome_paths.h" | 53 #include "chrome/common/chrome_paths.h" |
| 55 #include "chrome/common/extensions/api/accessibility_private.h" | 54 #include "chrome/common/extensions/api/accessibility_private.h" |
| 56 #include "chrome/common/extensions/extension_constants.h" | 55 #include "chrome/common/extensions/extension_constants.h" |
| 57 #include "chrome/common/pref_names.h" | 56 #include "chrome/common/pref_names.h" |
| 58 #include "chrome/grit/browser_resources.h" | 57 #include "chrome/grit/browser_resources.h" |
| 59 #include "chromeos/audio/audio_a11y_controller.h" | 58 #include "chromeos/audio/audio_a11y_controller.h" |
| 60 #include "chromeos/audio/chromeos_sounds.h" | 59 #include "chromeos/audio/chromeos_sounds.h" |
| 61 #include "chromeos/login/login_state.h" | |
| 62 #include "components/prefs/pref_member.h" | 60 #include "components/prefs/pref_member.h" |
| 63 #include "components/prefs/pref_service.h" | 61 #include "components/prefs/pref_service.h" |
| 64 #include "components/user_manager/user_manager.h" | |
| 65 #include "content/public/browser/browser_accessibility_state.h" | 62 #include "content/public/browser/browser_accessibility_state.h" |
| 66 #include "content/public/browser/browser_thread.h" | 63 #include "content/public/browser/browser_thread.h" |
| 67 #include "content/public/browser/notification_details.h" | 64 #include "content/public/browser/notification_details.h" |
| 68 #include "content/public/browser/notification_service.h" | 65 #include "content/public/browser/notification_service.h" |
| 69 #include "content/public/browser/notification_source.h" | 66 #include "content/public/browser/notification_source.h" |
| 70 #include "content/public/browser/web_ui.h" | 67 #include "content/public/browser/web_ui.h" |
| 71 #include "content/public/common/content_switches.h" | 68 #include "content/public/common/content_switches.h" |
| 72 #include "content/public/common/service_manager_connection.h" | 69 #include "content/public/common/service_manager_connection.h" |
| 73 #include "extensions/browser/event_router.h" | 70 #include "extensions/browser/event_router.h" |
| 74 #include "extensions/browser/extension_registry.h" | 71 #include "extensions/browser/extension_registry.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 CHECK(this == g_accessibility_manager); | 323 CHECK(this == g_accessibility_manager); |
| 327 AccessibilityStatusEventDetails details(ACCESSIBILITY_MANAGER_SHUTDOWN, false, | 324 AccessibilityStatusEventDetails details(ACCESSIBILITY_MANAGER_SHUTDOWN, false, |
| 328 ash::A11Y_NOTIFICATION_NONE); | 325 ash::A11Y_NOTIFICATION_NONE); |
| 329 NotifyAccessibilityStatusChanged(details); | 326 NotifyAccessibilityStatusChanged(details); |
| 330 input_method::InputMethodManager::Get()->RemoveObserver(this); | 327 input_method::InputMethodManager::Get()->RemoveObserver(this); |
| 331 | 328 |
| 332 if (chromevox_panel_) { | 329 if (chromevox_panel_) { |
| 333 chromevox_panel_->Close(); | 330 chromevox_panel_->Close(); |
| 334 chromevox_panel_ = nullptr; | 331 chromevox_panel_ = nullptr; |
| 335 } | 332 } |
| 333 | |
| 334 session_state_observer_.reset(); | |
|
James Cook
2017/02/27 21:20:28
nit: document why this has to be done here
xiyuan
2017/02/27 22:16:21
I removed OnAppTerminating and moved its code here
| |
| 336 } | 335 } |
| 337 | 336 |
| 338 bool AccessibilityManager::ShouldShowAccessibilityMenu() { | 337 bool AccessibilityManager::ShouldShowAccessibilityMenu() { |
| 339 // If any of the loaded profiles has an accessibility feature turned on - or | 338 // If any of the loaded profiles has an accessibility feature turned on - or |
| 340 // enforced to always show the menu - we return true to show the menu. | 339 // enforced to always show the menu - we return true to show the menu. |
| 341 std::vector<Profile*> profiles = | 340 std::vector<Profile*> profiles = |
| 342 g_browser_process->profile_manager()->GetLoadedProfiles(); | 341 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 343 for (std::vector<Profile*>::iterator it = profiles.begin(); | 342 for (std::vector<Profile*>::iterator it = profiles.begin(); |
| 344 it != profiles.end(); | 343 it != profiles.end(); |
| 345 ++it) { | 344 ++it) { |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1145 UpdateFocusHighlightFromPref(); | 1144 UpdateFocusHighlightFromPref(); |
| 1146 UpdateSelectToSpeakFromPref(); | 1145 UpdateSelectToSpeakFromPref(); |
| 1147 UpdateSwitchAccessFromPref(); | 1146 UpdateSwitchAccessFromPref(); |
| 1148 | 1147 |
| 1149 // Update the panel height in the shelf layout manager when the profile | 1148 // Update the panel height in the shelf layout manager when the profile |
| 1150 // changes, since the shelf layout manager doesn't exist in the login profile. | 1149 // changes, since the shelf layout manager doesn't exist in the login profile. |
| 1151 if (chromevox_panel_) | 1150 if (chromevox_panel_) |
| 1152 chromevox_panel_->UpdatePanelHeight(); | 1151 chromevox_panel_->UpdatePanelHeight(); |
| 1153 } | 1152 } |
| 1154 | 1153 |
| 1155 void AccessibilityManager::ActiveUserChanged(const AccountId& account_id) { | 1154 void AccessibilityManager::ActiveUserChanged( |
| 1155 const user_manager::User* active_user) { | |
| 1156 SetProfile(ProfileManager::GetActiveUserProfile()); | 1156 SetProfile(ProfileManager::GetActiveUserProfile()); |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 void AccessibilityManager::OnAppTerminating() { | |
| 1160 session_state_observer_.reset(); | |
| 1161 } | |
| 1162 | |
| 1163 void AccessibilityManager::OnFullscreenStateChanged( | 1159 void AccessibilityManager::OnFullscreenStateChanged( |
| 1164 bool is_fullscreen, | 1160 bool is_fullscreen, |
| 1165 ash::WmWindow* root_window) { | 1161 ash::WmWindow* root_window) { |
| 1166 if (chromevox_panel_) | 1162 if (chromevox_panel_) |
| 1167 chromevox_panel_->UpdateWidgetBounds(); | 1163 chromevox_panel_->UpdateWidgetBounds(); |
| 1168 } | 1164 } |
| 1169 | 1165 |
| 1170 void AccessibilityManager::SetProfileForTest(Profile* profile) { | 1166 void AccessibilityManager::SetProfileForTest(Profile* profile) { |
| 1171 SetProfile(profile); | 1167 SetProfile(profile); |
| 1172 } | 1168 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1261 Profile* profile = ProfileManager::GetActiveUserProfile(); | 1257 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 1262 if (ProfileHelper::IsSigninProfile(profile)) | 1258 if (ProfileHelper::IsSigninProfile(profile)) |
| 1263 SetProfile(profile); | 1259 SetProfile(profile); |
| 1264 break; | 1260 break; |
| 1265 } | 1261 } |
| 1266 case chrome::NOTIFICATION_SESSION_STARTED: | 1262 case chrome::NOTIFICATION_SESSION_STARTED: |
| 1267 // Update |profile_| when entering a session. | 1263 // Update |profile_| when entering a session. |
| 1268 SetProfile(ProfileManager::GetActiveUserProfile()); | 1264 SetProfile(ProfileManager::GetActiveUserProfile()); |
| 1269 | 1265 |
| 1270 // Add a session state observer to be able to monitor session changes. | 1266 // Add a session state observer to be able to monitor session changes. |
| 1271 if (!session_state_observer_.get() && ash::Shell::HasInstance()) | 1267 if (!session_state_observer_.get()) |
| 1272 session_state_observer_.reset( | 1268 session_state_observer_.reset( |
| 1273 new ash::ScopedSessionStateObserver(this)); | 1269 new user_manager::ScopedUserSessionStateObserver(this)); |
| 1274 break; | 1270 break; |
| 1275 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 1271 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 1276 // Update |profile_| when exiting a session or shutting down. | 1272 // Update |profile_| when exiting a session or shutting down. |
| 1277 Profile* profile = content::Source<Profile>(source).ptr(); | 1273 Profile* profile = content::Source<Profile>(source).ptr(); |
| 1278 if (profile_ == profile) | 1274 if (profile_ == profile) |
| 1279 SetProfile(NULL); | 1275 SetProfile(NULL); |
| 1280 break; | 1276 break; |
| 1281 } | 1277 } |
| 1282 } | 1278 } |
| 1283 } | 1279 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1400 content::BrowserContext* context) { | 1396 content::BrowserContext* context) { |
| 1401 keyboard_listener_extension_id_ = id; | 1397 keyboard_listener_extension_id_ = id; |
| 1402 | 1398 |
| 1403 extensions::ExtensionRegistry* registry = | 1399 extensions::ExtensionRegistry* registry = |
| 1404 extensions::ExtensionRegistry::Get(context); | 1400 extensions::ExtensionRegistry::Get(context); |
| 1405 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) | 1401 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) |
| 1406 extension_registry_observer_.Add(registry); | 1402 extension_registry_observer_.Add(registry); |
| 1407 } | 1403 } |
| 1408 | 1404 |
| 1409 } // namespace chromeos | 1405 } // namespace chromeos |
| OLD | NEW |