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

Side by Side Diff: chrome/browser/chromeos/login/wizard_accessibility_helper.cc

Issue 6283009: Unregister access notifications when accessibility is turned off (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/login/wizard_accessibility_helper.h" 5 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/extensions/extension_accessibility_api.h" 10 #include "chrome/browser/extensions/extension_accessibility_api.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 } 112 }
113 } 113 }
114 } 114 }
115 115
116 void WizardAccessibilityHelper::ToggleAccessibility(views::View* view_tree) { 116 void WizardAccessibilityHelper::ToggleAccessibility(views::View* view_tree) {
117 if (!IsAccessibilityEnabled()) { 117 if (!IsAccessibilityEnabled()) {
118 EnableAccessibilityForView(view_tree); 118 EnableAccessibilityForView(view_tree);
119 } else { 119 } else {
120 SetAccessibilityEnabled(false); 120 SetAccessibilityEnabled(false);
121 if (registered_notifications_)
122 UnregisterNotifications();
121 } 123 }
122 } 124 }
123 125
124 void WizardAccessibilityHelper::SetAccessibilityEnabled(bool enabled) { 126 void WizardAccessibilityHelper::SetAccessibilityEnabled(bool enabled) {
127 bool doSpeak = (IsAccessibilityEnabled() != enabled);
125 if (g_browser_process) { 128 if (g_browser_process) {
126 PrefService* prefService = g_browser_process->local_state(); 129 PrefService* prefService = g_browser_process->local_state();
127 prefService->SetBoolean(prefs::kAccessibilityEnabled, enabled); 130 prefService->SetBoolean(prefs::kAccessibilityEnabled, enabled);
128 prefService->ScheduleSavePersistentPrefs(); 131 prefService->ScheduleSavePersistentPrefs();
129 } 132 }
130 ExtensionAccessibilityEventRouter::GetInstance()-> 133 ExtensionAccessibilityEventRouter::GetInstance()->
131 SetAccessibilityEnabled(enabled); 134 SetAccessibilityEnabled(enabled);
132 accessibility_handler_->Speak(enabled ? 135 if (doSpeak) {
133 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() : 136 accessibility_handler_->Speak(enabled ?
134 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str(), 137 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() :
135 false, true); 138 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str(),
139 false, true);
140 }
136 } 141 }
137 142
138 void WizardAccessibilityHelper::AddViewToBuffer(views::View* view_tree) { 143 void WizardAccessibilityHelper::AddViewToBuffer(views::View* view_tree) {
139 if (!view_tree->GetWidget()) 144 if (!view_tree->GetWidget())
140 return; 145 return;
141 bool view_exists = false; 146 bool view_exists = false;
142 // Check if the view is already queued for enabling accessibility. 147 // Check if the view is already queued for enabling accessibility.
143 // Prevent adding the same view in the buffer twice. 148 // Prevent adding the same view in the buffer twice.
144 for (std::map<views::View*, bool>::iterator iter = views_buffer_.begin(); 149 for (std::map<views::View*, bool>::iterator iter = views_buffer_.begin();
145 iter != views_buffer_.end(); ++iter) { 150 iter != views_buffer_.end(); ++iter) {
146 if ((*iter).first == view_tree) { 151 if ((*iter).first == view_tree) {
147 view_exists = true; 152 view_exists = true;
148 break; 153 break;
149 } 154 }
150 } 155 }
151 if (!view_exists) 156 if (!view_exists)
152 views_buffer_[view_tree] = false; 157 views_buffer_[view_tree] = false;
153 } 158 }
154 159
155 } // namespace chromeos 160 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698