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

Unified Diff: ui/accessibility/platform/atk_util_auralinux.cc

Issue 1124173005: Revert of Linux Aura accessibility is enabled only on GNOME desktops (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/accessibility/platform/atk_util_auralinux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/platform/atk_util_auralinux.cc
diff --git a/ui/accessibility/platform/atk_util_auralinux.cc b/ui/accessibility/platform/atk_util_auralinux.cc
index 0f770c279da58da514638bd7d4d43860096ed801..5d25c510e3258a7a990185f625cfc181eb1ad462 100644
--- a/ui/accessibility/platform/atk_util_auralinux.cc
+++ b/ui/accessibility/platform/atk_util_auralinux.cc
@@ -5,17 +5,10 @@
#include <atk/atk.h>
#if defined(USE_GCONF)
#include <gconf/gconf-client.h>
-#elif defined(USE_DBUS)
-#include "dbus/bus.h"
-#include "dbus/message.h"
-#include "dbus/object_path.h"
-#include "dbus/object_proxy.h"
#endif
#include <glib-2.0/gmodule.h>
-#include "base/bind.h"
#include "base/files/file_path.h"
-#include "base/location.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "ui/accessibility/platform/atk_util_auralinux.h"
@@ -23,49 +16,41 @@
namespace {
-typedef void (*gnome_accessibility_module_init)();
-
-const char kAccessibilityEnabled[] = "ACCESSIBILITY_ENABLED";
-const char kAtkBridgePath[] = "gtk-2.0/modules/libatk-bridge.so";
-const char kAtkBridgeSymbolName[] = "gnome_accessibility_module_init";
-
-gnome_accessibility_module_init g_accessibility_module_init = nullptr;
-
-bool AccessibilityModuleInitOnFileThread() {
- // Try to load libatk-bridge.so.
- base::FilePath atk_bridge_path(ATK_LIB_DIR);
- atk_bridge_path = atk_bridge_path.Append(kAtkBridgePath);
- GModule* bridge = g_module_open(atk_bridge_path.value().c_str(),
- static_cast<GModuleFlags>(0));
- if (!bridge) {
- VLOG(1) << "Unable to open module " << atk_bridge_path.value();
- return false;
- }
-
- if (!g_module_symbol(bridge, kAtkBridgeSymbolName,
- (gpointer *)&g_accessibility_module_init)) {
- VLOG(1) << "Unable to get symbol pointer from " << atk_bridge_path.value();
- // Just to make sure it's null;
- g_accessibility_module_init = nullptr;
- return false;
- }
-
- return true;
-}
-
#if defined(USE_GCONF)
const char kGnomeAccessibilityEnabledKey[] =
"/desktop/gnome/interface/accessibility";
-#elif defined(USE_DBUS)
+bool ShouldEnableAccessibility() {
+ GConfClient* client = gconf_client_get_default();
+ if (!client) {
+ LOG(ERROR) << "gconf_client_get_default failed";
+ return false;
+ }
-const char kServiceName[] = "org.a11y.Bus";
-const char kObjectPath[] = "/org/a11y/bus";
-const char kInterfaceName[] = "org.a11y.Status";
-const char kPropertyName[] = "IsEnabled";
+ GError* error = nullptr;
+ gboolean value = gconf_client_get_bool(client,
+ kGnomeAccessibilityEnabledKey,
+ &error);
+ if (error) {
+ VLOG(1) << "gconf_client_get_bool failed";
+ g_error_free(error);
+ g_object_unref(client);
+ return false;
+ }
-#endif
+ g_object_unref(client);
+ return value;
+}
+
+#else // !defined(USE_GCONF)
+
+bool ShouldEnableAccessibility() {
+ // TODO(k.czech): implement this for non-GNOME desktops.
+ return false;
+}
+
+#endif // defined(USE_GCONF)
} // namespace
@@ -154,135 +139,44 @@
return Singleton<AtkUtilAuraLinux>::get();
}
-#if defined(USE_GCONF) || defined(USE_DBUS)
-
-AtkUtilAuraLinux::AtkUtilAuraLinux()
- : is_enabled_(false) {
-}
-
-#else
-
AtkUtilAuraLinux::AtkUtilAuraLinux() {
}
-#endif
-
void AtkUtilAuraLinux::Initialize(
scoped_refptr<base::TaskRunner> init_task_runner) {
+ // TODO(k.czech): use |init_task_runner| to post a task to do the
+ // initialization rather than doing it on this thread.
+ // http://crbug.com/468112
// Register our util class.
g_type_class_unref(g_type_class_ref(ATK_UTIL_AURALINUX_TYPE));
- init_task_runner->PostTaskAndReply(
- FROM_HERE,
- base::Bind(
- &AtkUtilAuraLinux::CheckIfAccessibilityIsEnabledOnFileThread,
- base::Unretained(this)),
- base::Bind(
- &AtkUtilAuraLinux::FinishAccessibilityInitOnUIThread,
- base::Unretained(this)));
+ if (!ShouldEnableAccessibility()) {
+ VLOG(1) << "Will not enable ATK accessibility support.";
+ return;
+ }
+
+ VLOG(1) << "Enabling ATK accessibility support.";
+
+ // Try to load libatk-bridge.so.
+ base::FilePath atk_bridge_path(ATK_LIB_DIR);
+ atk_bridge_path = atk_bridge_path.Append("gtk-2.0/modules/libatk-bridge.so");
+ GModule* bridge = g_module_open(atk_bridge_path.value().c_str(),
+ static_cast<GModuleFlags>(0));
+ if (!bridge) {
+ VLOG(1) << "Unable to open module " << atk_bridge_path.value();
+ return;
+ }
+
+ // Try to call gnome_accessibility_module_init from libatk-bridge.so.
+ void (*gnome_accessibility_module_init)();
+ if (g_module_symbol(bridge, "gnome_accessibility_module_init",
+ (gpointer *)&gnome_accessibility_module_init)) {
+ (*gnome_accessibility_module_init)();
+ }
}
AtkUtilAuraLinux::~AtkUtilAuraLinux() {
}
-void AtkUtilAuraLinux::CheckIfAccessibilityIsEnabledOnFileThread() {
- char* enable_accessibility = getenv(kAccessibilityEnabled);
- if ((enable_accessibility && atoi(enable_accessibility) == 1) ||
- CheckPlatformAccessibilitySupportOnFileThread())
- is_enabled_ = AccessibilityModuleInitOnFileThread();
-}
-
-#if defined(USE_GCONF)
-
-bool AtkUtilAuraLinux::CheckPlatformAccessibilitySupportOnFileThread() {
- GConfClient* client = gconf_client_get_default();
- if (!client) {
- LOG(ERROR) << "gconf_client_get_default failed";
- return false;
- }
-
- GError* error = nullptr;
- bool is_enabled = gconf_client_get_bool(client,
- kGnomeAccessibilityEnabledKey,
- &error);
-
- g_object_unref(client);
-
- if (error) {
- VLOG(1) << "gconf_client_get_bool failed";
- g_error_free(error);
- return false;
- }
-
- return is_enabled;
-}
-
-#elif defined(USE_DBUS)
-
-bool AtkUtilAuraLinux::CheckPlatformAccessibilitySupportOnFileThread() {
- dbus::Bus::Options options;
- scoped_refptr<dbus::Bus> dbus(new dbus::Bus(options));
- dbus::ObjectProxy* object_proxy = dbus->GetObjectProxy(
- kServiceName, dbus::ObjectPath(kObjectPath));
-
- DCHECK(object_proxy);
-
- dbus::MethodCall method_call(DBUS_INTERFACE_PROPERTIES, "Get");
- dbus::MessageWriter message_writer(&method_call);
- message_writer.AppendString(kInterfaceName);
- message_writer.AppendString(kPropertyName);
-
- // TODO(k.czech) replace this with asynchronous call
- scoped_ptr<dbus::Response> response(
- object_proxy->CallMethodAndBlock(&method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
-
- if (!response) {
- LOG(ERROR) << "AtSpi: failed to get " << kPropertyName;
- dbus->ShutdownAndBlock();
- return false;
- }
-
- // TODO(k.czech) handle case for at-spi2-core version 2.2.0/2.2.2
- // org.a11y.Bus.Enabled returns variant struct with a bool instead of bool
- bool is_enabled = false;
- dbus::MessageReader reader(response.get());
- if (!reader.PopVariantOfBool(&is_enabled))
- LOG(ERROR) << "AtSpi: unexpected response";
-
- dbus->ShutdownAndBlock();
-
- return is_enabled;
-}
-
-#else
-
-bool AtkUtilAuraLinux::CheckPlatformAccessibilitySupportOnFileThread() {
- return false;
-}
-
-#endif
-
-#if defined(USE_GCONF) || defined(USE_DBUS)
-
-void AtkUtilAuraLinux::FinishAccessibilityInitOnUIThread() {
- if (!is_enabled_) {
- VLOG(1) << "Will not enable ATK accessibility support.";
- return;
- }
-
- VLOG(1) << "Enabling ATK accessibility support.";
- // Try to call gnome_accessibility_module_init from libatk-bridge.so.
- DCHECK(g_accessibility_module_init);
- g_accessibility_module_init();
-}
-
-#else
-
-void AtkUtilAuraLinux::FinishAccessibilityInitOnUIThread() {
-}
-
-#endif
-
} // namespace ui
« no previous file with comments | « ui/accessibility/platform/atk_util_auralinux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698