Index: chrome/browser/supervised_user/supervised_user_interstitial.cc |
diff --git a/chrome/browser/supervised_user/supervised_user_interstitial.cc b/chrome/browser/supervised_user/supervised_user_interstitial.cc |
index dcb91a2660f178437615e74608e2823184a5d592..3810abd57cf49a7de63f616777e8faac15c6222f 100644 |
--- a/chrome/browser/supervised_user/supervised_user_interstitial.cc |
+++ b/chrome/browser/supervised_user/supervised_user_interstitial.cc |
@@ -61,7 +61,20 @@ std::string BuildAvatarImageUrl(const std::string& url, int size) { |
} |
class TabCloser : public content::WebContentsUserData<TabCloser> { |
- // To use, call TabCloser::CreateForWebContents. |
+ public: |
+ static void MaybeClose(WebContents* web_contents) { |
+ // Close the tab if there is no history entry to go back to and there is a |
+ // browser for the tab (which is not the case for example in a <webview>). |
+ if (!web_contents->GetController().IsInitialBlankNavigation()) |
+ return; |
+ |
+#if !defined(OS_ANDROID) |
+ if (!chrome::FindBrowserWithWebContents(web_contents)) |
+ return; |
+#endif |
+ TabCloser::CreateForWebContents(web_contents); |
+ } |
+ |
private: |
friend class content::WebContentsUserData<TabCloser>; |
@@ -305,10 +318,7 @@ void SupervisedUserInterstitial::CommandReceived(const std::string& command) { |
DCHECK(web_contents->GetController().GetTransientEntry()); |
interstitial_page_->DontProceed(); |
- // Close the tab if there is no history entry to go back to. |
- if (web_contents->GetController().IsInitialBlankNavigation()) |
- TabCloser::CreateForWebContents(web_contents); |
- |
+ TabCloser::MaybeClose(web_contents); |
return; |
} |