diff options
author | bauerb <bauerb@chromium.org> | 2015-10-21 08:38:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-21 15:39:10 +0000 |
commit | 34f34c5fe939d8520e5ce59cc31e11cc4b439e75 (patch) | |
tree | 95111e91b976eab4f35d90d80549aeccb2e03232 | |
parent | 8b1432641f74fa80bf1642cc21fff64acc66df74 (diff) | |
download | chromium_src-34f34c5fe939d8520e5ce59cc31e11cc4b439e75.zip chromium_src-34f34c5fe939d8520e5ce59cc31e11cc4b439e75.tar.gz chromium_src-34f34c5fe939d8520e5ce59cc31e11cc4b439e75.tar.bz2 |
Don't try to close first-navigation tabs when showing the supervised user interstitial inside a <webview>.
A WebContents in a <webview> is under the control of the embedding page, so we
can't simply close it (and there isn't a browser or tab strip for it anyway).
BUG=545394
Review URL: https://codereview.chromium.org/1417813004
Cr-Commit-Position: refs/heads/master@{#355300}
-rw-r--r-- | chrome/browser/supervised_user/supervised_user_interstitial.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/chrome/browser/supervised_user/supervised_user_interstitial.cc b/chrome/browser/supervised_user/supervised_user_interstitial.cc index dcb91a2..3810abd 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; } |