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

Add flags for existing switches #1687

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

Ahrotahn
Copy link
Contributor

This PR creates chrome://flags entries for existing Chromium switches and features.
There have been many previous requests for flags that already exist, albeit only as command-line switches. The most prominent ones are for starting in incognito and removing the tiles on the new tab page. This also helps in situations where adding switches would be difficult, such as on mobile.

The initial entries:

  • Disable Top Sites: Removes the top sites and most visited tiles on the new tab page.
  • Disable WebGL: Disable all versions of WebGL.
  • Force Dark Mode: Forces dark mode in UI for platforms that support it.
  • Incognito: Starts the browser in incognito.
  • No Pings: Disables ping attribute functionalty on <a> tags which can be a privacy concern.
  • Start Maximized: Always starts the browser maximized.
  • Web UI Dark Mode: Forces dark mode for internal chrome pages.

This isn't meant to be an exhaustive list, but I'd like to add the more commonly used/requested ones.
I'll keep this as a draft for a while so everyone has time to add suggestions for other useful entries.

@PF4Public
Copy link
Contributor

PF4Public commented Oct 11, 2021

  • Adjustable number of ntp entries (more columns and rows) :)

@wchen342
Copy link
Contributor

wchen342 commented Oct 11, 2021

So these are only flags, no actual code changes? Nevermind, I missed they are command line switches.

Btw disable WebGL conflicts with this Bromite patch, maybe you can adjust it so I don't need the Bromite patch anymore?

@Ahrotahn
Copy link
Contributor Author

  • Adjustable number of ntp entries (more columns and rows) :)

It would nice if that already had a switch! I've been experimenting with different methods of making the ntp tiles adjustable and I have a couple different solutions I'm testing out. It's not as straightforward as I initially thought!


So these are only flags, no actual code changes? Nevermind, I missed they are command line switches.

Btw disable WebGL conflicts with this Bromite patch, maybe you can adjust it so I don't need the Bromite patch anymore?

Both are correct, these are just flags with no code changes which work because the command-line switches already exist.

You shouldn't need that patch anymore while using this PR. They are essentially the same thing:
content/public/common/content_switches.cc

const char kDisableWebGL[] = "disable-webgl";

@jacob755
Copy link

i request for this flags
--disable-dwm-composition
--enable-low-end-device-mode
--js-flags=--noexpose_wasm
disable feature WebAssembly,AsmJsToWebAssembly,WebAssemblyStreaming
--enable-stale-while-revalidate
--enable-offline-load-stale-cache
--use-simple-cache-backend=on

@wchen342
Copy link
Contributor

In that case I wonder whether it is possible to write a script to convert all command line options to flags? I think the differences are just definitions in header files.

@Ahrotahn
Copy link
Contributor Author

It's possible, but there are a lot of switches available and that would likely make digging through chrome://flags a pain. I also plan to update the PR with a commit that adds documentation for the flags once the list is more finalized and that would make maintaining that more cumbersome even if it were somehow automated.

I would like to keep the patch on the smaller side as I mostly intend this to cover just the most often used switches to make things easier for end users that only need a few of them. An argument could be made to remove some of the ones I've included since there may not be many people that utilize them, but that's one of the reasons I made this a draft as I'm interested in seeing what switches other people are using.

@PF4Public
Copy link
Contributor

If anyone is interested, I've managed to make Chromium show 25 recent tabs:

More tabs in recent

--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
@@ -60,7 +60,7 @@
 
 // The maximum number of local recently closed entries (tab or window) to be
 // shown in the menu.
-const int kMaxLocalEntries = 8;
+const int kMaxLocalEntries = 25;
 
 // Comparator function for use with std::sort that will sort sessions by
 // descending modified_time (i.e., most recent first).

And 128 ntp tiles (it takes a second to render this madness :) ):

More NTP tiles

