Commit a0b7e8ce authored by Olivier Yiptong's avatar Olivier Yiptong Committed by Commit Bot

[Native File System] Exit fullscreen mode when showing permission prompts

When a permission prompt is shown, the user should have the URL bar
visible so that they can make an informed decision before accepting or
denying the request. This change exits fullscreen mode, which would hide
the URL bar, when a permission prompt is shown.

BUG=1007038

Change-Id: I6d2b600390b0297d0711de48b76fa492f16a71b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1854789Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Olivier Yiptong <oyiptong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705605}
parent 2402663e
......@@ -85,6 +85,9 @@ void ShowWritePermissionPromptOnUIThread(
return;
}
// Drop fullscreen mode so that the user sees the URL bar.
web_contents->ForSecurityDropFullscreen();
request_manager->AddRequest(
{origin, path, is_directory},
base::BindOnce(
......@@ -131,6 +134,9 @@ void ShowDirectoryAccessConfirmationPromptOnUIThread(
std::move(callback).Run(PermissionAction::DISMISSED);
}
// Drop fullscreen mode so that the user sees the URL bar.
web_contents->ForSecurityDropFullscreen();
ShowNativeFileSystemDirectoryAccessConfirmationDialog(
origin, path, std::move(callback), web_contents);
}
......
......@@ -16,6 +16,7 @@
#include "chrome/browser/ui/views/page_action/page_action_icon_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/test/browser_test_utils.h"
#include "third_party/blink/public/common/features.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_dialog_factory.h"
......@@ -99,6 +100,12 @@ class NativeFileSystemBrowserTest : public InProcessBrowserTest {
ui::SelectFileDialog::SetFactory(nullptr);
}
bool IsFullscreen() {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
return web_contents->IsFullscreenForCurrentTab();
}
base::FilePath CreateTestFile(const std::string& contents) {
base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath result;
......@@ -215,6 +222,54 @@ IN_PROC_BROWSER_TEST_F(NativeFileSystemBrowserTest, OpenFile) {
}
}
IN_PROC_BROWSER_TEST_F(NativeFileSystemBrowserTest, FullscreenOpenFile) {
const base::FilePath test_file = CreateTestFile("");
const std::string file_contents = "file contents to write";
GURL frame_url = embedded_test_server()->GetURL("/title1.html");
ui::SelectFileDialog::SetFactory(
new FakeSelectFileDialogFactory({test_file}));
ui_test_utils::NavigateToURL(browser(),
embedded_test_server()->GetURL("/title1.html"));
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
NativeFileSystemPermissionRequestManager::FromWebContents(web_contents)
->set_auto_response_for_test(PermissionAction::GRANTED);
EXPECT_EQ(test_file.BaseName().AsUTF8Unsafe(),
content::EvalJs(web_contents,
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'openFile'});"
" self.entry = e;"
" return e.name; })()"));
EXPECT_TRUE(
content::ExecuteScript(web_contents,
"(async () => {"
" await document.body.requestFullscreen();"
"})()"));
// Wait until the fullscreen operation completes.
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(IsFullscreen());
EXPECT_TRUE(content::ExecuteScript(
web_contents,
"(async () => {"
" let fsChangePromise = new Promise((resolve) => {"
" document.onfullscreenchange = resolve;"
" });"
" const w = await self.entry.createWriter();"
" await fsChangePromise;"
" return; })()"));
// Wait until the fullscreen exit operation completes.
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(IsFullscreen());
}
IN_PROC_BROWSER_TEST_F(NativeFileSystemBrowserTest, SafeBrowsing) {
const base::FilePath test_file = temp_dir_.GetPath().AppendASCII("test.exe");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment