Repository: huhu/rust-search-extension (language: rust)

Issue:
Offline mode no longer works in Chrome 118.0.5993.70
### Env

* Chrome: Version 118.0.5993.70 (Official Build) unknown (64-bit)
* Rust Search Extension: 1.12.0
* Host: Fedora 38 Workstation/GNOME 44.5
* Rust: 
    
   ```sh
   $ rustup -V
   rustup 1.26.0 (5af9b9484 2023-04-05)
   info: This is the version for the rustup toolchain manager, not the rustc compiler.
   info: The currently active `rustc` version is `rustc 1.73.0 (cc66ad468 2023-10-03)`
   ```

### Erroneous Behavior

Choose the entry I want to check, press enter, nothing happens

### Steps to reproduce

1. Enable the offline mode with the following path
    
    ```
    file:///home/steve/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc/rust/html/
    ```

    > the path should be right:
    >
    > ```sh
    > $ rustup doc --std --path
    > /home/steve/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc/rust/html/std/index.html
    > ```

2. Open a new tab
3. input `rs`, the a space
4. input `Vec`, choose `std::vec::Vec`, press the enter button

### Workaround I have tried

1. Restart chrome
5. Reinstall the extension

### Demo


[Screencast from 2023-10-16 12-15-17.webm](https://github.com/huhu/rust-search-extension/assets/96880612/603b97db-1fd4-4d5a-8d20-db8314121c18)


Discussion / hints:
Thanks for the feedback. Chrome has restricted access to local file URLs since 118.0, see the announcement and workaround here: https://developer.chrome.com/docs/extensions/whatsnew/#changes-to-file-scheme
Thanks for the response!

Per the announcement, you need to explicitly enable this in

```
chrome://extensions => extension details
```

But I didn't find it on that page :(, please see the screenshot below:

![Screenshot from 2023-10-16 15-45-37](https://github.com/huhu/rust-search-extension/assets/96880612/29f6a379-b4eb-4a03-81c9-006fac11b7c9)



Neither for me to find that setting. 🥲 Maybe you can change to this workaround: https://rust.extension.sh/faq/#why-local-file-rust-doc-not-work-properly-on-firefox
Get it, I don't want to spawn a server just for serving local file accesses so I think I will just use the online doc for the moment, thanks for looking into the issue!
In the post provided by the Chrome announcement I found this [potential solution](https://groups.google.com/a/chromium.org/g/chromium-extensions/c/ZtCvVISQU54/m/Qv_wCnnUAQAJ):

> I ended up adding "optional_host_permissions": [ "file:///*" ]
> This way the "Allow access to file URLs" is shown, navigation works, but I don't actually get read permission.

Maybe we can give it a try?

Fix patch:
diff --git a/core b/core
index 508eab5c..d273f007 160000
--- a/core
+++ b/core
@@ -1,1 +1,1 @@
-Subproject commit 508eab5c66825d4e34a30092f33b9e010351ee0d
+Subproject commit d273f007bc90650a873d142f8d988badfcfae31e
diff --git a/docs/content/_index.md b/docs/content/_index.md
index 226fef36..049e25ca 100644
--- a/docs/content/_index.md
+++ b/docs/content/_index.md
@@ -90,7 +90,7 @@ path is your doc directory.
 
 - For Chrome/Edge users:
   Prepend `file://` before your doc directory, and input it to the input box on the
-  settings page.
+  settings page. Then [enable access to file URLs](https://developer.chrome.com/docs/extensions/develop/concepts/declare-permissions#allow_access_to_file_urls_and_incognito_pages) on the extension's details page.
 
   ![GIF](/offline-mode-chrome.gif)
 
diff --git a/manifest.jsonnet b/manifest.jsonnet
index 34573d30..d10f10e5 100644
--- a/manifest.jsonnet
+++ b/manifest.jsonnet
@@ -15,6 +15,7 @@ local description = 'Rust Search Extension - the ultimate search extension for R
 local browser = std.extVar('browser');
 
 local host_permissions = ['*://crates.io/api/v1/crates/*', 'https://rust.extension.sh/*'];
+local optional_host_permissions = ['file:///*'];
 local json = if std.member(['chrome', 'edge'], browser) then
   local manifest_v3 = import 'core/manifest_v3.libsonnet';
   manifest_v3.new(name, keyword, description, version, service_worker='service-worker.js')
@@ -33,6 +34,7 @@ local json = if std.member(['chrome', 'edge'], browser) then
     [if browser == 'chrome' then 'key' else null]: 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxOX+QfzcFnxPwwmzXDhuU59XGCSMZq+FGo0vOx/ufg/Vw7HfKEPVb9TKzrGtqW38kafWkjxOxGhF7VyyX2ymi55W0xqf8BedePbvMtV6H1tY5bscJ0dLKGH/ZG4T4f645LgvOWOBgyv8s3NDWXzwOMS57ER1y+EtHjDsWD1M0nfe0VCCLW18QlAsNTHfLZk6lUeEeGXZrl6+jK+pZxwhQFmc8cJvOyw7uAq6IJ9lnGDvxFVjGUepA0lKbLuIZjN3p70mgVUIuBYzKE6R8HDk4oBbKAK0HyyKfnuAYbfwVYotHw4def+OW9uADSlZEDC10wwIpU9NoP3szh+vWSnk0QIDAQAB',
   }
   .addHostPermissions(host_permissions)
+  .addOptionalHostPermissions(optional_host_permissions)
 else
   local manifest_v2 = import 'core/manifest.libsonnet';
   manifest_v2.new(name, keyword, description, version)


Test patch: