[M120 Migration]Fix for crash during chrome exit
[platform/framework/web/chromium-efl.git] / chrome / browser / universal_web_contents_observers.cc
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/universal_web_contents_observers.h"
6
7 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_part.h"
8
9 #include "extensions/buildflags/buildflags.h"
10
11 #if BUILDFLAG(ENABLE_EXTENSIONS)
12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
13 #endif
14
15 void AttachUniversalWebContentsObservers(content::WebContents* web_contents) {
16   // This function is for attaching *universal* WebContentsObservers - ones that
17   // should be attached to *every* WebContents.  Such universal observers and/or
18   // helpers are relatively rare and therefore only a limited set of observers
19   // should be handled below.
20   //
21   // In particular, helpers handled by TabHelpers::AttachTabHelpers typically
22   // only apply to tabs, but not to other flavors of WebContents.  As pointed
23   // out by //docs/tab_helpers.md there are WebContents that are not tabs
24   // and not every WebContents has (or needs) every tab helper.
25
26 #if BUILDFLAG(ENABLE_EXTENSIONS)
27   if (extensions::ChromeContentBrowserClientExtensionsPart::
28           AreExtensionsDisabledForProfile(web_contents->GetBrowserContext())) {
29     return;
30   }
31
32   extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
33       web_contents);
34 #endif
35 }