Compare commits

...

6 Commits

5 changed files with 78 additions and 16 deletions
+59 -10
View File
@@ -267,7 +267,7 @@
// This closure is run when the default search provider is set to Google.
--- /dev/null
+++ b/components/search_engines/template_url_bang_manager.cc
@@ -0,0 +1,197 @@
@@ -0,0 +1,215 @@
+// Copyright 2025 The Helium Authors
+// You can use, redistribute, and/or modify this source code under
+// the terms of the GPL-3.0 license that can be found in the LICENSE file.
@@ -427,9 +427,25 @@
+
+ auto dict = std::move(bang).TakeDict();
+ auto bname = dict.FindString("s");
+ auto bbang = dict.FindString("t");
+
+ std::vector<const std::string*> triggers;
+ if (auto bbang = dict.FindString("t")) {
+ triggers.push_back(bbang);
+ }
+
+ if (auto bbangs = dict.FindList("ts")) {
+ triggers.reserve(triggers.size() + bbangs->size());
+
+ for (const auto& trigger : *bbangs) {
+ const std::string* value = trigger.GetIfString();
+ if (!value) continue;
+
+ triggers.push_back(value);
+ }
+ }
+
+ auto burl_template = dict.FindString("u");
+ if (!bname || !bbang || !burl_template) {
+ if (!bname || !burl_template || triggers.empty()) {
+ continue;
+ }
+
@@ -444,10 +460,12 @@
+ category_map_[index] = GetCategoryFromJSONObject(*bcategory);
+ }
+
+ // We need to pass the URL here as-is, because otherwise URLs
+ // which have the template in the path will have it %-encoded,
+ // which will break everything.
+ bangs_.emplace_back(index++, *bname, *bbang, *burl_template);
+ for (auto trigger : triggers) {
+ // We need to pass the URL here as-is, because otherwise URLs
+ // which have the template in the path will have it %-encoded,
+ // which will break everything.
+ bangs_.emplace_back(index++, *bname, *trigger, *burl_template);
+ }
+ }
+
+ LOG(INFO) << bangs_.size() << " bangs loaded";
@@ -778,19 +796,50 @@
#endif // COMPONENTS_HELIUM_SERVICES_PREF_NAMES_H_
--- a/components/omnibox/browser/omnibox_edit_model.cc
+++ b/components/omnibox/browser/omnibox_edit_model.cc
@@ -1506,7 +1506,10 @@ void OmniboxEditModel::InternalSetUserTe
@@ -780,6 +780,17 @@ bool OmniboxEditModel::AcceptKeyword(
controller_->StopAutocomplete(/*clear_result=*/false);
+ const TemplateURL* turl =
+ controller_->client()->GetTemplateURLService()->GetTemplateURLForKeyword(
+ keyword_);
+
+ if (turl && turl->bang_id() > 0 && !user_text_.starts_with(u'!')) {
+ AutocompleteMatch match = CurrentMatch(nullptr);
+ if (!match.fill_into_edit.empty()) {
+ user_text_ = match.fill_into_edit;
+ }
+ }
+
is_keyword_hint_ = false;
keyword_mode_entry_method_ = entry_method;
if (original_user_text_with_keyword_.empty()) {
@@ -822,9 +833,6 @@ bool OmniboxEditModel::AcceptKeyword(
}
base::RecordAction(base::UserMetricsAction("AcceptedKeywordHint"));
- const TemplateURL* turl =
- controller_->client()->GetTemplateURLService()->GetTemplateURLForKeyword(
- keyword_);
EmitEnteredKeywordModeHistogram(entry_method, turl);
return true;
}
@@ -1506,7 +1514,13 @@ void OmniboxEditModel::InternalSetUserTe
std::u16string OmniboxEditModel::MaybeStripKeyword(
const std::u16string& text) const {
- return is_keyword_selected()
+ std::u16string trimmed_text;
+ base::TrimWhitespace(text, base::TRIM_LEADING, &trimmed_text);
+
+ std::u16string actual_keyword = base::ToLowerASCII(
+ AutocompleteInput::SplitKeywordFromInput(text, false, nullptr));
+ AutocompleteInput::SplitKeywordFromInput(trimmed_text, false, nullptr));
+
+ return is_keyword_selected() && actual_keyword == keyword_
? AutocompleteInput::SplitReplacementStringFromInput(text, false)
: text;
}
@@ -2746,9 +2749,8 @@ bool OmniboxEditModel::MaybeAcceptKeywor
@@ -2746,9 +2760,8 @@ bool OmniboxEditModel::MaybeAcceptKeywor
return false;
size_t keyword_length = new_text.length() - 1;
@@ -114,17 +114,18 @@
// DIR_ROAMING_USER_DATA has been overridden by a command-line option.
--- a/chrome/common/chrome_paths_linux.cc
+++ b/chrome/common/chrome_paths_linux.cc
@@ -101,6 +101,23 @@ bool GetDefaultUserDataDirectory(base::F
@@ -101,6 +101,24 @@ bool GetDefaultUserDataDirectory(base::F
return true;
}
+bool GetChromeUserDataDirectory(base::FilePath* result) {
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ base::FilePath config_dir;
+ std::string chrome_config_home_str;
+ if (env->GetVar("CHROME_CONFIG_HOME", &chrome_config_home_str) &&
+ base::IsStringUTF8(chrome_config_home_str)) {
+ config_dir = base::FilePath::FromUTF8Unsafe(chrome_config_home_str);
+ std::optional<std::string> chrome_config_home_str =
+ env->GetVar("CHROME_CONFIG_HOME");
+
+ if (chrome_config_home_str && base::IsStringUTF8(*chrome_config_home_str)) {
+ config_dir = base::FilePath::FromUTF8Unsafe(*chrome_config_home_str);
+ } else {
+ config_dir =
+ GetXDGDirectory(env.get(), kXdgConfigHomeEnvVar, kDotConfigDir);
@@ -0,0 +1,11 @@
--- a/ui/native_theme/features/native_theme_features.cc
+++ b/ui/native_theme/features/native_theme_features.cc
@@ -46,7 +46,7 @@ BASE_FEATURE(kFluentScrollbar,
// once it is complete.
BASE_FEATURE(kFluentOverlayScrollbar,
"FluentOverlayScrollbar",
- base::FEATURE_DISABLED_BY_DEFAULT);
+ base::FEATURE_ENABLED_BY_DEFAULT);
} // namespace features
+1
View File
@@ -216,3 +216,4 @@ helium/ui/fix-pwa-toolbar.patch
helium/ui/top-container.patch
helium/ui/status-bubble.patch
helium/ui/clean-incognito-guest-ntp.patch
helium/ui/enable-fluent-scrollbar.patch
+1 -1
View File
@@ -1 +1 @@
4
5