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

Side by Side Diff: chrome/browser/chromeos/accessibility_util.cc

Issue 7781004: Move Speak() in accessibility_utils, speak enable and disable strings when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused headers Created 9 years, 3 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_util.h" 5 #include "chrome/browser/chromeos/accessibility_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h"
11 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h"
10 #include "chrome/browser/extensions/extension_accessibility_api.h" 12 #include "chrome/browser/extensions/extension_accessibility_api.h"
11 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/file_reader.h" 14 #include "chrome/browser/extensions/file_reader.h"
13 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/common/extensions/extension_messages.h" 17 #include "chrome/common/extensions/extension_messages.h"
16 #include "chrome/common/extensions/extension_resource.h" 18 #include "chrome/common/extensions/extension_resource.h"
17 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
18 #include "content/browser/renderer_host/render_view_host.h" 20 #include "content/browser/renderer_host/render_view_host.h"
19 #include "content/browser/tab_contents/tab_contents.h" 21 #include "content/browser/tab_contents/tab_contents.h"
20 #include "content/browser/webui/web_ui.h" 22 #include "content/browser/webui/web_ui.h"
21 #include "grit/browser_resources.h" 23 #include "grit/browser_resources.h"
24 #include "grit/generated_resources.h"
25 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
23 27
24 namespace chromeos { 28 namespace chromeos {
25 namespace accessibility { 29 namespace accessibility {
26 30
27 // Helper class that directly loads an extension's content scripts into 31 // Helper class that directly loads an extension's content scripts into
28 // all of the frames corresponding to a given RenderViewHost. 32 // all of the frames corresponding to a given RenderViewHost.
29 class ContentScriptLoader { 33 class ContentScriptLoader {
30 public: 34 public:
31 // Initialize the ContentScriptLoader with the ID of the extension 35 // Initialize the ContentScriptLoader with the ID of the extension
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 g_browser_process->local_state()->SetBoolean( 94 g_browser_process->local_state()->SetBoolean(
91 prefs::kAccessibilityEnabled, enabled); 95 prefs::kAccessibilityEnabled, enabled);
92 // Explicitly call SavePersistentPrefs instead of ScheduleSavePersistentPrefs 96 // Explicitly call SavePersistentPrefs instead of ScheduleSavePersistentPrefs
93 // so that this change gets written immediately, in case the user shuts 97 // so that this change gets written immediately, in case the user shuts
94 // down right now. TODO(dmazzoni) switch this back to 98 // down right now. TODO(dmazzoni) switch this back to
95 // ScheduleSavePersistentPrefs once http://crosbug.com/19491 is fixed. 99 // ScheduleSavePersistentPrefs once http://crosbug.com/19491 is fixed.
96 g_browser_process->local_state()->SavePersistentPrefs(); 100 g_browser_process->local_state()->SavePersistentPrefs();
97 ExtensionAccessibilityEventRouter::GetInstance()-> 101 ExtensionAccessibilityEventRouter::GetInstance()->
98 SetAccessibilityEnabled(enabled); 102 SetAccessibilityEnabled(enabled);
99 103
104 Speak(enabled ?
105 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() :
106 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str(),
107 false, true);
108
100 // Load/Unload ChromeVox 109 // Load/Unload ChromeVox
101 Profile* profile = ProfileManager::GetDefaultProfile(); 110 Profile* profile = ProfileManager::GetDefaultProfile();
102 ExtensionService* extension_service = 111 ExtensionService* extension_service =
103 profile->GetExtensionService(); 112 profile->GetExtensionService();
104 std::string manifest = ResourceBundle::GetSharedInstance(). 113 std::string manifest = ResourceBundle::GetSharedInstance().
105 GetRawDataResource(IDR_CHROMEVOX_MANIFEST).as_string(); 114 GetRawDataResource(IDR_CHROMEVOX_MANIFEST).as_string();
106 FilePath path = FilePath(extension_misc::kAccessExtensionPath) 115 FilePath path = FilePath(extension_misc::kAccessExtensionPath)
107 .AppendASCII(extension_misc::kChromeVoxDirectoryName); 116 .AppendASCII(extension_misc::kChromeVoxDirectoryName);
108 ExtensionService::ComponentExtensionInfo info(manifest, path); 117 ExtensionService::ComponentExtensionInfo info(manifest, path);
109 if (enabled) { // Load ChromeVox 118 if (enabled) { // Load ChromeVox
(...skipping 28 matching lines...) Expand all
138 } 147 }
139 148
140 void ToggleAccessibility(WebUI* login_web_ui) { 149 void ToggleAccessibility(WebUI* login_web_ui) {
141 bool accessibility_enabled = g_browser_process && 150 bool accessibility_enabled = g_browser_process &&
142 g_browser_process->local_state()->GetBoolean( 151 g_browser_process->local_state()->GetBoolean(
143 prefs::kAccessibilityEnabled); 152 prefs::kAccessibilityEnabled);
144 accessibility_enabled = !accessibility_enabled; 153 accessibility_enabled = !accessibility_enabled;
145 EnableAccessibility(accessibility_enabled, login_web_ui); 154 EnableAccessibility(accessibility_enabled, login_web_ui);
146 }; 155 };
147 156
157 void Speak(const char* speak_str, bool queue, bool interruptible) {
158 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
159 if (queue || !interruptible) {
160 std::string props = "";
161 props.append("enqueue=");
162 props.append(queue ? "1;" : "0;");
163 props.append("interruptible=");
164 props.append(interruptible ? "1;" : "0;");
165 chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()->
166 SetSpeakProperties(props.c_str());
167 }
168 chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()->
169 Speak(speak_str);
170 }
171 }
172
173
148 } // namespace accessibility 174 } // namespace accessibility
149 } // namespace chromeos 175 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/accessibility_util.h ('k') | chrome/browser/chromeos/login/wizard_accessibility_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698