Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow command line arguments #120

Open
Pebkac03 opened this issue May 5, 2024 · 5 comments
Open

Allow command line arguments #120

Pebkac03 opened this issue May 5, 2024 · 5 comments

Comments

@Pebkac03
Copy link

Pebkac03 commented May 5, 2024

Command line arguments provide a standardized way for customization of chromium and by extension CEF. Allowing the webview widget or controller to accept these as arguments would in my opinion extend the functionality of this package. It would for example provide a solution to issue #87 by allowing the scrollbar to be hidden using: --enable-features=OverlaySrollbar.

I am fairly proficient in Flutter and Dart but almost clueless regarding C languages and CEF. I have however found the following to help anyone wanting to undertake a PR:

CEF accepts command line arguments through the the CefExecuteProcess function which I found in webview_cef/common/webview_plugin.cc on line 61. It gets the parameter from the variable mainArgs which is defined in the initCEFProcesses function on line 47 (not 51) in the same file. From there on the trail runs cold for me but it seems to me it would be entirely possible to pass a list of arguments from the webview widget or webview controller in dart to that functions args parameter.

the CEF docs regarding command line arguments can be found here and a list of Chromius command line arguments can be found here.

the dart implementation would by my design look like:

webview(
  controller: WebViewController(),
  arguments: CommandLineArguments(
    kiosk: false,
    disable-first-run-ui: true,
    enable-features: CEFFeatures(
      OverlayScrollbar: true
    )
  )
)
@SinyimZhi
Copy link
Collaborator

SinyimZhi commented May 9, 2024

Actually, cef works on native side which is same level with flutter engine, we can find that the initialize part is not effect by flutter code. But this does not affect our use of command-line parameters to affect the setting of cef. There is a simple way is that you can try to use shell to start your program with some command-line settings, i guess this would be effectived. @Pebkac03

@Pebkac03
Copy link
Author

Alright, was worried that might be the case. Might it be possible and a good idea to create a YAML file for developers to hardcode it into their app? Or provide docs on how to do so?

@SinyimZhi
Copy link
Collaborator

SinyimZhi commented May 17, 2024

I think there are many ways to achieve the effect you want, and the cef parameter settings can also be added to the implementation of the OnBeforeChildProcessLaunch function in webview_app.cc, cef is implemented in a multi process mode.
If you are willing, can you try to complete and submit the PR? @Pebkac03

@Pebkac03
Copy link
Author

I'll fork and start experimenting. Hopefully it will be possible. Will post a comment here with what I find.

@SinyimZhi
Copy link
Collaborator

SinyimZhi commented May 20, 2024

I'll fork and start experimenting. Hopefully it will be possible. Will post a comment here with what I find.

That's sounds great, welcome to join us and hope to hear good news.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants