Solve ProfileIOData, Extension, HostContentSettingsMap ordering issue.

There's a chicken/egg/omelette(?) issue during set up:

* ProfilIOData needs to grab HostContentSettingsMap on creation, and it
can be used at any point after creation to create a URLRequestContext,
which can use the HostContentSettingsMap.
* ExtensionSystem needs to modify the HostContentSettingsMap before the
map is used.
* ExtensionSystem needs access to the URLRequestContextGetter, which
ProfileIOData creates, but needs the HostContentSettingsMap before it
can safely create it.

This CL just makes the ExtensionSystem method to hook into
HostContentSettingsMap static, and the map sets up the hook on
construction.  Since the method to set up hooks wasn't depending on any
members of the ExtensionSystem, this should just "work"

This bug has existed a while, but we never ran into DCHECKs as a
result because while the URLRequestContext was potentially being set
up with the HostContentSettingsMap was fully initialized, we generally
weren't issuing network requests until after the ExtensionSystem set
up the map.

https://codereview.chromium.org/2841163002/ changed that, since the
ProxyService may figure out it needs a PAC file and fetch it any time
after the URLRequestContext is created.

BUG=718835

Review-Url: https://codereview.chromium.org/2866613003
Cr-Commit-Position: refs/heads/master@{#471853}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 196834e..8156b795 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2046,21 +2046,27 @@
 }
 
 void ExtensionService::RegisterContentSettings(
-    HostContentSettingsMap* host_content_settings_map) {
+    HostContentSettingsMap* host_content_settings_map,
+    Profile* profile) {
+  // Most extension services key off of the original profile.
+  Profile* original_profile = profile->GetOriginalProfile();
+
   TRACE_EVENT0("browser,startup", "ExtensionService::RegisterContentSettings");
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
   host_content_settings_map->RegisterProvider(
       HostContentSettingsMap::INTERNAL_EXTENSION_PROVIDER,
       std::unique_ptr<content_settings::ObservableProvider>(
-          new content_settings::InternalExtensionProvider(profile_)));
+          new content_settings::InternalExtensionProvider(original_profile)));
 
   host_content_settings_map->RegisterProvider(
       HostContentSettingsMap::CUSTOM_EXTENSION_PROVIDER,
       std::unique_ptr<content_settings::ObservableProvider>(
           new content_settings::CustomExtensionProvider(
-              extensions::ContentSettingsService::Get(profile_)
+              extensions::ContentSettingsService::Get(original_profile)
                   ->content_settings_store(),
-              profile_->GetOriginalProfile() != profile_)));
+              // TODO(mmenke):  CustomExtensionProvider expects this to be true
+              // for incognito profiles.
+              false)));
 }
 
 void ExtensionService::TrackTerminatedExtension(