commit 0e0af3160db04e48fd5036b8ef52fd041119d0da
Author: Katherine Senzee <katherine.senzee@acquia.com>
Date:   Wed Dec 9 16:30:33 2009 -0800

    get rid of $custom_theme global

diff --git modules/overlay/overlay.api.php modules/overlay/overlay.api.php
index 12c2bc5..f256582 100644
--- modules/overlay/overlay.api.php
+++ modules/overlay/overlay.api.php
@@ -32,13 +32,8 @@ function hook_overlay_parent_initialize() {
  * within the confines of the overlay.
  */
 function hook_overlay_child_initialize() {
-  // Use a different theme for content administration pages.
-  if (arg(0) == 'admin' && arg(1) == 'content') {
-    if ($theme = variable_get('content_administration_pages_theme', FALSE)) {
-      global $custom_theme;
-      $custom_theme = $theme;
-    }
-  }
+  // Add our custom JavaScript.
+  drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay-child.js');
 }
 
 /**
diff --git modules/overlay/overlay.module modules/overlay/overlay.module
index 9c390d0..d73ccf4 100644
--- modules/overlay/overlay.module
+++ modules/overlay/overlay.module
@@ -41,8 +41,6 @@ function overlay_permission() {
  * @see overlay_set_mode()
  */
 function overlay_init() {
-  // @todo: custom_theme does not exist anymore.
-  global $custom_theme;
   // Only act if the user has access to administration pages. Other modules can
   // also enable the overlay directly for other uses of the JavaScript.
   if (user_access('access overlay')) {
@@ -51,13 +49,6 @@ function overlay_init() {
       if (!path_is_admin($_GET['q'])) {
         overlay_close_dialog();
       }
-      // If system module did not switch the theme yet (i.e. this is not an
-      // admin page, per se), we should switch the theme here.
-      $admin_theme = variable_get('admin_theme', 0);
-      if ($custom_theme != $admin_theme) {
-        $custom_theme = $admin_theme;
-        drupal_add_css(drupal_get_path('module', 'system') . '/admin.css');
-      }
       // Indicate that we are viewing an overlay child page.
       overlay_set_mode('child');
     }
@@ -69,6 +60,21 @@ function overlay_init() {
 }
 
 /**
+ * Implements hook_custom_theme().
+ *
+ * If the site has an administrative theme, use it within the overlay.
+ */
+function overlay_custom_theme() {
+  if (user_access('access overlay') && isset($_GET['render']) && $_GET['render'] == 'overlay') {
+    $admin_theme = variable_get('admin_theme', 0);
+    if ($admin_theme) {
+      drupal_add_css(drupal_get_path('module', 'system') . '/admin.css');
+      return $admin_theme;
+    }
+  }
+}
+
+/**
  * Implements hook_exit().
  *
  * When viewing an overlay child page, check if we need to trigger a refresh of
