Google Chrome - how can i programmatically enable chrome://flags some of the modules from disable mode to enabled mode?

前端 未结 2 952
野趣味
野趣味 2020-12-08 03:25

How can I automate the setting of chrome flags to enable few modules?

I have application designed which requires on open the chrome://flags few modules enabled, othe

2条回答
  •  忘掉有多难
    2020-12-08 03:47

    Rooting about in the chrome://flags screen I found something interesting in an included JS file :

    /**
     * Invoked when the selection of a multi-value choice is changed to the
     * specified index.
     * @param {HTMLElement} node The node for the experiment being changed.
     * @param {number} index The index of the option that was selected.
     */
    function handleSelectChoiceExperiment(node, index) {
      // Tell the C++ FlagsDOMHandler to enable the selected choice.
      chrome.send('enableFlagsExperiment',
                  [String(node.internal_name) + '@' + index, 'true']);
      requestFlagsExperimentsData();
    }
    

    chrome.send is indeed a valid method,

    Here is another snippet form the same file (chrome://flags/flags.js)

    /**
     * Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs).
     */
    function restartBrowser() {
      chrome.send('restartBrowser');
    }
    

    Manually calling chrome.send ('restartBroswer') did indeed restart the browser.

    I think this provides all the facilities you need to automate the setting of the flags, you will need to trawl through the chrome://flags source to find the flags you need and then set up the appropriate chrome.send calls.

提交回复
热议问题