Index: modules/overlay/overlay-child.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-child.css,v
retrieving revision 1.6
diff -u -p -r1.6 overlay-child.css
--- modules/overlay/overlay-child.css	28 Jul 2010 01:26:00 -0000	1.6
+++ modules/overlay/overlay-child.css	16 Sep 2010 15:57:01 -0000
@@ -138,3 +138,8 @@ html.js body {
 * html #overlay-close:hover {
   position: absolute;
 }
+
+.element-invisible.force-visible {
+  position: static !important;
+  clip: auto;
+}
\ No newline at end of file
Index: modules/overlay/overlay-child.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-child.js,v
retrieving revision 1.10
diff -u -p -r1.10 overlay-child.js
--- modules/overlay/overlay-child.js	8 Jul 2010 12:20:23 -0000	1.10
+++ modules/overlay/overlay-child.js	16 Sep 2010 15:57:01 -0000
@@ -57,6 +57,11 @@ Drupal.behaviors.overlayChild = {
 
     // Attach child related behaviors to the iframe document.
     Drupal.overlayChild.attachBehaviors(context, settings);
+    
+    // Make sure both links are always visible when either is focused.
+    $('#overlay-disable-link a')
+      .focusin( function() { $('#overlay-disable-link a').addClass('force-visible'); })
+      .focusout( function() { $('#overlay-disable-link a').removeClass('force-visible'); });
   }
 };
 
Index: modules/overlay/overlay-parent.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-parent.css,v
retrieving revision 1.15
diff -u -p -r1.15 overlay-parent.css
--- modules/overlay/overlay-parent.css	8 Jun 2010 05:16:29 -0000	1.15
+++ modules/overlay/overlay-parent.css	16 Sep 2010 15:57:01 -0000
@@ -46,3 +46,8 @@ html.overlay-open .displace-bottom {
 {
   position: absolute;
 }
+
+.element-invisible.force-visible {
+  position: static !important;
+  clip: auto;
+}
\ No newline at end of file
Index: modules/overlay/overlay-parent.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-parent.js,v
retrieving revision 1.54
diff -u -p -r1.54 overlay-parent.js
--- modules/overlay/overlay-parent.js	18 Aug 2010 02:25:50 -0000	1.54
+++ modules/overlay/overlay-parent.js	16 Sep 2010 15:57:02 -0000
@@ -25,6 +25,30 @@ Drupal.behaviors.overlayParent = {
       // scripts to bind their own handlers to links and also to prevent
       // overlay's handling.
       .bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOverrideLink'));
+    
+    // Inject the disable overlay links if they need to be displayed.
+    if (typeof Drupal.settings.overlay.disable_link != 'undefined') {
+      // Wrap the #skip-link in an wrapper div (or create that wrapper)
+      // allowing us to keep elements at the top of the DOM and in a sensible
+      // order.
+      if ($('#skip-link').length) {
+        $('#skip-link').wrap('<div id="accessibility-wrapper"/>');
+        // make sure #skip-link remains the first
+        $('#skip-link').attr('tabindex', -100);        
+      } 
+      else {
+        $('body').prepend('<div id="accessibility-wrapper"/>')
+      }
+      // Create a container for the two overlay accessibility links
+      $('#accessibility-wrapper').append('<div id="overlay-disable-link"/>');
+      // Add links and set the tab index for the container
+      $('#overlay-disable-link').append(Drupal.settings.overlay.disable_link.profile_link).attr('tabindex', -99);
+      $('#overlay-disable-link').append(Drupal.settings.overlay.disable_link.dismiss_message_link);
+        // Make sure both links are always visible when either is focused.
+      $('#overlay-disable-link a')
+        .focusin( function() { $('#overlay-disable-link a').addClass('force-visible'); })
+        .focusout( function() { $('#overlay-disable-link a').removeClass('force-visible'); });
+    }
   }
 };
 
Index: modules/overlay/overlay.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v
retrieving revision 1.31
diff -u -p -r1.31 overlay.module
--- modules/overlay/overlay.module	31 Aug 2010 15:04:09 -0000	1.31
+++ modules/overlay/overlay.module	16 Sep 2010 15:57:02 -0000
@@ -30,6 +30,16 @@ function overlay_menu() {
     'access arguments' => array('access overlay'),
     'type' => MENU_CALLBACK,
   );
+  // Menu callback setting overlay preference (and dismissing accessibility
+  // message).
+  $items['overlay/set/%/%'] = array(
+    'title' => 'Sets the overlay preference of the current user',
+    'type' => MENU_CALLBACK,
+    'page callback' => 'overlay_user_set_preference',
+    'access arguments' => array('access overlay'),
+    'page arguments' => array(2, 3)
+  );
+
   return $items;
 }
 
