| OLD | NEW |
| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 BrowserAccessibilityState::GetInstance()->OnAccessibilityEnabledManually(); | 101 BrowserAccessibilityState::GetInstance()->OnAccessibilityEnabledManually(); |
| 102 | 102 |
| 103 Speak(enabled ? | 103 Speak(enabled ? |
| 104 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() : | 104 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() : |
| 105 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str()); | 105 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str()); |
| 106 | 106 |
| 107 // Load/Unload ChromeVox | 107 // Load/Unload ChromeVox |
| 108 Profile* profile = ProfileManager::GetDefaultProfile(); | 108 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 109 ExtensionService* extension_service = | 109 ExtensionService* extension_service = |
| 110 profile->GetExtensionService(); | 110 profile->GetExtensionService(); |
| 111 std::string manifest = ResourceBundle::GetSharedInstance(). | |
| 112 GetRawDataResource(IDR_CHROMEVOX_MANIFEST).as_string(); | |
| 113 FilePath path = FilePath(extension_misc::kAccessExtensionPath) | 111 FilePath path = FilePath(extension_misc::kAccessExtensionPath) |
| 114 .AppendASCII(extension_misc::kChromeVoxDirectoryName); | 112 .AppendASCII(extension_misc::kChromeVoxDirectoryName); |
| 115 if (enabled) { // Load ChromeVox | 113 if (enabled) { // Load ChromeVox |
| 116 const Extension* extension = | 114 const Extension* extension = |
| 117 extension_service->component_loader()->Add(manifest, path); | 115 extension_service->component_loader()->Add(IDR_CHROMEVOX_MANIFEST, |
| 116 path); |
| 118 | 117 |
| 119 if (login_web_ui) { | 118 if (login_web_ui) { |
| 120 RenderViewHost* render_view_host = | 119 RenderViewHost* render_view_host = |
| 121 login_web_ui->tab_contents()->render_view_host(); | 120 login_web_ui->tab_contents()->render_view_host(); |
| 122 ContentScriptLoader* loader = new ContentScriptLoader( | 121 ContentScriptLoader* loader = new ContentScriptLoader( |
| 123 extension->id(), render_view_host); | 122 extension->id(), render_view_host); |
| 124 | 123 |
| 125 for (size_t i = 0; i < extension->content_scripts().size(); i++) { | 124 for (size_t i = 0; i < extension->content_scripts().size(); i++) { |
| 126 const UserScript& script = extension->content_scripts()[i]; | 125 const UserScript& script = extension->content_scripts()[i]; |
| 127 for (size_t j = 0; j < script.js_scripts().size(); ++j) { | 126 for (size_t j = 0; j < script.js_scripts().size(); ++j) { |
| 128 const UserScript::File &file = script.js_scripts()[j]; | 127 const UserScript::File &file = script.js_scripts()[j]; |
| 129 ExtensionResource resource = extension->GetResource( | 128 ExtensionResource resource = extension->GetResource( |
| 130 file.relative_path()); | 129 file.relative_path()); |
| 131 loader->AppendScript(resource); | 130 loader->AppendScript(resource); |
| 132 } | 131 } |
| 133 } | 132 } |
| 134 loader->Run(); // It cleans itself up when done. | 133 loader->Run(); // It cleans itself up when done. |
| 135 } | 134 } |
| 136 | 135 |
| 137 LOG(INFO) << "ChromeVox was Loaded."; | 136 LOG(INFO) << "ChromeVox was Loaded."; |
| 138 } else { // Unload ChromeVox | 137 } else { // Unload ChromeVox |
| 139 extension_service->component_loader()->Remove(manifest); | 138 extension_service->component_loader()->Remove(path); |
| 140 LOG(INFO) << "ChromeVox was Unloaded."; | 139 LOG(INFO) << "ChromeVox was Unloaded."; |
| 141 } | 140 } |
| 142 } | 141 } |
| 143 | 142 |
| 144 void ToggleAccessibility(WebUI* login_web_ui) { | 143 void ToggleAccessibility(WebUI* login_web_ui) { |
| 145 bool accessibility_enabled = g_browser_process && | 144 bool accessibility_enabled = g_browser_process && |
| 146 g_browser_process->local_state()->GetBoolean( | 145 g_browser_process->local_state()->GetBoolean( |
| 147 prefs::kAccessibilityEnabled); | 146 prefs::kAccessibilityEnabled); |
| 148 accessibility_enabled = !accessibility_enabled; | 147 accessibility_enabled = !accessibility_enabled; |
| 149 EnableAccessibility(accessibility_enabled, login_web_ui); | 148 EnableAccessibility(accessibility_enabled, login_web_ui); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 163 return false; | 162 return false; |
| 164 } | 163 } |
| 165 PrefService* prefs = g_browser_process->local_state(); | 164 PrefService* prefs = g_browser_process->local_state(); |
| 166 bool accessibility_enabled = prefs && | 165 bool accessibility_enabled = prefs && |
| 167 prefs->GetBoolean(prefs::kAccessibilityEnabled); | 166 prefs->GetBoolean(prefs::kAccessibilityEnabled); |
| 168 return accessibility_enabled; | 167 return accessibility_enabled; |
| 169 } | 168 } |
| 170 | 169 |
| 171 } // namespace accessibility | 170 } // namespace accessibility |
| 172 } // namespace chromeos | 171 } // namespace chromeos |
| OLD | NEW |