--- a/ui/webui/resources/cr_components/most_visited/most_visited.ts
+++ b/ui/webui/resources/cr_components/most_visited/most_visited.ts
@@ -343,20 +343,19 @@
   }
 
   private computeColumnCount_(): number {
-    let maxColumns = 3;
+    let maxColumns = 4;
     if (this.screenWidth_ === ScreenWidth.WIDE) {
-      maxColumns = 5;
+      maxColumns = 16;
     } else if (this.screenWidth_ === ScreenWidth.MEDIUM) {
-      maxColumns = 4;
+      maxColumns = 10;
     }
 
     const shortcutCount = this.tiles_ ? this.tiles_.length : 0;
     const canShowAdd = this.maxTiles_ > shortcutCount;
-    const tileCount =
-        Math.min(this.maxTiles_, shortcutCount + (canShowAdd ? 1 : 0));
-    const columnCount = tileCount <= maxColumns ?
-        tileCount :
-        Math.min(maxColumns, Math.ceil(tileCount / 2));
+    const tileCount = shortcutCount + (canShowAdd ? 1 : 0);
+    const columnCount = Math.ceil(Math.sqrt(tileCount/2)*2) <= maxColumns ?
+      Math.ceil(Math.sqrt(tileCount/2)*2) :
+      maxColumns;
     return columnCount || 3;
   }
 
@@ -364,13 +363,14 @@
     if (this.columnCount_ === 0) {
       return 0;
     }
-
     const shortcutCount = this.tiles_ ? this.tiles_.length : 0;
-    return this.columnCount_ <= shortcutCount ? 2 : 1;
+    const canShowAdd = this.maxTiles_ > shortcutCount;
+    const tileCount = shortcutCount + (canShowAdd ? 1 : 0);
+    return Math.ceil(tileCount/this.columnCount_) || 2;
   }
 
   private computeMaxTiles_(): number {
-    return this.customLinksEnabled_ ? 10 : 8;
+    return 128;
   }
 
   private computeMaxVisibleTiles_(): number {

--- a/components/ntp_tiles/constants.h
+++ b/components/ntp_tiles/constants.h
@@ -16,7 +16,7 @@
 extern const size_t kMaxNumMostVisited;
 
 // Maximum number of tiles that can be shown on the NTP.
-const int kMaxNumTiles = 10;
+const int kMaxNumTiles = 128;
 
 }  // namespace ntp_tiles
 
--- a/components/ntp_tiles/constants.cc
+++ b/components/ntp_tiles/constants.cc
@@ -6,10 +6,10 @@
 
 namespace ntp_tiles {
 
-const size_t kMaxNumCustomLinks = 10;
+const size_t kMaxNumCustomLinks = 128;
 
 // If custom links are enabled, an additional tile may be returned making up to
 // kMaxNumCustomLinks custom links including the "Add shortcut" button.
-const size_t kMaxNumMostVisited = 8;
+const size_t kMaxNumMostVisited = 128;
 
 }  // namespace ntp_tiles
 
--- a/components/history/core/browser/top_sites_impl.h
+++ b/components/history/core/browser/top_sites_impl.h
@@ -40,7 +40,7 @@
 struct SitesAndQueriesRequest;
 
 // How many top sites to store in the cache.
-static constexpr size_t kTopSitesNumber = 10;
+static constexpr size_t kTopSitesNumber = 128;
 
 // This class allows requests for most visited urls on any thread. All other
 // methods must be invoked on the UI thread. All mutations to internal state

@bigdiff
Copy link

bigdiff commented Jan 29, 2023

sorry if this is not related, but is it possible to increase the number of suggestions in the omnibar?

for example if I type github i want the omnibar to show 15 suggestions from bookmarks/history (i disable search suggestions).

currently it only shows 6 suggestions as a maximum number 🤔

@PF4Public
Copy link
Contributor

is it possible to increase the number of suggestions in the omnibar?

I'm glad you asked :) I ended up with the following:

Omnibox autocomplete

