Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2664)

Unified Diff: chrome/browser/supervised_user/supervised_user_interstitial.cc

Issue 1417813004: Don't try to close first-navigation tabs when showing the supervised user interstitial inside a <we… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698