Clean up extension_util.h.

Make utility functions take BrowserContexts instead of
ExtensionServices. Also move them from the extension_util
namespace to extensions::util.

BUG=315853,332985
[email protected]

Review URL: https://codereview.chromium.org/145263009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246929 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/apps/ephemeral_app_launcher.cc b/chrome/browser/apps/ephemeral_app_launcher.cc
index 828f4cb..6feee8e 100644
--- a/chrome/browser/apps/ephemeral_app_launcher.cc
+++ b/chrome/browser/apps/ephemeral_app_launcher.cc
@@ -82,8 +82,8 @@
 
   const Extension* extension = extension_service->GetInstalledExtension(id());
   if (extension) {
-    if (extension_util::IsAppLaunchableWithoutEnabling(extension->id(),
-                                                       extension_service)) {
+    if (extensions::util::IsAppLaunchableWithoutEnabling(extension->id(),
+                                                         profile())) {
       LaunchApp(extension);
       InvokeCallback(std::string());
       return;
diff --git a/chrome/browser/apps/ephemeral_app_service.cc b/chrome/browser/apps/ephemeral_app_service.cc
index 1b4713b..1a526bc 100644
--- a/chrome/browser/apps/ephemeral_app_service.cc
+++ b/chrome/browser/apps/ephemeral_app_service.cc
@@ -170,7 +170,7 @@
     ++app_count;
 
     // Do not remove ephemeral apps that are running.
-    if (!extension_util::IsExtensionIdle(extension->id(), system))
+    if (!extensions::util::IsExtensionIdle(extension->id(), profile_))
       continue;
 
     base::Time last_launch_time = prefs->GetLastLaunchTime(extension->id());
diff --git a/chrome/browser/autocomplete/extension_app_provider.cc b/chrome/browser/autocomplete/extension_app_provider.cc
index d6624fc..4687bded 100644
--- a/chrome/browser/autocomplete/extension_app_provider.cc
+++ b/chrome/browser/autocomplete/extension_app_provider.cc
@@ -165,7 +165,7 @@
     // provider is currently only used in the app launcher.
 
     if (profile_->IsOffTheRecord() &&
-        !extension_util::CanLoadInIncognito(app, extension_service))
+        !extensions::util::CanLoadInIncognito(app, profile_))
       continue;
 
     GURL launch_url = app->is_platform_app() ?
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc
index 81a9012c..ae14a6635 100644
--- a/chrome/browser/autocomplete/keyword_provider.cc
+++ b/chrome/browser/autocomplete/keyword_provider.cc
@@ -206,8 +206,7 @@
         GetExtensionById(template_url->GetExtensionId(), false);
     if (!extension ||
         (profile_->IsOffTheRecord() &&
-        !extension_util::IsIncognitoEnabled(extension->id(),
-                                            extension_service)))
+        !extensions::util::IsIncognitoEnabled(extension->id(), profile_)))
       return base::string16();
   }
 
@@ -285,8 +284,8 @@
           service->GetExtensionById(template_url->GetExtensionId(), false);
       bool enabled =
           extension && (!profile_->IsOffTheRecord() ||
-                        extension_util::IsIncognitoEnabled(extension->id(),
-                                                           service));
+                        extensions::util::IsIncognitoEnabled(
+                            extension->id(), profile_));
       if (!enabled) {
         i = matches.erase(i);
         continue;
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 15706b08..2ad67fe 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -3577,7 +3577,7 @@
         Manifest::IsUnpackedLocation(location));
     extension_value->SetBoolean("is_enabled", service->IsExtensionEnabled(id));
     extension_value->SetBoolean("allowed_in_incognito",
-        extension_util::IsIncognitoEnabled(id, service));
+        extensions::util::IsIncognitoEnabled(id, browser->profile()));
     extension_value->SetBoolean(
         "has_page_action",
         extension_action_manager->GetPageAction(*extension) != NULL);
@@ -3683,8 +3683,8 @@
     AutomationJSONReply(this, reply_message).SendSuccess(NULL);
   }
 
-  extension_util::SetIsIncognitoEnabled(
-      extension->id(), service, allow_in_incognito);
+  extensions::util::SetIsIncognitoEnabled(
+      extension->id(), browser->profile(), allow_in_incognito);
 }
 
 // See TriggerPageActionById() in chrome/test/pyautolib/pyauto.py
diff --git a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc
index 8996671..6e4bf80 100644
--- a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc
+++ b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc
@@ -107,7 +107,7 @@
        iter != service->extensions()->end(); ++iter) {
     const Extension* extension = iter->get();
     if (profile->IsOffTheRecord() &&
-        !extension_util::IsIncognitoEnabled(extension->id(), service))
+        !extensions::util::IsIncognitoEnabled(extension->id(), profile))
       continue;
 
     FileBrowserHandler::List* handler_list =
diff --git a/chrome/browser/chromeos/file_manager/file_tasks.cc b/chrome/browser/chromeos/file_manager/file_tasks.cc
index 7e8aaa0..2298600fd 100644
--- a/chrome/browser/chromeos/file_manager/file_tasks.cc
+++ b/chrome/browser/chromeos/file_manager/file_tasks.cc
@@ -397,7 +397,7 @@
       continue;
 
     if (profile->IsOffTheRecord() &&
-        !extension_util::IsIncognitoEnabled(extension->id(), service))
+        !extensions::util::IsIncognitoEnabled(extension->id(), profile))
       continue;
 
     typedef std::vector<const extensions::FileHandlerInfo*> FileHandlerList;
diff --git a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
index 3c6cf24..e51bf34a 100644
--- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
+++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
@@ -12,6 +12,7 @@
 #include "chrome/browser/extensions/extension_system.h"
 #include "chrome/browser/extensions/extension_util.h"
 #include "chrome/browser/lifetime/application_lifetime.h"
+#include "chrome/browser/profiles/profile.h"
 #include "chrome/common/extensions/api/autotest_private.h"
 #include "chrome/common/extensions/manifest_url_handler.h"
 #include "extensions/common/manifest_handlers/background_info.h"
@@ -190,7 +191,7 @@
         Manifest::IsUnpackedLocation(location));
     extension_value->SetBoolean("isEnabled", service->IsExtensionEnabled(id));
     extension_value->SetBoolean("allowedInIncognito",
-        extension_util::IsIncognitoEnabled(id, service));
+        util::IsIncognitoEnabled(id, GetProfile()));
     extension_value->SetBoolean(
         "hasPageAction",
         extension_action_manager->GetPageAction(*extension) != NULL);
diff --git a/chrome/browser/extensions/api/declarative/rules_cache_delegate.cc b/chrome/browser/extensions/api/declarative/rules_cache_delegate.cc
index 7b4bdaa9..bc3778b 100644
--- a/chrome/browser/extensions/api/declarative/rules_cache_delegate.cc
+++ b/chrome/browser/extensions/api/declarative/rules_cache_delegate.cc
@@ -140,7 +140,7 @@
           (*i)->HasAPIPermission(APIPermission::kDeclarativeWebRequest);
       bool respects_off_the_record =
           !(profile_->IsOffTheRecord()) ||
-          extension_util::IsIncognitoEnabled((*i)->id(), extension_service);
+          util::IsIncognitoEnabled((*i)->id(), profile_);
       if (needs_apis_storing_rules && respects_off_the_record)
         ReadFromStorage((*i)->id());
     }
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index c10bf03..de05b83 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -317,10 +317,9 @@
     }
   }
 
-  info->incognito_enabled =
-      extension_util::IsIncognitoEnabled(item.id(),service);
+  info->incognito_enabled = util::IsIncognitoEnabled(item.id(), GetProfile());
   info->wants_file_access = item.wants_file_access();
-  info->allow_file_access = extension_util::AllowFileAccess(&item, service);
+  info->allow_file_access = util::AllowFileAccess(item.id(), GetProfile());
   info->allow_reload = Manifest::IsUnpackedLocation(item.location());
   info->is_unpacked = Manifest::IsUnpackedLocation(item.location());
   info->terminated = registry->terminated_extensions().Contains(item.id());
@@ -587,7 +586,7 @@
                << extension->id();
     result = false;
   } else {
-    extension_util::SetAllowFileAccess(extension, service, params->allow);
+    util::SetAllowFileAccess(extension->id(), GetProfile(), params->allow);
     result = true;
   }
 
