Fix PermissionObserver OOB access crash

This change fixes a crash caused by an OOB access from the
|chooser_observer_| when removing the observer upon the destruction of
SiteSettingsHandler. The crash occurs when the following conditions are
met.

1. An off the record profile is created.
2. A chooser permission is granted in the off the record profile.
3. The chrome://settings/content page is opened in the main profile
   window.
4. The off the record window is closed.
5. The chrome://settings/content page is closed.

The SiteSettingsHandler will attempt to remove itself from the off the
record ChooserContextBase upon destruction, but the off the record
ChooserContextBase was already destroyed previously, therefore accessing
memory that has already been freed.

This change removes the logic that adds the SiteSettingsHandler to the
off the record ChooserContextBase, since the UI does not actually
display off the record chooser permissions anyways. I created
https://crbug.com/927372 for adding this feature.

Bug: 926501
Change-Id: I87359a3d67020a80b9fb698d5252c320436317de
Reviewed-on: https://chromium-review.googlesource.com/c/1447312
Reviewed-by: Dan Beam <dbeam@chromium.org>
Commit-Queue: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#628468}(cherry picked from commit 15a43eca69de36953bd187b5b4f9595388aa91c2)
Reviewed-on: https://chromium-review.googlesource.com/c/1450224
Reviewed-by: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Cr-Commit-Position: refs/branch-heads/3683@{#161}
Cr-Branched-From: e51029943e0a38dd794b73caaf6373d5496ae783-refs/heads/master@{#625896}
diff --git a/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chrome/browser/ui/webui/settings/site_settings_handler.cc
index 4201c661..9e0d11e 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -1402,15 +1402,14 @@
   if (!profile_->HasOffTheRecordProfile())
     return;
 
+  // At the moment, off the record chooser permissions are not included in the
+  // chooser permissions.
+  // TODO(https://crbug.com/927372): When chooser permissions are included,
+  // attach SiteSettingsHandler as an observer to the chooser contexts.
   auto* map = HostContentSettingsMapFactory::GetForProfile(
       profile_->GetOffTheRecordProfile());
   if (!observer_.IsObserving(map))
     observer_.Add(map);
-
-  auto* usb_context = UsbChooserContextFactory::GetForProfile(
-      profile_->GetOffTheRecordProfile());
-  if (!chooser_observer_.IsObserving(usb_context))
-    chooser_observer_.Add(usb_context);
 }
 
 void SiteSettingsHandler::TreeNodesAdded(ui::TreeModel* model,
diff --git a/chrome/browser/ui/webui/site_settings_helper.cc b/chrome/browser/ui/webui/site_settings_helper.cc
index 9b61a6e..4e03254 100644
--- a/chrome/browser/ui/webui/site_settings_helper.cc
+++ b/chrome/browser/ui/webui/site_settings_helper.cc
@@ -771,6 +771,8 @@
     const ChooserTypeNameEntry& chooser_type) {
   auto exceptions = std::make_unique<base::ListValue>();
 
+  // TODO(https://crbug.com/927372): Combine the off the record permissions with
+  // the main profile permissions so that the UI is able to display them.
   if (incognito) {
     if (!profile->HasOffTheRecordProfile())
       return exceptions;