@@ -62,8 +72,11 @@ function overlay_theme() {
  */
 function overlay_form_user_profile_form_alter(&$form, &$form_state) {
   if ($form['#user_category'] == 'account') {
+    global $user;
     $account = $form['#user'];
-    if (user_access('access overlay', $account)) {
+    // Display overlay preference fieldset only if current user can access the
+    // overlay and only on current user's own profile.
+    if (user_access('access overlay', $account) && $account->uid == $user->uid) {
       $form['overlay_control'] = array(
         '#type' => 'fieldset',
         '#title' => t('Administrative overlay'),
@@ -85,7 +98,9 @@ function overlay_form_user_profile_form_
  * Implements hook_user_presave().
  */
 function overlay_user_presave(&$edit, $account, $category) {
-  if (isset($edit['overlay'])) {
+  global $user;
+  // Only allow user's own overlay preference to be set.
+  if (isset($edit['overlay']) && $account->uid == $user->uid) {
     $edit['data']['overlay'] = $edit['overlay'];
   }
 }
@@ -258,6 +273,90 @@ function overlay_page_alter(&$page) {
     // Add the overlay wrapper before the html wrapper.
     array_unshift($page['#theme_wrappers'], 'overlay');
   }
+  elseif ($link = _overlay_disable_link()) {
+    $overlay_disable_setting = array(
+      'profile_link' => drupal_render($link['profile_link']),
+      'dismiss_message_link' => drupal_render($link['dismiss_message_link'])
+    );
+    drupal_add_js(array('overlay' => array('disable_link' => $overlay_disable_setting)), 'setting');
+  }
+}
+
+/**
+ * Sets the overlay preference of the current user.
+ *
+ * @param $preference
+ *   Set the overlay preference (0 disables, 1 enables).
+ * @param $token
+ *   Token protecting against CSRF
+ */
+function overlay_user_set_preference($preference, $token) {
+  if ($token != drupal_get_token('overlay')) {
+    drupal_access_denied();
+  }
+  else {
+    global $user;
+    if (user_save(user_load($user->uid), array('data' => array('overlay' => (bool) $preference ? 1 : 0 )))) {
+      // @todo: what do we want to display here ...
+      drupal_set_message(t('Your preference for the administrative overlay has been saved and the message dismissed.'));
+    }
+    // Destination is normally given. Go to user profile as fallback.
+    drupal_goto('user/' . $user->uid . '/edit');
+  }
+}
+
+/**
+ * Returns a renderable array representing a link to disable the Overlay.
+ *
+ * If the current user can access the overlay, but has not set a preference
+ * regarding the overlay in the user account settings, then this function
+ * returns a link to disable the overlay.
+ */
+function _overlay_disable_link() {
+  global $user;
+
+  $build = array();
+  if (!isset($user->data['overlay']) && user_access('access overlay')) {
+    // Wrap the two links in a container
+    $build = array(
+      '#prefix' => '<div id="overlay-disable-link">',
+      '#suffix' => '</div>',
+      // Disable link
+      'profile_link' => array(
+        '#type' => 'link',
+        '#title' => t('Administrative pages are configured to open in an overlay window. If you cannot access them, disable the administrative overlay in your account settings.'),
+        '#href' => 'user/' . $user->uid . '/edit',
+        '#options' => array(
+          'query' => drupal_get_destination(),
+          'fragment' => 'edit-overlay-control',
+          'attributes' => array(
+            'id' => 'overlay-profile-link',
+            // Prevent the target page from being opened in the overlay, and make
+            // this link visible for screen-readers only.
+            'class' => array('overlay-exclude', 'element-invisible', 'focusable'),
+          ),
+        ),
+      ),
+      // Dismiss link
+      'dismiss_message_link' => array(
+        '#type' => 'link',
+        '#title' => t('Dismiss this message.'),
+        // Dismissing means: enable the overlay and dismiss the message
+        '#href' => 'overlay/set/1/' . drupal_get_token('overlay'),
+        '#options' => array(
+          'query' => drupal_get_destination(),
+          'fragment' => 'edit-overlay-control',
+          'attributes' => array(
+            'id' => 'overlay-dismiss-message',
+            // Prevent the target page from being opened in the overlay, and make
+            // this link visible for screen-readers only.
+            'class' => array('overlay-exclude', 'element-invisible', 'focusable'),
+          ),
+        ),
+      )
+    );
+  }
+  return $build;
 }
 
 /**
@@ -324,9 +423,9 @@ function overlay_preprocess_maintenance_
  * @see overlay.tpl.php
  */
 function template_preprocess_overlay(&$variables) {
-  $variables['tabs']              = menu_primary_local_tasks();
-  $variables['title']             = drupal_get_title();
-
+  $variables['tabs'] = menu_primary_local_tasks();
+  $variables['title'] = drupal_get_title();
+  $variables['disable_overlay'] = _overlay_disable_link();
   $variables['content_attributes_array']['class'][] = 'clearfix';
 }
 
Index: modules/overlay/overlay.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.tpl.php,v
retrieving revision 1.3
diff -u -p -r1.3 overlay.tpl.php
--- modules/overlay/overlay.tpl.php	11 Jul 2010 22:03:45 -0000	1.3
+++ modules/overlay/overlay.tpl.php	16 Sep 2010 15:57:02 -0000
@@ -21,6 +21,7 @@
  */
 ?>
 
+<?php print render($disable_overlay); ?>
 <div id="overlay" <?php print $attributes; ?>>
   <div id="overlay-titlebar" class="clearfix">
     <div id="overlay-title-wrapper" class="clearfix">