@@ -609,8 +608,7 @@
   if (!extension)
     result = false;
   else
-    extension_util::SetIsIncognitoEnabled(
-        extension->id(),service, params->allow);
+    util::SetIsIncognitoEnabled(extension->id(), GetProfile(), params->allow);
 
   return result;
 }
diff --git a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc
index a5bb68d2..6d5ee30 100644
--- a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc
+++ b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc
@@ -395,7 +395,7 @@
        ++iter) {
     const Extension* extension = iter->get();
     if (GetProfile()->IsOffTheRecord() &&
-        !extension_util::IsIncognitoEnabled(extension->id(), service))
+        !util::IsIncognitoEnabled(extension->id(), GetProfile()))
       continue;
 
     MediaGalleriesHandler::List* handler_list =
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc
index cf44a51..48afc782 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -217,7 +217,8 @@
 
   // Only running ephemeral apps can receive messages. Idle cached ephemeral
   // apps are invisible and should not be connectable.
-  if (extension_util::IsIdleEphemeralApp(target_extension, extension_system)) {
+  if (target_extension->is_ephemeral() &&
+      util::IsExtensionIdle(target_extension_id, profile)) {
     DispatchOnDisconnect(
         source, receiver_port_id, kReceivingEndDoesntExistError);
     return;
@@ -267,14 +268,11 @@
     }
   }
 
-  ExtensionService* extension_service =
-      ExtensionSystem::Get(profile)->extension_service();
   WebContents* source_contents = tab_util::GetWebContentsByID(
       source_process_id, source_routing_id);
 
   if (profile->IsOffTheRecord() &&
-      !extension_util::IsIncognitoEnabled(target_extension_id,
-                                          extension_service)) {
+      !util::IsIncognitoEnabled(target_extension_id, profile)) {
     // Give the user a chance to accept an incognito connection if they haven't
     // already - but only for spanning-mode incognito. We don't want the
     // complication of spinning up an additional process here which might need
diff --git a/chrome/browser/extensions/api/module/module.cc b/chrome/browser/extensions/api/module/module.cc
index 1d74237..049220e 100644
--- a/chrome/browser/extensions/api/module/module.cc
+++ b/chrome/browser/extensions/api/module/module.cc
@@ -52,22 +52,14 @@
 }
 
 bool ExtensionIsAllowedIncognitoAccessFunction::RunImpl() {
-  ExtensionService* ext_service =
-      ExtensionSystem::Get(GetProfile())->extension_service();
-  const Extension* extension = GetExtension();
-
   SetResult(new base::FundamentalValue(
-      extension_util::IsIncognitoEnabled(extension->id(), ext_service)));
+      util::IsIncognitoEnabled(extension_id(), GetProfile())));
   return true;
 }
 
 bool ExtensionIsAllowedFileSchemeAccessFunction::RunImpl() {
-  ExtensionService* ext_service =
-      ExtensionSystem::Get(GetProfile())->extension_service();
-  const Extension* extension = GetExtension();
-
   SetResult(new base::FundamentalValue(
-      extension_util::AllowFileAccess(extension, ext_service)));
+      util::AllowFileAccess(extension_id(), GetProfile())));
   return true;
 }
 
diff --git a/chrome/browser/extensions/api/preference/preference_helpers.cc b/chrome/browser/extensions/api/preference/preference_helpers.cc
index 61ab636..9a1d356 100644
--- a/chrome/browser/extensions/api/preference/preference_helpers.cc
+++ b/chrome/browser/extensions/api/preference/preference_helpers.cc
@@ -103,7 +103,7 @@
     if (router->ExtensionHasEventListener(extension_id, event_name) &&
         (*it)->HasAPIPermission(permission) &&
         (!incognito || IncognitoInfo::IsSplitMode(it->get()) ||
-         extension_util::CanCrossIncognito(it->get(), extension_service))) {
+         util::CanCrossIncognito(it->get(), profile))) {
       // Inject level of control key-value.
       base::DictionaryValue* dict;
       bool rv = args->GetDictionary(0, &dict);
@@ -120,8 +120,7 @@
       bool from_incognito = false;
       if (IncognitoInfo::IsSplitMode(it->get())) {
         if (incognito &&
-            extension_util::IsIncognitoEnabled(extension_id,
-                                               extension_service)) {
+            util::IsIncognitoEnabled(extension_id, profile)) {
           restrict_to_profile = profile->GetOffTheRecordProfile();
         } else if (!incognito &&
                    PreferenceAPI::Get(profile)->DoesExtensionControlPref(
diff --git a/chrome/browser/extensions/api/tabs/windows_event_router.cc b/chrome/browser/extensions/api/tabs/windows_event_router.cc
index e6d55fca..de47d1f 100644
--- a/chrome/browser/extensions/api/tabs/windows_event_router.cc
+++ b/chrome/browser/extensions/api/tabs/windows_event_router.cc
@@ -118,9 +118,7 @@
   // can't see the new focused window across the incognito boundary.
   // See crbug.com/46610.
   if (new_active_context && new_active_context != context &&
-      !extension_util::CanCrossIncognito(extension,
-                                         ExtensionSystem::GetForBrowserContext(
-                                             context)->extension_service())) {
+      !util::CanCrossIncognito(extension, context)) {
     event_args->Clear();
     event_args->Append(new base::FundamentalValue(
         extension_misc::kUnknownWindowId));
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
index 572a4d8..82a6340 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -298,12 +298,9 @@
   std::string icon_data = params_->details.icon_data ?
       *params_->details.icon_data : std::string();
 
-  ExtensionService* service =
-      extensions::ExtensionSystem::Get(GetProfile())->extension_service();
-  if (extension_util::IsExtensionInstalledPermanently(params_->details.id,
-                                                      service)
-      || !g_pending_installs.Get().InsertInstall(GetProfile(),
-                                                 params_->details.id)) {
+  Profile* profile = GetProfile();
+  if (util::IsExtensionInstalledPermanently(params_->details.id, profile) ||
+      !g_pending_installs.Get().InsertInstall(profile, params_->details.id)) {
     SetResultCode(ALREADY_INSTALLED);
     error_ = kAlreadyInstalledError;
     return false;
diff --git a/chrome/browser/extensions/app_icon_loader_impl.cc b/chrome/browser/extensions/app_icon_loader_impl.cc
index fefa33eb..bde988b 100644
--- a/chrome/browser/extensions/app_icon_loader_impl.cc
+++ b/chrome/browser/extensions/app_icon_loader_impl.cc
@@ -105,10 +105,7 @@
                                    const gfx::ImageSkia& icon) {
   gfx::ImageSkia image = icon;
 
-  const ExtensionService* service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
-  const bool can_launch = extension_util::IsAppLaunchable(id, service);
-  if (!can_launch) {
+  if (!util::IsAppLaunchable(id, profile_)) {
     const color_utils::HSL shift = {-1, 0, 0.6};
     image = gfx::ImageSkiaOperations::CreateHSLShiftedImage(image, shift);
   }
diff --git a/chrome/browser/extensions/context_menu_matcher.cc b/chrome/browser/extensions/context_menu_matcher.cc
index 28f3449..a49a1d97 100644
--- a/chrome/browser/extensions/context_menu_matcher.cc
+++ b/chrome/browser/extensions/context_menu_matcher.cc
@@ -161,7 +161,7 @@
   if (!all_items || all_items->empty())
     return false;
 
-  *can_cross_incognito = extension_util::CanCrossIncognito(*extension, service);
+  *can_cross_incognito = util::CanCrossIncognito(*extension, profile_);
   items = GetRelevantExtensionItems(*all_items,
                                     *can_cross_incognito);
 
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index 95ed97f..8cc4542 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -178,11 +178,11 @@
     content::WindowedNotificationObserver load_signal(
         chrome::NOTIFICATION_EXTENSION_LOADED,
         content::Source<Profile>(profile()));
-    CHECK(!extension_util::IsIncognitoEnabled(extension_id, service) ||
+    CHECK(!extensions::util::IsIncognitoEnabled(extension_id, profile()) ||
           extension->force_incognito_enabled());
 
     if (flags & kFlagEnableIncognito) {
-      extension_util::SetIsIncognitoEnabled(extension_id, service, true);
+      extensions::util::SetIsIncognitoEnabled(extension_id, profile(), true);
       load_signal.Wait();
       extension = service->GetExtensionById(extension_id, false);
       CHECK(extension) << extension_id << " not found after reloading.";
@@ -193,9 +193,9 @@
     content::WindowedNotificationObserver load_signal(
         chrome::NOTIFICATION_EXTENSION_LOADED,
         content::Source<Profile>(profile()));
-    CHECK(extension_util::AllowFileAccess(extension, service));
+    CHECK(extensions::util::AllowFileAccess(extension_id, profile()));
     if (!(flags & kFlagEnableFileAccess)) {
-      extension_util::SetAllowFileAccess(extension, service, false);
+      extensions::util::SetAllowFileAccess(extension_id, profile(), false);
       load_signal.Wait();
       extension = service->GetExtensionById(extension_id, false);
       CHECK(extension) << extension_id << " not found after reloading.";
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index f628d3d..17da794b 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -370,8 +370,8 @@
   }
   function_ui->set_dispatcher(AsWeakPtr());
   function_ui->set_context(browser_context_);
-  function->set_include_incognito(extension_util::CanCrossIncognito(extension,
-                                                                    service));
+  function->set_include_incognito(
+      extensions::util::CanCrossIncognito(extension, browser_context_));
 
   if (!CheckPermissions(function.get(), extension, params, callback))
     return;
diff --git a/chrome/browser/extensions/extension_functional_browsertest.cc b/chrome/browser/extensions/extension_functional_browsertest.cc
index cf43c56..cf54b50 100644
--- a/chrome/browser/extensions/extension_functional_browsertest.cc
+++ b/chrome/browser/extensions/extension_functional_browsertest.cc
@@ -63,8 +63,7 @@
   // Verify that the extension is enabled and allowed in incognito
   // is disabled.
   EXPECT_TRUE(service->IsExtensionEnabled(last_loaded_extension_id()));
-  EXPECT_FALSE(
-      extension_util::IsIncognitoEnabled(last_loaded_extension_id(), service));
+  EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
 }
 
 IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest, TestSetExtensionsState) {
@@ -72,30 +71,24 @@
   InstallExtensionSilently(service, "google_talk.crx");
 
   // Disable the extension and verify.
-  extension_util::SetIsIncognitoEnabled(
-      last_loaded_extension_id(), service, false);
+  util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false);
   service->DisableExtension(last_loaded_extension_id(),
                             Extension::DISABLE_USER_ACTION);
   EXPECT_FALSE(service->IsExtensionEnabled(last_loaded_extension_id()));
 
   // Enable the extension and verify.
-  extension_util::SetIsIncognitoEnabled(
-      last_loaded_extension_id(), service, false);
+  util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false);
   service->EnableExtension(last_loaded_extension_id());
   EXPECT_TRUE(service->IsExtensionEnabled(last_loaded_extension_id()));
 
   // Allow extension in incognito mode and verify.
   service->EnableExtension(last_loaded_extension_id());
-  extension_util::SetIsIncognitoEnabled(
-      last_loaded_extension_id(), service, true);
-  EXPECT_TRUE(
-      extension_util::IsIncognitoEnabled(last_loaded_extension_id(), service));
+  util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), true);
+  EXPECT_TRUE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
 
   // Disallow extension in incognito mode and verify.
   service->EnableExtension(last_loaded_extension_id());
-  extension_util::SetIsIncognitoEnabled(
-      last_loaded_extension_id(), service, false);
-  EXPECT_FALSE(
-      extension_util::IsIncognitoEnabled(last_loaded_extension_id(), service));
+  util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false);
+  EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
 }
 }  // namespace extensions
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 8c1759b..5aac4e5 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2211,7 +2211,7 @@
   // only used for idle updates.
   if ((reason == extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE ||
        reason == extensions::ExtensionPrefs::DELAY_REASON_NONE) &&
-       is_ready() && !extension_util::IsExtensionIdle(extension_id, system_))
+       is_ready() && !extensions::util::IsExtensionIdle(extension_id, profile_))
     return;
 
   const Extension* extension = delayed_installs_.GetByID(extension_id);
@@ -2670,7 +2670,7 @@
         extension_id, kOnUpdateAvailableEvent);
   } else {
     // Delay installation if the extension is not idle.
-    return !extension_util::IsExtensionIdle(extension_id, system_);
+    return !extensions::util::IsExtensionIdle(extension_id, profile_);
   }
 }
 
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 5134473..78a196ee 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -2978,7 +2978,7 @@
   // Disable it and allow it to run in incognito. These settings should carry
   // over to the updated version.
   service_->DisableExtension(good->id(), Extension::DISABLE_USER_ACTION);
