diff -urp modules/contextual/contextual.module modules/contextual/contextual.module
--- modules/contextual/contextual.module	2010-01-08 13:06:53.000000000 +0530
+++ modules/contextual/contextual.module	2010-02-04 18:59:10.000000000 +0530
@@ -29,10 +29,29 @@ function contextual_help($path, $arg) {
  * Implements hook_permission().
  */
 function contextual_permission() {
+  // Determine if there are any themes that do not support contextual links,
+  // so that we can add a proper permission description for 'access contextual
+  // links'.
+  $themes = list_themes();
+  $themes_without_contextual_links = array();
+  foreach ($themes as $theme) {
+    if (drupal_theme_access($theme) && !theme_get_setting('toggle_contextual_links', $theme->name)) {
+      $themes_without_contextual_links[] = $theme->info['name'];
+    }
+  }
+  if (empty($themes_without_contextual_links)) {
+    $contextual_links_description = t('Use contextual links to perform actions related to elements on a page.');
+  }
+  elseif (count($themes_without_contextual_links) == 1) {
+    $contextual_links_description = t('Use contextual links to perform actions related to elements on a page. (Note: The %theme theme is not configured to display contextual links, so this permission will not have an effect when that theme is being used.)', array('%theme' => reset($themes_without_contextual_links)));
+  }
+  else {
+    $contextual_links_description = t('Use contextual links to perform actions related to elements on a page. (Note: The following themes are not configured to display contextual links, so this permission will not have an effect when those themes are being used: %themes)', array('%themes' => implode(', ', $themes_without_contextual_links)));
+  }
   return array(
     'access contextual links' => array(
       'title' => t('Use contextual links'),
-      'description' => t('Use contextual links to perform actions related to elements on a page.'),
+      'description' => $contextual_links_description,
     ),
   );
 }
@@ -65,7 +84,7 @@ function contextual_preprocess(&$variabl
   static $hooks;
 
   // Nothing to do here if the user is not permitted to access contextual links.
-  if (!user_access('access contextual links')) {
+  if (!user_access('access contextual links') || !theme_get_setting('toggle_contextual_links')) {
     return;
   }
 
diff -urp modules/system/system.admin.inc modules/system/system.admin.inc
--- modules/system/system.admin.inc	2010-01-30 13:24:01.000000000 +0530
+++ modules/system/system.admin.inc	2010-02-04 18:51:40.000000000 +0530
@@ -483,6 +483,7 @@ function system_theme_settings($form, &$
     'favicon'                   => t('Shortcut icon'),
     'main_menu'                 => t('Main menu'),
     'secondary_menu'            => t('Secondary menu'),
+    'contextual_links'          => t('Contextual links'),
   );
 
   // Some features are not always available
diff -urp drupal-f/modules/system/system.module drupal-u/modules/system/system.module
--- modules/system/system.module	2010-02-03 13:56:02.000000000 +0530
+++ modules/system/system.module	2010-02-04 18:52:47.000000000 +0530
@@ -2264,6 +2264,7 @@ function _system_rebuild_theme_data() {
         'slogan',
         'main_menu',
         'secondary_menu',
+        'contextual_links',
       ),
       'screenshot' => 'screenshot.png',
       'php' => DRUPAL_MINIMUM_PHP,
