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

Unified Diff: webkit/glue/plugins/flash_workarounds_linux.cc

Issue 155558: linux: add flash workarounds (Closed)
Patch Set: Created 11 years, 5 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
Index: webkit/glue/plugins/flash_workarounds_linux.cc
diff --git a/webkit/glue/plugins/flash_workarounds_linux.cc b/webkit/glue/plugins/flash_workarounds_linux.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1c203aa8636816414a6d67c514cc50a0ae2b9189
--- /dev/null
+++ b/webkit/glue/plugins/flash_workarounds_linux.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/glue/plugins/flash_workarounds_linux.h"
+
+#include <dlfcn.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+#include "base/logging.h"
+#include "base/native_library.h"
+
+namespace {
+
+typedef void (*Type_gtk_widget_modify_bg)(
+ GtkWidget* widget, GtkStateType state, const GdkColor* color);
+Type_gtk_widget_modify_bg g_real_gtk_widget_modify_bg = NULL;
+bool g_enable_gtk_widget_modify_bg_workaround = false;
+
+typedef Status (* Type_XGetWindowAttributes)(
+ Display *display, Window w, XWindowAttributes *window_attributes_return);
+Type_XGetWindowAttributes g_real_XGetWindowAttributes = NULL;
+
+} // anonymous namespace
+
+extern "C" {
+
+// Flash calls gtk_widget_modify_bg from an expose handler, but that function
+// can generate more expose events, leading to an infinite loop.
+// So we intercept that function and disable it in the flash plugin process.
+void gtk_widget_modify_bg(GtkWidget* widget, GtkStateType state,
+ const GdkColor* color) {
+ if (!g_real_gtk_widget_modify_bg) {
+ g_real_gtk_widget_modify_bg = (Type_gtk_widget_modify_bg)(
+ dlsym(RTLD_NEXT, "gtk_widget_modify_bg"));
+ DCHECK(g_real_gtk_widget_modify_bg);
+ }
+ if (g_enable_gtk_widget_modify_bg_workaround)
+ return;
+ g_real_gtk_widget_modify_bg(widget, state, color);
+}
+
+// Flash calls XGetWindowAttributes with a NULL display, which crashes.
+// So we intercept that function and make sure the display is set.
+Status XGetWindowAttributes(Display *display, Window w,
+ XWindowAttributes *window_attributes_return) {
+ if (!g_real_XGetWindowAttributes) {
+ g_real_XGetWindowAttributes = (Type_XGetWindowAttributes)(
+ dlsym(RTLD_NEXT, "XGetWindowAttributes"));
+ DCHECK(g_real_XGetWindowAttributes);
+ }
+ if (!display)
+ display = GDK_DISPLAY();
+ DCHECK(display);
+ return g_real_XGetWindowAttributes(display, w, window_attributes_return);
+}
+
+} // extern "C"
+
+void EnableFlashWorkarounds(const FilePath &library_path) {
+ base::AddShallowBindPath(library_path);
+ g_enable_gtk_widget_modify_bg_workaround = true;
+}

Powered by Google App Engine
This is Rietveld 408576698