-  extension_util::SetIsIncognitoEnabled(good->id(), service_, true);
+  extensions::util::SetIsIncognitoEnabled(good->id(), profile_.get(), true);
   service_->extension_prefs()->SetDidExtensionEscalatePermissions(good, true);
 
   path = data_dir_.AppendASCII("good2.crx");
@@ -2986,7 +2986,8 @@
   ASSERT_EQ(1u, service_->disabled_extensions()->size());\
   const Extension* good2 = service_->GetExtensionById(good_crx, true);
   ASSERT_EQ("1.0.0.1", good2->version()->GetString());
-  EXPECT_TRUE(extension_util::IsIncognitoEnabled(good2->id(), service_));
+  EXPECT_TRUE(extensions::util::IsIncognitoEnabled(
+      good2->id(), profile_.get()));
   EXPECT_TRUE(service_->extension_prefs()->DidExtensionEscalatePermissions(
       good2->id()));
 }
@@ -3240,7 +3241,8 @@
   EXPECT_FALSE(
       service_->extension_prefs()->IsExtensionDisabled(extension->id()));
   EXPECT_TRUE(service_->IsExtensionEnabled(extension->id()));
-  EXPECT_FALSE(extension_util::IsIncognitoEnabled(extension->id(), service_));
+  EXPECT_FALSE(extensions::util::IsIncognitoEnabled(extension->id(),
+                                                    profile_.get()));
 }
 
 // Test updating a pending CRX as if the source is an external extension
@@ -5470,7 +5472,7 @@
   EXPECT_EQ(extension->id(), data.id());
   EXPECT_FALSE(data.uninstalled());
   EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled());
-  EXPECT_EQ(extension_util::IsIncognitoEnabled(good_crx, service_),
+  EXPECT_EQ(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()),
             data.incognito_enabled());
   EXPECT_TRUE(data.version().Equals(*extension->version()));
   EXPECT_EQ(extensions::ManifestURL::GetUpdateURL(extension),
@@ -5499,7 +5501,7 @@
   EXPECT_EQ(extension->id(), data.id());
   EXPECT_FALSE(data.uninstalled());
   EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled());
-  EXPECT_EQ(extension_util::IsIncognitoEnabled(good_crx, service_),
+  EXPECT_EQ(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()),
             data.incognito_enabled());
   EXPECT_TRUE(data.version().Equals(*extension->version()));
   EXPECT_EQ(extensions::ManifestURL::GetUpdateURL(extension),
@@ -5558,7 +5560,7 @@
     EXPECT_FALSE(data.incognito_enabled());
   }
 