--- a/components/omnibox/browser/autocomplete_result.cc
+++ b/components/omnibox/browser/autocomplete_result.cc
@@ -95,8 +95,8 @@
   // and 10 on iPad.
   constexpr size_t kMaxZeroSuggestMatchesOnIPad = 10;
 #else
-  constexpr size_t kDefaultMaxAutocompleteMatches = 8;
-  constexpr size_t kDefaultMaxZeroSuggestMatches = 8;
+  constexpr size_t kDefaultMaxAutocompleteMatches = 25;
+  constexpr size_t kDefaultMaxZeroSuggestMatches = 25;
 #endif
   static_assert(kMaxAutocompletePositionValue > kDefaultMaxAutocompleteMatches,
                 "kMaxAutocompletePositionValue must be larger than the largest "
--- a/components/omnibox/browser/omnibox_field_trial.cc
+++ b/components/omnibox/browser/omnibox_field_trial.cc
@@ -269,9 +269,9 @@ void OmniboxFieldTrial::GetDemotionsByType(
 
 size_t OmniboxFieldTrial::GetProviderMaxMatches(
     AutocompleteProvider::Type provider) {
-  size_t default_max_matches_per_provider = 3;
+  size_t default_max_matches_per_provider = 20; 
 
-  std::string param_value = base::GetFieldTrialParamValueByFeature(
+/*  std::string param_value = base::GetFieldTrialParamValueByFeature(
       omnibox::kUIExperimentMaxAutocompleteMatches,
       OmniboxFieldTrial::kUIMaxAutocompleteMatchesByProviderParam);
 
@@ -295,7 +295,7 @@ size_t OmniboxFieldTrial::GetProviderMaxMatches(
       else if (k == provider)
         return v;
     }
-  }
+  }*/
 
   return default_max_matches_per_provider;
 }

Which is based on https://github.com/bromite/bromite/blob/master/build/patches/Increase-number-of-autocomplete-matches-to-10.patch which is based on #814 (comment)

@fordfrog
Copy link

i think it would also be good to add support for --user-agent. i was not able set it to /etc/chromium/default because of the spaces in user agent string... it ended up splitting the string to separate strings and opening them as links though i had user agent string quoted. currently i run chromium from command line with --user-agent switch but that's not that user friendly...

@bigdiff
Copy link

bigdiff commented Feb 18, 2023

is it possible to increase the number of suggestions in the omnibar?

I'm glad you asked :) I ended up with the following:

Omnibox autocomplete

--- a/components/omnibox/browser/autocomplete_result.cc
+++ b/components/omnibox/browser/autocomplete_result.cc
@@ -95,8 +95,8 @@
   // and 10 on iPad.
   constexpr size_t kMaxZeroSuggestMatchesOnIPad = 10;
 #else
-  constexpr size_t kDefaultMaxAutocompleteMatches = 8;
-  constexpr size_t kDefaultMaxZeroSuggestMatches = 8;
+  constexpr size_t kDefaultMaxAutocompleteMatches = 25;
+  constexpr size_t kDefaultMaxZeroSuggestMatches = 25;
 #endif
   static_assert(kMaxAutocompletePositionValue > kDefaultMaxAutocompleteMatches,
                 "kMaxAutocompletePositionValue must be larger than the largest "
--- a/components/omnibox/browser/omnibox_field_trial.cc
+++ b/components/omnibox/browser/omnibox_field_trial.cc
@@ -269,9 +269,9 @@ void OmniboxFieldTrial::GetDemotionsByType(
 
 size_t OmniboxFieldTrial::GetProviderMaxMatches(
     AutocompleteProvider::Type provider) {
-  size_t default_max_matches_per_provider = 3;
+  size_t default_max_matches_per_provider = 20; 
 
-  std::string param_value = base::GetFieldTrialParamValueByFeature(
+/*  std::string param_value = base::GetFieldTrialParamValueByFeature(
       omnibox::kUIExperimentMaxAutocompleteMatches,
       OmniboxFieldTrial::kUIMaxAutocompleteMatchesByProviderParam);
 
@@ -295,7 +295,7 @@ size_t OmniboxFieldTrial::GetProviderMaxMatches(
       else if (k == provider)
         return v;
     }
-  }
+  }*/
 
   return default_max_matches_per_provider;
 }

Which is based on bromite/bromite@master/build/patches/Increase-number-of-autocomplete-matches-to-10.patch which is based on #814 (comment)

Will this change be integrated into ungoogled-chromium? or will it become a flag I can change?

@PF4Public
Copy link
Contributor

Will this change be integrated into ungoogled-chromium? or will it become a flag I can change?

I'm applying locally these and some other Bromite patches and they work exceptionally well with ungoogled-chromium and bring some additional value. As such I'm willing to try and merge them when we have resolved the licensing issue as discussed in #1845.

Cannot promise anything though. It could be that they only fit in contrib repo, and not here. It could be that it would be very difficult (for me) to refactor them into toggle-able flags and no one would be interested either.

@Ahrotahn
Copy link
Contributor Author

I've been sitting on this for too long, but this should be good to go. I've updated the PR to include the low end device mode and WebRTC IP handling policy. We can always add more in the in future if needed.

@Ahrotahn Ahrotahn marked this pull request as ready for review May 23, 2023 14:39
@Ahrotahn Ahrotahn requested a review from a team as a code owner May 23, 2023 14:39
@bigdiff
Copy link

bigdiff commented May 26, 2023

I'm not sure if it is possible to convert blink switches into flags also but if possible I would like to see --enable-blink-features=MiddleClickAutoscroll added as a flag too. ⚡

@Ahrotahn
Copy link
Contributor Author

I recall experimenting with nested flags a long time ago and this method didn't work them. It should be possible to set up a helper to pass them along. I'll do some more testing later on to see what would work.

@PF4Public
Copy link
Contributor

@Ahrotahn Should we merge this PR after updating for new version or would you like to tinker some more?

@Ahrotahn
Copy link
Contributor Author

Ahrotahn commented Jun 7, 2023

It should be fine like this. If I'm able to figure out a clean solution for the nested flags I'll make a new PR to update the patch further.

@Ahrotahn
Copy link
Contributor Author

I reordered the WebRTC policies since #2359 has been merged. If we remove that patch after #2116 is complete I'll need to remember to change the order back to how it was previously.

@PF4Public
Copy link
Contributor

Should we prioritize #2116 then and merge others afterwards?

@Ahrotahn
Copy link
Contributor Author

No, I'll add a new PR to change that after I've spent enough time on #2116. I think it's important to have the flag available since #2359 has already been merged.

@PF4Public
Copy link
Contributor

So, merging this one next, then?

@Ahrotahn
Copy link
Contributor Author

Sure, I'll update the others in a bit.

@PF4Public PF4Public merged commit de90709 into ungoogled-software:master Jun 13, 2023
@PF4Public
Copy link
Contributor

Awesome!

@bigdiff
Copy link

bigdiff commented Jun 14, 2023

Will this change be integrated into ungoogled-chromium? or will it become a flag I can change?

I'm applying locally these and some other Bromite patches and they work exceptionally well with ungoogled-chromium and bring some additional value. As such I'm willing to try and merge them when we have resolved the licensing issue as discussed in #1845.

Cannot promise anything though. It could be that they only fit in contrib repo, and not here. It could be that it would be very difficult (for me) to refactor them into toggle-able flags and no one would be interested either.

Sorry for asking again, but has the licensing issue been worked out yet? I saw that the mentioned PR got merged, if so I can create a new issue to track the progress and it anyone is willing to maintain a patch for.

@Ahrotahn
Copy link
Contributor Author

Carl granted us permission to keep the original patches we currently have, but we wouldn't be able to include any new ones without working that out unfortunately.

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

Successfully merging this pull request may close these issues.

7 participants