Check possibility of browser creation in OpenApplicationTab
extensions::OpenApplicationTab does not check if the browser can be
created or not when the request comes and if it requests browser
creation in an inappropriate condition (like during browser shutdown or
with wrong profile), it leads to a crash.
This is fixed by checking if browser creation is possible beforehand.
Bug: 1261628
Change-Id: Ic00aff5607e086257b038c1a4a82d37779e10a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3245573
Reviewed-by: Ben Wells <benwells@chromium.org>
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/main@{#936273}
diff --git a/chrome/browser/ui/extensions/application_launch.cc b/chrome/browser/ui/extensions/application_launch.cc
index 7876e7c..aec295a7 100644
--- a/chrome/browser/ui/extensions/application_launch.cc
+++ b/chrome/browser/ui/extensions/application_launch.cc
@@ -199,7 +199,11 @@
WebContents* contents = NULL;
if (!browser) {
// No browser for this profile, need to open a new one.
- //
+ if (Browser::GetCreationStatusForProfile(profile) !=
+ Browser::CreationStatus::kOk) {
+ return contents;
+ }
+
// TODO(erg): AppLaunchParams should pass user_gesture from the extension
// system to here.
browser = Browser::Create(