-  extension_util::SetIsIncognitoEnabled(good_crx, service_, true);
+  extensions::util::SetIsIncognitoEnabled(good_crx, profile_.get(), true);
   {
     syncer::SyncDataList list = extension_sync_service_->GetAllSyncData(
         syncer::EXTENSIONS);
@@ -5837,7 +5839,7 @@
 
   InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
   EXPECT_TRUE(service_->IsExtensionEnabled(good_crx));
-  EXPECT_FALSE(extension_util::IsIncognitoEnabled(good_crx, service_));
+  EXPECT_FALSE(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
 
   sync_pb::EntitySpecifics specifics;
   sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
@@ -5856,7 +5858,8 @@
     list[0] = sync_change;
     extension_sync_service_->ProcessSyncChanges(FROM_HERE, list);
     EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
-    EXPECT_FALSE(extension_util::IsIncognitoEnabled(good_crx, service_));
+    EXPECT_FALSE(
+        extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
   }
 
   {
@@ -5871,7 +5874,7 @@
     list[0] = sync_change;
     extension_sync_service_->ProcessSyncChanges(FROM_HERE, list);
     EXPECT_TRUE(service_->IsExtensionEnabled(good_crx));
-    EXPECT_TRUE(extension_util::IsIncognitoEnabled(good_crx, service_));
+    EXPECT_TRUE(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
   }
 
   {
@@ -5886,7 +5889,7 @@
     list[0] = sync_change;
     extension_sync_service_->ProcessSyncChanges(FROM_HERE, list);
     EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
-    EXPECT_TRUE(extension_util::IsIncognitoEnabled(good_crx, service_));
+    EXPECT_TRUE(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
   }
 
   EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx));
@@ -5904,7 +5907,7 @@
   InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
   TerminateExtension(good_crx);
   EXPECT_TRUE(service_->IsExtensionEnabled(good_crx));
-  EXPECT_FALSE(extension_util::IsIncognitoEnabled(good_crx, service_));
+  EXPECT_FALSE(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
 
   sync_pb::EntitySpecifics specifics;
   sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
@@ -5923,7 +5926,7 @@
 
   extension_sync_service_->ProcessSyncChanges(FROM_HERE, list);
   EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
-  EXPECT_TRUE(extension_util::IsIncognitoEnabled(good_crx, service_));
+  EXPECT_TRUE(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
 
   EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx));
 }
@@ -5939,7 +5942,7 @@
 
   InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
   EXPECT_TRUE(service_->IsExtensionEnabled(good_crx));
-  EXPECT_FALSE(extension_util::IsIncognitoEnabled(good_crx, service_));
+  EXPECT_FALSE(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
 
   sync_pb::EntitySpecifics specifics;
   sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
@@ -6022,11 +6025,11 @@
 
 
   EXPECT_TRUE(service_->IsExtensionEnabled(good_crx));
-  EXPECT_FALSE(extension_util::IsIncognitoEnabled(good_crx, service_));
+  EXPECT_FALSE(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
   extension_sync_service_->ProcessSyncChanges(FROM_HERE, list);
   EXPECT_TRUE(service_->updater()->WillCheckSoon());
   EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
-  EXPECT_TRUE(extension_util::IsIncognitoEnabled(good_crx, service_));
+  EXPECT_TRUE(extensions::util::IsIncognitoEnabled(good_crx, profile_.get()));
 
   const extensions::PendingExtensionInfo* info;
   EXPECT_TRUE((info = service_->pending_extension_manager()->
diff --git a/chrome/browser/extensions/extension_startup_browsertest.cc b/chrome/browser/extensions/extension_startup_browsertest.cc
index 15404c9..176962e 100644
--- a/chrome/browser/extensions/extension_startup_browsertest.cc
+++ b/chrome/browser/extensions/extension_startup_browsertest.cc
@@ -26,6 +26,7 @@
 #include "content/public/browser/notification_service.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/test/browser_test_utils.h"
+#include "extensions/browser/extension_registry.h"
 #include "extensions/common/extension.h"
 #include "extensions/common/extension_set.h"
 #include "extensions/common/feature_switch.h"
@@ -99,9 +100,10 @@
     int found_extensions = 0;
     for (extensions::ExtensionSet::const_iterator it =
              service->extensions()->begin();
-         it != service->extensions()->end(); ++it)
+         it != service->extensions()->end(); ++it) {
       if ((*it)->location() != extensions::Manifest::COMPONENT)
         found_extensions++;
+    }
 
     ASSERT_EQ(static_cast<uint32>(num_expected_extensions),
               static_cast<uint32>(found_extensions));
@@ -186,14 +188,14 @@
   // doing so reloads them.
   std::vector<const extensions::Extension*> extension_list;
 
-  ExtensionService* service = extensions::ExtensionSystem::Get(
-      browser()->profile())->extension_service();
+  extensions::ExtensionRegistry* registry =
+      extensions::ExtensionRegistry::Get(browser()->profile());
   for (extensions::ExtensionSet::const_iterator it =
-           service->extensions()->begin();
-       it != service->extensions()->end(); ++it) {
+           registry->enabled_extensions().begin();
+       it != registry->enabled_extensions().end(); ++it) {
     if ((*it)->location() == extensions::Manifest::COMPONENT)
       continue;
-    if (extension_util::AllowFileAccess(it->get(), service))
+    if (extensions::util::AllowFileAccess((*it)->id(), browser()->profile()))
       extension_list.push_back(it->get());
   }
 
@@ -201,7 +203,8 @@
     content::WindowedNotificationObserver user_scripts_observer(
         chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
         content::NotificationService::AllSources());
-    extension_util::SetAllowFileAccess(extension_list[i], service, false);
+    extensions::util::SetAllowFileAccess(
+        extension_list[i]->id(), browser()->profile(), false);
     user_scripts_observer.Wait();
   }
 
diff --git a/chrome/browser/extensions/extension_sync_service.cc b/chrome/browser/extensions/extension_sync_service.cc
index 39ab123..638670b 100644
--- a/chrome/browser/extensions/extension_sync_service.cc
+++ b/chrome/browser/extensions/extension_sync_service.cc
@@ -232,7 +232,7 @@
   return extensions::ExtensionSyncData(
       extension,
       extension_service_->IsExtensionEnabled(extension.id()),
-      extension_util::IsIncognitoEnabled(extension.id(), extension_service_));
+      extensions::util::IsIncognitoEnabled(extension.id(), profile_));
 }
 
 extensions::AppSyncData ExtensionSyncService::GetAppSyncData(
@@ -240,7 +240,7 @@
   return extensions::AppSyncData(
       extension,
       extension_service_->IsExtensionEnabled(extension.id()),
-      extension_util::IsIncognitoEnabled(extension.id(), extension_service_),
+      extensions::util::IsIncognitoEnabled(extension.id(), profile_),
       extension_prefs_->app_sorting()->GetAppLaunchOrdinal(extension.id()),
       extension_prefs_->app_sorting()->GetPageOrdinal(extension.id()),
       extensions::GetLaunchTypePrefValue(extension_prefs_, extension.id()));
@@ -412,8 +412,8 @@
   bool extension_installed = (extension != NULL);
   int result = extension ?
       extension->version()->CompareTo(extension_sync_data.version()) : 0;
-  extension_util::SetIsIncognitoEnabled(
-      id, extension_service_, extension_sync_data.incognito_enabled());
+  extensions::util::SetIsIncognitoEnabled(
+      id, profile_, extension_sync_data.incognito_enabled());
   extension = NULL;  // No longer safe to use.
 
   if (extension_installed) {
diff --git a/chrome/browser/extensions/extension_system.cc b/chrome/browser/extensions/extension_system.cc
index 5138bdc..f5966bcb 100644
--- a/chrome/browser/extensions/extension_system.cc
+++ b/chrome/browser/extensions/extension_system.cc
@@ -427,8 +427,7 @@
     install_time = ExtensionPrefs::Get(profile_)->
         GetInstallTime(extension->id());
   }
-  bool incognito_enabled =
-      extension_util::IsIncognitoEnabled(extension->id(), extension_service());
+  bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_);
 
   bool notifications_disabled = false;
 #if defined(ENABLE_NOTIFICATIONS)
diff --git a/chrome/browser/extensions/extension_toolbar_model.cc b/chrome/browser/extensions/extension_toolbar_model.cc
index d4946fb..b9d7611 100644
--- a/chrome/browser/extensions/extension_toolbar_model.cc
+++ b/chrome/browser/extensions/extension_toolbar_model.cc
@@ -413,12 +413,10 @@
 
 int ExtensionToolbarModel::IncognitoIndexToOriginal(int incognito_index) {
   int original_index = 0, i = 0;
-  ExtensionService* extension_service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
   for (ExtensionList::iterator iter = toolbar_items_.begin();
        iter != toolbar_items_.end();
        ++iter, ++original_index) {
-    if (extension_util::IsIncognitoEnabled((*iter)->id(), extension_service)) {
+    if (extensions::util::IsIncognitoEnabled((*iter)->id(), profile_)) {
       if (incognito_index == i)
         break;
       ++i;
@@ -429,14 +427,12 @@
 
 int ExtensionToolbarModel::OriginalIndexToIncognito(int original_index) {
   int incognito_index = 0, i = 0;
-  ExtensionService* extension_service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
   for (ExtensionList::iterator iter = toolbar_items_.begin();
        iter != toolbar_items_.end();
        ++iter, ++i) {
     if (original_index == i)
       break;
-    if (extension_util::IsIncognitoEnabled((*iter)->id(), extension_service))
+    if (extensions::util::IsIncognitoEnabled((*iter)->id(), profile_))
       ++incognito_index;
   }
   return incognito_index;
diff --git a/chrome/browser/extensions/extension_util.cc b/chrome/browser/extensions/extension_util.cc
index 3f3d8bea..3b53e5e 100644
--- a/chrome/browser/extensions/extension_util.cc
+++ b/chrome/browser/extensions/extension_util.cc
@@ -8,6 +8,7 @@
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/extensions/extension_sync_service.h"
 #include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/profiles/profile.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/extensions/sync_helper.h"
 #include "content/public/browser/site_instance.h"
@@ -17,46 +18,49 @@
 #include "extensions/common/manifest.h"
 #include "extensions/common/manifest_handlers/incognito_info.h"
 
-using extensions::Extension;
-using extensions::ExtensionPrefs;
-using extensions::ExtensionRegistry;
-
-namespace extension_util {
+namespace extensions {
+namespace util {
 
 bool IsIncognitoEnabled(const std::string& extension_id,
-                        const ExtensionService* service) {
-  if (!service)
-    return false;
+                        content::BrowserContext* context) {
+  const Extension* extension = ExtensionRegistry::Get(context)->
+      GetExtensionById(extension_id, ExtensionRegistry::ENABLED);
+  if (extension) {
+    if (!extension->can_be_incognito_enabled())
+      return false;
+    // If this is an existing component extension we always allow it to
+    // work in incognito mode.
+    if (extension->location() == Manifest::COMPONENT)
+      return true;
+    if (extension->force_incognito_enabled())
+      return true;
+  }
 
-  const Extension* extension = service->GetInstalledExtension(extension_id);
-  if (extension && !extension->can_be_incognito_enabled())
-    return false;
-  // If this is an existing component extension we always allow it to
-  // work in incognito mode.
-  if (extension && extension->location() == extensions::Manifest::COMPONENT)
-    return true;
-  if (extension && extension->force_incognito_enabled())
-    return true;
-
-  // Check the prefs.
-  return service->extension_prefs()->IsIncognitoEnabled(extension_id);
+  return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id);
 }
 
 void SetIsIncognitoEnabled(const std::string& extension_id,
-                           ExtensionService* service,
+                           content::BrowserContext* context,
                            bool enabled) {
+  ExtensionService* service =
+      ExtensionSystem::GetForBrowserContext(context)->extension_service();
+  CHECK(service);
   const Extension* extension = service->GetInstalledExtension(extension_id);
-  if (extension && !extension->can_be_incognito_enabled())
-    return;
-  if (extension && extension->location() == extensions::Manifest::COMPONENT) {
-    // This shouldn't be called for component extensions unless it is called
-    // by sync, for syncable component extensions.
-    // See http://crbug.com/112290 and associated CLs for the sordid history.
-    DCHECK(extensions::sync_helper::IsSyncable(extension));
 
-    // If we are here, make sure the we aren't trying to change the value.
-    DCHECK_EQ(enabled, IsIncognitoEnabled(extension_id, service));
-    return;
+  if (extension) {
+    if (!extension->can_be_incognito_enabled())
+      return;
+
+    if (extension->location() == Manifest::COMPONENT) {
+      // This shouldn't be called for component extensions unless it is called
+      // by sync, for syncable component extensions.
+      // See http://crbug.com/112290 and associated CLs for the sordid history.
+      DCHECK(sync_helper::IsSyncable(extension));
+
+      // If we are here, make sure the we aren't trying to change the value.
+      DCHECK_EQ(enabled, IsIncognitoEnabled(extension_id, service->profile()));
+      return;
+    }
   }
 
   ExtensionPrefs* extension_prefs = service->extension_prefs();
@@ -86,99 +90,88 @@
 }
 
 bool CanCrossIncognito(const Extension* extension,
-                       const ExtensionService* service) {
+                       content::BrowserContext* context) {
   // We allow the extension to see events and data from another profile iff it
   // uses "spanning" behavior and it has incognito access. "split" mode
   // extensions only see events for a matching profile.
   CHECK(extension);
-  return extension_util::IsIncognitoEnabled(extension->id(), service) &&
-         !extensions::IncognitoInfo::IsSplitMode(extension);
+  return IsIncognitoEnabled(extension->id(), context) &&
+         !IncognitoInfo::IsSplitMode(extension);
 }
 
 bool CanLoadInIncognito(const Extension* extension,
-                        const ExtensionService* service) {
+                        content::BrowserContext* context) {
+  CHECK(extension);
   if (extension->is_hosted_app())
     return true;
   // Packaged apps and regular extensions need to be enabled specifically for
   // incognito (and split mode should be set).
-  return extensions::IncognitoInfo::IsSplitMode(extension) &&
-         extension_util::IsIncognitoEnabled(extension->id(), service);
+  return IncognitoInfo::IsSplitMode(extension) &&
+         IsIncognitoEnabled(extension->id(), context);
 }
 
-bool AllowFileAccess(const Extension* extension,
-                     const ExtensionService* service) {
-  return (CommandLine::ForCurrentProcess()->HasSwitch(
-              switches::kDisableExtensionsFileAccessCheck) ||
-          service->extension_prefs()->AllowFileAccess(extension->id()));
+bool AllowFileAccess(const std::string& extension_id,
+                     content::BrowserContext* context) {
+  return CommandLine::ForCurrentProcess()->HasSwitch(
+             switches::kDisableExtensionsFileAccessCheck) ||
+         ExtensionPrefs::Get(context)->AllowFileAccess(extension_id);
 }
 
-void SetAllowFileAccess(const Extension* extension,
-                        ExtensionService* service,
+void SetAllowFileAccess(const std::string& extension_id,
+                        content::BrowserContext* context,
                         bool allow) {
+  ExtensionService* service =
+      ExtensionSystem::GetForBrowserContext(context)->extension_service();
+  CHECK(service);
+
   // Reload to update browser state. Only bother if the value changed and the
   // extension is actually enabled, since there is no UI otherwise.
-  bool old_allow = AllowFileAccess(extension, service);
-  if (allow == old_allow)
+  if (allow == AllowFileAccess(extension_id, context))
     return;
 
-  service->extension_prefs()->SetAllowFileAccess(extension->id(), allow);
+  service->extension_prefs()->SetAllowFileAccess(extension_id, allow);
 
-  bool extension_is_enabled = service->extensions()->Contains(extension->id());
+  bool extension_is_enabled = service->extensions()->Contains(extension_id);
   if (extension_is_enabled)
-    service->ReloadExtension(extension->id());
+    service->ReloadExtension(extension_id);
 }
 
 bool IsAppLaunchable(const std::string& extension_id,
-                     const ExtensionService* service) {
-  return !(service->extension_prefs()->GetDisableReasons(extension_id) &
+                     content::BrowserContext* context) {
+  return !(ExtensionPrefs::Get(context)->GetDisableReasons(extension_id) &
            Extension::DISABLE_UNSUPPORTED_REQUIREMENT);
 }
 
 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id,
-                                    const ExtensionService* service) {
-  ExtensionRegistry* registry =
-      ExtensionRegistry::Get(service->GetBrowserContext());
-  const Extension* launchable_extension = registry->GetExtensionById(
-      extension_id, ExtensionRegistry::ENABLED);
-  return launchable_extension != NULL;
+                                    content::BrowserContext* context) {
+  return ExtensionRegistry::Get(context)->GetExtensionById(
+      extension_id, ExtensionRegistry::ENABLED) != NULL;
 }
 
 bool IsExtensionIdle(const std::string& extension_id,
-                     extensions::ExtensionSystem* extension_system) {
-  DCHECK(extension_system);
-  extensions::ProcessManager* process_manager =
-      extension_system->process_manager();
+                     content::BrowserContext* context) {
+  ProcessManager* process_manager =
+      ExtensionSystem::GetForBrowserContext(context)->process_manager();
   DCHECK(process_manager);
-  extensions::ExtensionHost* host =
+  ExtensionHost* host =
       process_manager->GetBackgroundHostForExtension(extension_id);
   if (host)
     return false;
 
   content::SiteInstance* site_instance = process_manager->GetSiteInstanceForURL(
       Extension::GetBaseURLFromExtensionId(extension_id));
-  if (site_instance && site_instance->HasProcess()) {
+  if (site_instance && site_instance->HasProcess())
     return false;
-  }
 
   return process_manager->GetRenderViewHostsForExtension(extension_id).empty();
 }
 
 bool IsExtensionInstalledPermanently(const std::string& extension_id,
-                                     const ExtensionService* service) {
-  DCHECK(service);
-  const Extension* extension = service->GetInstalledExtension(extension_id);
+                                     content::BrowserContext* context) {
+  const Extension* extension = ExtensionRegistry::Get(context)->
+      GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
   return extension && !extension->is_ephemeral();
 }
 
-bool IsIdleEphemeralApp(const extensions::Extension* extension,
-                        extensions::ExtensionSystem* extension_system) {
-  DCHECK(extension);
-  DCHECK(extension_system);
-
-  if (!extension->is_ephemeral())
-    return false;
-
-  return IsExtensionIdle(extension->id(), extension_system);
-}
-
-}  // namespace extension_util
+}  // namespace util
+}  // namespace extensions
diff --git a/chrome/browser/extensions/extension_util.h b/chrome/browser/extensions/extension_util.h
index 16222f6c..d352993 100644
--- a/chrome/browser/extensions/extension_util.h
+++ b/chrome/browser/extensions/extension_util.h
@@ -7,68 +7,66 @@
 
 #include <string>
 
-namespace extensions {
-class Extension;
-class ExtensionSystem;
+namespace content {
+class BrowserContext;
 }
 
-class ExtensionService;
+namespace extensions {
 
-namespace extension_util {
+class Extension;
 
-// Whether this extension can run in an incognito window.
+namespace util {
+
+// Returns true if |extension_id| can run in an incognito window.
 bool IsIncognitoEnabled(const std::string& extension_id,
-                        const ExtensionService* service);
+                        content::BrowserContext* context);
 
-// Will reload the extension since this permission is applied at loading time
-// only.
+// Sets whether |extension_id| can run in an incognito window. Reloads the
+// extension if it's enabled since this permission is applied at loading time
+// only. Note that an ExtensionService must exist.
 void SetIsIncognitoEnabled(const std::string& extension_id,
-                           ExtensionService* service,
+                           content::BrowserContext* context,
                            bool enabled);
 
-// Returns true if the given extension can see events and data from another
-// sub-profile (incognito to original profile, or vice versa).
+// Returns true if |extension| can see events and data from another sub-profile
+// (incognito to original profile, or vice versa).
 bool CanCrossIncognito(const extensions::Extension* extension,
-                       const ExtensionService* service);
+                       content::BrowserContext* context);
 
-// Returns true if the given extension can be loaded in incognito.
+// Returns true if |extension| can be loaded in incognito.
 bool CanLoadInIncognito(const extensions::Extension* extension,
-                        const ExtensionService* service);
+                        content::BrowserContext* context);
 
-// Whether this extension can inject scripts into pages with file URLs.
-bool AllowFileAccess(const extensions::Extension* extension,
-                     const ExtensionService* service);
+// Returns true if this extension can inject scripts into pages with file URLs.
+bool AllowFileAccess(const std::string& extension_id,
+                     content::BrowserContext* context);
 
-// Will reload the extension since this permission is applied at loading time
-// only.
-void SetAllowFileAccess(const extensions::Extension* extension,
-                        ExtensionService* service,
+// Sets whether |extension_id| can inject scripts into pages with file URLs.
+// Reloads the extension if it's enabled since this permission is applied at
+// loading time only. Note than an ExtensionService must exist.
+void SetAllowFileAccess(const std::string& extension_id,
+                        content::BrowserContext* context,
                         bool allow);
 
-// Whether an app can be launched or not. Apps may require enabling first,
-// but they will still be launchable.
+// Returns true if |extension_id| can be launched (possibly only after being
+// enabled).
 bool IsAppLaunchable(const std::string& extension_id,
-                     const ExtensionService* service);
+                     content::BrowserContext* context);
 
-// Whether an app can be launched without being enabled first.
+// Returns true if |extension_id| can be launched without being enabled first.
 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id,
-                                    const ExtensionService* service);
+                                    content::BrowserContext* context);
 
-// Whether an extension is idle and whether it is safe to perform actions
-// such as updating.
+// Returns true if |extension_id| is idle and it is safe to perform actions such
+// as updating.
 bool IsExtensionIdle(const std::string& extension_id,
-                     extensions::ExtensionSystem* extension_system);
+                     content::BrowserContext* context);
 
-// Whether an extension is installed permanently and not ephemerally.
+// Returns true if |extension_id| is installed permanently and not ephemerally.
 bool IsExtensionInstalledPermanently(const std::string& extension_id,
-                                     const ExtensionService* service);
+                                     content::BrowserContext* context);
 
-// Returns true if the extension is an ephemeral app that is not currently
-// running. Note that this function will always return false if |extension| is
-// not an ephemeral app.
-bool IsIdleEphemeralApp(const extensions::Extension* extension,
-                        extensions::ExtensionSystem* extension_system);
-
-}  // namespace extension_util
+}  // namespace util
+}  // namespace extensions
 
 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_
diff --git a/chrome/browser/extensions/extension_view_host_factory.cc b/chrome/browser/extensions/extension_view_host_factory.cc
index 481aa14e..b791dc0 100644
--- a/chrome/browser/extensions/extension_view_host_factory.cc
+++ b/chrome/browser/extensions/extension_view_host_factory.cc
@@ -47,13 +47,6 @@
   return host;
 }
 
-// Return true if this extension can run in an incognito window.
-bool IsIncognitoEnabled(Profile* profile, const Extension* extension) {
-  ExtensionService* service =
-      ExtensionSystem::Get(profile)->extension_service();
-  return extension_util::IsIncognitoEnabled(extension->id(), service);
-}
-
 // Creates a view host for an extension in an incognito window. Returns NULL
 // if the extension is not allowed to run in incognito.
 ExtensionViewHost* CreateViewHostForIncognito(const Extension* extension,
@@ -72,7 +65,7 @@
   }
 
   // Create the host if the extension can run in incognito.
-  if (IsIncognitoEnabled(profile, extension)) {
+  if (util::IsIncognitoEnabled(extension->id(), profile)) {
     return CreateViewHostForExtension(
         extension, url, profile, browser, view_type);
   }
diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc
index d187a8c..384552a1 100644
--- a/chrome/browser/extensions/extension_web_ui.cc
+++ b/chrome/browser/extensions/extension_web_ui.cc
@@ -224,7 +224,7 @@
     // extension uses split mode.
     bool incognito_override_allowed =
         extensions::IncognitoInfo::IsSplitMode(extension) &&
-        extension_util::IsIncognitoEnabled(extension->id(), service);
+        extensions::util::IsIncognitoEnabled(extension->id(), profile);
     if (profile->IsOffTheRecord() && !incognito_override_allowed) {
       ++i;
       continue;
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc
index ebde012..b3fd8f5 100644
--- a/chrome/browser/extensions/user_script_master.cc
+++ b/chrome/browser/extensions/user_script_master.cc
@@ -379,9 +379,8 @@
       extensions_info_[extension->id()] =
           ExtensionSet::ExtensionPathAndDefaultLocale(
               extension->path(), LocaleInfo::GetDefaultLocale(extension));
-      bool incognito_enabled = extension_util::IsIncognitoEnabled(
-          extension->id(),
-          extensions::ExtensionSystem::Get(profile_)->extension_service());
+      bool incognito_enabled =
+          util::IsIncognitoEnabled(extension->id(), profile_);
       const UserScriptList& scripts =
           ContentScriptsInfo::GetContentScripts(extension);
       for (UserScriptList::const_iterator iter = scripts.begin();
diff --git a/chrome/browser/sync/test/integration/sync_extension_helper.cc b/chrome/browser/sync/test/integration/sync_extension_helper.cc
index ec9efb8..f26120c 100644
--- a/chrome/browser/sync/test/integration/sync_extension_helper.cc
+++ b/chrome/browser/sync/test/integration/sync_extension_helper.cc
@@ -14,6 +14,7 @@
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
 #include "chrome/browser/sync/test/integration/sync_test.h"
+#include "extensions/browser/extension_registry.h"
 #include "extensions/browser/pending_extension_info.h"
 #include "extensions/browser/pending_extension_manager.h"
 #include "extensions/common/extension.h"
@@ -24,6 +25,7 @@
 #include "testing/gtest/include/gtest/gtest.h"
 
 using extensions::Extension;
+using extensions::ExtensionRegistry;
 using extensions::Manifest;
 
 SyncExtensionHelper::ExtensionState::ExtensionState()
@@ -118,20 +120,20 @@
 
 void SyncExtensionHelper::IncognitoEnableExtension(
     Profile* profile, const std::string& name) {
-  extension_util::SetIsIncognitoEnabled(extensions::id_util::GenerateId(name),
-                                        profile->GetExtensionService(), true);
+  extensions::util::SetIsIncognitoEnabled(
+      extensions::id_util::GenerateId(name), profile, true);
 }
 
 void SyncExtensionHelper::IncognitoDisableExtension(
     Profile* profile, const std::string& name) {
-  extension_util::SetIsIncognitoEnabled(extensions::id_util::GenerateId(name),
-                                        profile->GetExtensionService(), false);
+  extensions::util::SetIsIncognitoEnabled(
+      extensions::id_util::GenerateId(name), profile, false);
 }
 
 bool SyncExtensionHelper::IsIncognitoEnabled(
     Profile* profile, const std::string& name) const {
-  return extension_util::IsIncognitoEnabled(
-      extensions::id_util::GenerateId(name), profile->GetExtensionService());
+  return extensions::util::IsIncognitoEnabled(
+      extensions::id_util::GenerateId(name), profile);
 }
 
 
@@ -199,7 +201,7 @@
         ExtensionState::ENABLED :
         ExtensionState::DISABLED;
     extension_state_map[id].incognito_enabled =
-        extension_util::IsIncognitoEnabled(id, extension_service);
+        extensions::util::IsIncognitoEnabled(id, profile);
 
     DVLOG(2) << "Extension " << (*it)->id() << " in profile "
              << profile_debug_name << " is "
@@ -217,7 +219,7 @@
   for (id = pending_crx_ids.begin(); id != pending_crx_ids.end(); ++id) {
     extension_state_map[*id].enabled_state = ExtensionState::PENDING;
     extension_state_map[*id].incognito_enabled =
-        extension_util::IsIncognitoEnabled(*id, extension_service);
+        extensions::util::IsIncognitoEnabled(*id, profile);
     DVLOG(2) << "Extension " << *id << " in profile "
              << profile_debug_name << " is pending";
   }
diff --git a/chrome/browser/ui/app_list/app_list_controller_delegate.cc b/chrome/browser/ui/app_list/app_list_controller_delegate.cc
index af06152..01509cca 100644
--- a/chrome/browser/ui/app_list/app_list_controller_delegate.cc
+++ b/chrome/browser/ui/app_list/app_list_controller_delegate.cc
@@ -110,10 +110,8 @@
 bool AppListControllerDelegate::HasOptionsPage(
     Profile* profile,
     const std::string& app_id) {
-  const ExtensionService* service =
-      extensions::ExtensionSystem::Get(profile)->extension_service();
   const extensions::Extension* extension = GetExtension(profile, app_id);
-  return extension_util::IsAppLaunchableWithoutEnabling(app_id, service) &&
+  return extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile) &&
          extension &&
          !extensions::ManifestURL::GetOptionsPage(extension).is_empty();
 }
diff --git a/chrome/browser/ui/app_list/extension_app_item.cc b/chrome/browser/ui/app_list/extension_app_item.cc
index 033f7a1..44740b1 100644
--- a/chrome/browser/ui/app_list/extension_app_item.cc
+++ b/chrome/browser/ui/app_list/extension_app_item.cc
@@ -133,10 +133,7 @@
   }
   gfx::ImageSkia icon = icon_->image_skia();
 
-  const ExtensionService* service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
-  const bool enabled = extension_util::IsAppLaunchable(extension_id_, service);
-  if (!enabled) {
+  if (!extensions::util::IsAppLaunchable(extension_id_, profile_)) {
     const color_utils::HSL shift = {-1, 0, 0.6};
     icon = gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift);
   }
@@ -196,9 +193,7 @@
 }
 
 bool ExtensionAppItem::RunExtensionEnableFlow() {
-  const ExtensionService* service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
-  if (extension_util::IsAppLaunchableWithoutEnabling(extension_id_, service))
+  if (extensions::util::IsAppLaunchableWithoutEnabling(extension_id_, profile_))
     return false;
 
   if (!extension_enable_flow_) {
diff --git a/chrome/browser/ui/app_list/search/app_result.cc b/chrome/browser/ui/app_list/search/app_result.cc
index c8f22ca9..12bb589e 100644
--- a/chrome/browser/ui/app_list/search/app_result.cc
+++ b/chrome/browser/ui/app_list/search/app_result.cc
@@ -131,9 +131,7 @@
 }
 
 bool AppResult::RunExtensionEnableFlow() {
-  const ExtensionService* service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
-  if (extension_util::IsAppLaunchableWithoutEnabling(app_id_, service))
+  if (extensions::util::IsAppLaunchableWithoutEnabling(app_id_, profile_))
     return false;
 
   if (!extension_enable_flow_) {
@@ -150,10 +148,7 @@
 void AppResult::UpdateIcon() {
   gfx::ImageSkia icon = icon_->image_skia();
 
-  const ExtensionService* service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
-  const bool can_launch = extension_util::IsAppLaunchable(app_id_, service);
-  if (!can_launch) {
+  if (!extensions::util::IsAppLaunchable(app_id_, profile_)) {
     const color_utils::HSL shift = {-1, 0, 0.6};
     icon = gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift);
   }
diff --git a/chrome/browser/ui/app_list/search/app_search_provider.cc b/chrome/browser/ui/app_list/search/app_search_provider.cc
index 6f6e68b4d..d977633 100644
--- a/chrome/browser/ui/app_list/search/app_search_provider.cc
+++ b/chrome/browser/ui/app_list/search/app_search_provider.cc
@@ -78,8 +78,7 @@
 
 void AppSearchProvider::Stop() {}
 
-void AppSearchProvider::AddApps(const extensions::ExtensionSet& extensions,
-                                ExtensionService* service) {
+void AppSearchProvider::AddApps(const extensions::ExtensionSet& extensions) {
   for (extensions::ExtensionSet::const_iterator iter = extensions.begin();
        iter != extensions.end(); ++iter) {
     const extensions::Extension* app = iter->get();
@@ -88,24 +87,18 @@
       continue;
 
     if (profile_->IsOffTheRecord() &&
-        !extension_util::CanLoadInIncognito(app, service))
+        !extensions::util::CanLoadInIncognito(app, profile_))
       continue;
     apps_.push_back(new App(app));
   }
 }
 
 void AppSearchProvider::RefreshApps() {
-  ExtensionService* extension_service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
-  if (!extension_service)
-    return;  // During testing, there is no extension service.
-
   apps_.clear();
-
   ExtensionRegistry* registry = ExtensionRegistry::Get(profile_);
-  AddApps(registry->enabled_extensions(), extension_service);
-  AddApps(registry->disabled_extensions(), extension_service);
-  AddApps(registry->terminated_extensions(), extension_service);
+  AddApps(registry->enabled_extensions());
+  AddApps(registry->disabled_extensions());
+  AddApps(registry->terminated_extensions());
 }
 
 void AppSearchProvider::Observe(int type,
diff --git a/chrome/browser/ui/app_list/search/app_search_provider.h b/chrome/browser/ui/app_list/search/app_search_provider.h
index 5fe3762..9106a2b 100644
--- a/chrome/browser/ui/app_list/search/app_search_provider.h
+++ b/chrome/browser/ui/app_list/search/app_search_provider.h
@@ -37,8 +37,7 @@
   typedef ScopedVector<App> Apps;
 
   // Adds extensions to apps container if they should be displayed.
-  void AddApps(const extensions::ExtensionSet& extensions,
-               ExtensionService* service);
+  void AddApps(const extensions::ExtensionSet& extensions);
   void RefreshApps();
 
   // content::NotificationObserver overrides:
diff --git a/chrome/browser/ui/app_list/search/webstore/webstore_result.cc b/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
index eae687b..bbb806c 100644
--- a/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
+++ b/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
@@ -127,8 +127,8 @@
   Actions actions;
 
   const bool is_otr = profile_->IsOffTheRecord();
-  const bool is_installed = extension_util::IsExtensionInstalledPermanently(
-      app_id_, extensions::ExtensionSystem::Get(profile_)->extension_service());
+  const bool is_installed =
+      extensions::util::IsExtensionInstalledPermanently(app_id_, profile_);
 
   if (!is_otr && !is_installed && !is_installing()) {
     if (CommandLine::ForCurrentProcess()->HasSwitch(
diff --git a/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc
index ba86283..acca86f 100644
--- a/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc
@@ -30,9 +30,9 @@
   Profile* const profile = ProfileManager::GetActiveUserProfile();
   const ExtensionService* const service =
       extensions::ExtensionSystem::Get(profile)->extension_service();
-  if (service == NULL ||
-      !extension_util::IsAppLaunchableWithoutEnabling(kFileManagerAppId,
-                                                      service)) {
+  if (!service ||
+      !extensions::util::IsAppLaunchableWithoutEnabling(kFileManagerAppId,
+                                                        profile)) {
     return;
   }
 
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index ccf8e94..c238e02 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -650,9 +650,7 @@
   if (!extension)
     return;
 
-  const ExtensionService* service =
-      extensions::ExtensionSystem::Get(profile_)->extension_service();
-  if (!extension_util::IsAppLaunchableWithoutEnabling(app_id, service)) {
+  if (!extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile_)) {
     // Do nothing if there is already a running enable flow.
     if (extension_enable_flow_)
       return;
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
index f6b435e..20ffd57 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
@@ -780,11 +780,8 @@
 
 - (BOOL)shouldDisplayBrowserAction:(const Extension*)extension {
   // Only display incognito-enabled extensions while in incognito mode.
-  return
-      (!profile_->IsOffTheRecord() ||
-       extension_util::IsIncognitoEnabled(
-          extension->id(),
-          extensions::ExtensionSystem::Get(profile_)->extension_service()));
+  return !profile_->IsOffTheRecord() ||
+      extensions::util::IsIncognitoEnabled(extension->id(), profile_);
 }
 
 - (void)showChevronIfNecessaryInFrame:(NSRect)frame animate:(BOOL)animate {
diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
index 2df92c0..5f2a45c 100644
--- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
@@ -702,7 +702,7 @@
     const Extension* extension) {
   // Only display incognito-enabled extensions while in incognito mode.
   return (!profile_->IsOffTheRecord() ||
-          extension_util:: IsIncognitoEnabled(
+          extensions::util::IsIncognitoEnabled(
               extension->id(),
               extensions::ExtensionSystem::Get(profile_)->extension_service()));
 }
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.cc b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
index 24e79e1..1d8cb91 100644
--- a/chrome/browser/ui/views/toolbar/browser_actions_container.cc
+++ b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
@@ -830,11 +830,8 @@
 bool BrowserActionsContainer::ShouldDisplayBrowserAction(
     const Extension* extension) {
   // Only display incognito-enabled extensions while in incognito mode.
-  return
-      (!profile_->IsOffTheRecord() ||
-       extension_util::IsIncognitoEnabled(
-           extension->id(),
-           extensions::ExtensionSystem::Get(profile_)->extension_service()));
+  return !profile_->IsOffTheRecord() ||
+      extensions::util::IsIncognitoEnabled(extension->id(), profile_);
 }
 
 bool BrowserActionsContainer::ShowPopup(
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index 520cdbed..2b6b1ac 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -228,13 +228,13 @@
       "terminated",
       registry->terminated_extensions().Contains(extension->id()));
   extension_data->SetBoolean("enabledIncognito",
-      extension_util::IsIncognitoEnabled(extension->id(), extension_service_));
+      util::IsIncognitoEnabled(extension->id(), extension_service_->profile()));
   extension_data->SetBoolean("incognitoCanBeToggled",
                              extension->can_be_incognito_enabled() &&
                              !extension->force_incognito_enabled());
   extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access());
   extension_data->SetBoolean("allowFileAccess",
-      extension_util::AllowFileAccess(extension, extension_service_));
+      util::AllowFileAccess(extension->id(), extension_service_->profile()));
   extension_data->SetBoolean("allow_reload",
       Manifest::IsUnpackedLocation(extension->location()));
   extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app());
@@ -875,9 +875,9 @@
   // Bug: http://crbug.com/41384
   base::AutoReset<bool> auto_reset_ignore_notifications(
       &ignore_notifications_, true);
-  extension_util::SetIsIncognitoEnabled(extension->id(),
-                                        extension_service_,
-                                        enable_str == "true");
+  util::SetIsIncognitoEnabled(extension->id(),
+                              extension_service_->profile(),
+                              enable_str == "true");
 }
 
 void ExtensionSettingsHandler::HandleAllowFileAccessMessage(
@@ -898,8 +898,8 @@
     return;
   }
 
-  extension_util::SetAllowFileAccess(
-      extension, extension_service_, allow_str == "true");
+  util::SetAllowFileAccess(
+      extension_id, extension_service_->profile(), allow_str == "true");
 }
 
 void ExtensionSettingsHandler::HandleUninstallMessage(
@@ -1114,7 +1114,8 @@
   // shell windows for incognito processes.
   if (extension_service_->profile()->HasOffTheRecordProfile() &&
       IncognitoInfo::IsSplitMode(extension) &&
-      extension_util::IsIncognitoEnabled(extension->id(), extension_service_)) {
+      util::IsIncognitoEnabled(extension->id(),
+                               extension_service_->profile())) {
     extensions::ProcessManager* process_manager =
         ExtensionSystem::Get(extension_service_->profile()->
             GetOffTheRecordProfile())->process_manager();
diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc
index 763b3ff..fa35304 100644
--- a/extensions/browser/event_router.cc
+++ b/extensions/browser/event_router.cc
@@ -13,7 +13,6 @@
 #include "base/values.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/extensions/extension_system.h"
 #include "chrome/browser/extensions/extension_util.h"
 #include "chrome/common/extensions/extension_messages.h"
@@ -564,9 +563,7 @@
                          context != event->restrict_to_browser_context;
   if (!cross_incognito)
     return true;
-  ExtensionService* service =
-      ExtensionSystem::GetForBrowserContext(context)->extension_service();
-  return extension_util::CanCrossIncognito(extension, service);
+  return util::CanCrossIncognito(extension, context);
 }
 
 bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent(
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc
index fed3369..217d389b 100644
--- a/extensions/browser/process_manager.cc
+++ b/extensions/browser/process_manager.cc
@@ -103,9 +103,6 @@
   virtual SiteInstance* GetSiteInstanceForURL(const GURL& url) OVERRIDE;
 
  private:
-  // Returns true if the extension is allowed to run in incognito mode.
-  bool IsIncognitoEnabled(const Extension* extension);
-
   ProcessManager* original_manager_;
 
   DISALLOW_COPY_AND_ASSIGN(IncognitoProcessManager);
@@ -873,7 +870,7 @@
 ExtensionHost* IncognitoProcessManager::CreateBackgroundHost(
     const Extension* extension, const GURL& url) {
   if (IncognitoInfo::IsSplitMode(extension)) {
-    if (IsIncognitoEnabled(extension))
+    if (util::IsIncognitoEnabled(extension->id(), GetBrowserContext()))
       return ProcessManager::CreateBackgroundHost(extension, url);
   } else {
     // Do nothing. If an extension is spanning, then its original-profile
@@ -894,11 +891,4 @@
   return ProcessManager::GetSiteInstanceForURL(url);
 }
 
-bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) {
-  // Keep in sync with duplicate in extension_info_map.cc.
-  ExtensionService* service = ExtensionSystem::GetForBrowserContext(
-      GetBrowserContext())->extension_service();
-  return extension_util::IsIncognitoEnabled(extension->id(), service);
-}
-
 }  // namespace extensions