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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/glue/plugins/flash_workarounds_linux.h"
6
7 #include <dlfcn.h>
8 #include <gtk/gtk.h>
9 #include <gdk/gdkx.h>
10
11 #include "base/logging.h"
12 #include "base/native_library.h"
13
14 namespace {
15
16 typedef void (*Type_gtk_widget_modify_bg)(
17 GtkWidget* widget, GtkStateType state, const GdkColor* color);
18 Type_gtk_widget_modify_bg g_real_gtk_widget_modify_bg = NULL;
19 bool g_enable_gtk_widget_modify_bg_workaround = false;
20
21 typedef Status (* Type_XGetWindowAttributes)(
22 Display *display, Window w, XWindowAttributes *window_attributes_return);
23 Type_XGetWindowAttributes g_real_XGetWindowAttributes = NULL;
24
25 } // anonymous namespace
26
27 extern "C" {
28
29 // Flash calls gtk_widget_modify_bg from an expose handler, but that function
30 // can generate more expose events, leading to an infinite loop.
31 // So we intercept that function and disable it in the flash plugin process.
32 void gtk_widget_modify_bg(GtkWidget* widget, GtkStateType state,
33 const GdkColor* color) {
34 if (!g_real_gtk_widget_modify_bg) {
35 g_real_gtk_widget_modify_bg = (Type_gtk_widget_modify_bg)(
36 dlsym(RTLD_NEXT, "gtk_widget_modify_bg"));
37 DCHECK(g_real_gtk_widget_modify_bg);
38 }
39 if (g_enable_gtk_widget_modify_bg_workaround)
40 return;
41 g_real_gtk_widget_modify_bg(widget, state, color);
42 }
43
44 // Flash calls XGetWindowAttributes with a NULL display, which crashes.
45 // So we intercept that function and make sure the display is set.
46 Status XGetWindowAttributes(Display *display, Window w,
47 XWindowAttributes *window_attributes_return) {
48 if (!g_real_XGetWindowAttributes) {
49 g_real_XGetWindowAttributes = (Type_XGetWindowAttributes)(
50 dlsym(RTLD_NEXT, "XGetWindowAttributes"));
51 DCHECK(g_real_XGetWindowAttributes);
52 }
53 if (!display)
54 display = GDK_DISPLAY();
55 DCHECK(display);
56 return g_real_XGetWindowAttributes(display, w, window_attributes_return);
57 }
58
59 } // extern "C"
60
61 void EnableFlashWorkarounds(const FilePath &library_path) {
62 base::AddShallowBindPath(library_path);
63 g_enable_gtk_widget_modify_bg_workaround = true;
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698