[Native File System] Show page info entry also if site is only reading files.
This lets a user block access to a site without having to first grant the site
write access.
Bug: 990989
Change-Id: Icd2d138f00b69d5435918e98c2d5edc11e090f36
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1736114
Reviewed-by: Balazs Engedy <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Avi Drissman <[email protected]>
Auto-Submit: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/master@{#684543}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 5d0e901..d967f25 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1566,6 +1566,9 @@
return serial_active_frame_count_ > 0;
}
+bool WebContentsImpl::HasNativeFileSystemHandles() {
+ return native_file_system_handle_count_ > 0;
+}
bool WebContentsImpl::HasNativeFileSystemDirectoryHandles() {
return !native_file_system_directory_handles_.empty();
}
@@ -6890,6 +6893,39 @@
NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
}
+void WebContentsImpl::IncrementNativeFileSystemHandleCount() {
+ // Trying to invalidate the tab state while being destroyed could result in a
+ // use after free.
+ if (IsBeingDestroyed())
+ return;
+
+ // Notify for UI updates if the state changes. Need both TYPE_TAB and TYPE_URL
+ // to update both the tab-level usage indicator and the usage indicator in the
+ // omnibox.
+ native_file_system_handle_count_++;
+ if (native_file_system_handle_count_ == 1) {
+ NotifyNavigationStateChanged(static_cast<content::InvalidateTypes>(
+ INVALIDATE_TYPE_TAB | INVALIDATE_TYPE_URL));
+ }
+}
+
+void WebContentsImpl::DecrementNativeFileSystemHandleCount() {
+ // Trying to invalidate the tab state while being destroyed could result in a
+ // use after free.
+ if (IsBeingDestroyed())
+ return;
+
+ // Notify for UI updates if the state changes. Need both TYPE_TAB and TYPE_URL
+ // to update both the tab-level usage indicator and the usage indicator in the
+ // omnibox.
+ DCHECK_NE(0u, native_file_system_handle_count_);
+ native_file_system_handle_count_--;
+ if (native_file_system_handle_count_ == 0) {
+ NotifyNavigationStateChanged(static_cast<content::InvalidateTypes>(
+ INVALIDATE_TYPE_TAB | INVALIDATE_TYPE_URL));
+ }
+}
+
void WebContentsImpl::AddNativeFileSystemDirectoryHandle(
const base::FilePath& path) {
// Trying to invalidate the tab state while being destroyed could result in a