Skip to content

Commit a29fe9b

Browse files
committed
Modify bing search params - removed chrome attrs
fix brave/brave-browser#20659
1 parent 3e30087 commit a29fe9b

5 files changed

+72
-1
lines changed

components/search_engines/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
group("search_engines") {
22
deps = [ "//components/search_engines" ]
33
}
4+
5+
source_set("unit_tests") {
6+
testonly = true
7+
8+
sources = [ "brave_prepopulated_engines_unittest.cc" ]
9+
10+
deps = [
11+
"//chrome/test:test_support",
12+
"//components/prefs",
13+
"//components/search_engines",
14+
"//content/test:test_support",
15+
"//testing/gtest",
16+
]
17+
}

components/search_engines/brave_prepopulated_engines.cc

+23-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const std::map<BravePrepopulatedEngineID, const PrepopulatedEngine*>
2323
brave_engines_map = {
2424
{PREPOPULATED_ENGINE_ID_GOOGLE, &google},
2525
{PREPOPULATED_ENGINE_ID_YANDEX, &brave_yandex},
26-
{PREPOPULATED_ENGINE_ID_BING, &bing},
26+
{PREPOPULATED_ENGINE_ID_BING, &brave_bing},
2727
{PREPOPULATED_ENGINE_ID_DUCKDUCKGO, &duckduckgo},
2828
{PREPOPULATED_ENGINE_ID_DUCKDUCKGO_DE, &duckduckgo_de},
2929
{PREPOPULATED_ENGINE_ID_DUCKDUCKGO_AU_NZ_IE, &duckduckgo_au_nz_ie},
@@ -226,6 +226,28 @@ const PrepopulatedEngine brave_search = {
226226
PREPOPULATED_ENGINE_ID_BRAVE,
227227
};
228228

229+
const PrepopulatedEngine brave_bing = {
230+
L"Bing",
231+
L":b",
232+
"https://www.bing.com/sa/simg/bing_p_rr_teal_min.ico",
233+
"https://www.bing.com/search?q={searchTerms}",
234+
"UTF-8",
235+
"https://www.bing.com/osjson.aspx?query={searchTerms}&language={language}",
236+
"https://www.bing.com/images/detail/search?iss=sbiupload#enterInsights",
237+
"https://www.bing.com/chrome/newtab",
238+
NULL,
239+
NULL,
240+
NULL,
241+
NULL,
242+
NULL,
243+
"imageBin={google:imageThumbnailBase64}",
244+
NULL,
245+
0,
246+
SEARCH_ENGINE_OTHER,
247+
NULL,
248+
PREPOPULATED_ENGINE_ID_BING,
249+
};
250+
229251
const std::map<BravePrepopulatedEngineID, const PrepopulatedEngine*>&
230252
GetBraveEnginesMap() {
231253
return brave_engines_map;

components/search_engines/brave_prepopulated_engines.h

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ extern const PrepopulatedEngine qwant;
104104
extern const PrepopulatedEngine startpage;
105105
extern const PrepopulatedEngine brave_yandex;
106106
extern const PrepopulatedEngine brave_search;
107+
extern const PrepopulatedEngine brave_bing;
107108

108109
const std::map<BravePrepopulatedEngineID, const PrepopulatedEngine*>&
109110
GetBraveEnginesMap();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
4+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
5+
6+
#include <memory>
7+
8+
#include "brave/components/search_engines/brave_prepopulated_engines.h"
9+
#include "chrome/test/base/testing_profile.h"
10+
#include "components/prefs/pref_service.h"
11+
#include "components/search_engines/template_url_data.h"
12+
#include "components/search_engines/template_url_prepopulate_data.h"
13+
#include "content/public/test/browser_task_environment.h"
14+
#include "testing/gtest/include/gtest/gtest.h"
15+
16+
class BravePrepopulatedEnginesTest : public testing::Test {
17+
public:
18+
BravePrepopulatedEnginesTest() = default;
19+
~BravePrepopulatedEnginesTest() override = default;
20+
21+
void SetUp() override { profile_ = std::make_unique<TestingProfile>(); }
22+
23+
content::BrowserTaskEnvironment browser_task_environment_;
24+
std::unique_ptr<TestingProfile> profile_;
25+
};
26+
27+
TEST_F(BravePrepopulatedEnginesTest, ModifiedProviderTest) {
28+
auto data = TemplateURLPrepopulateData::GetPrepopulatedEngine(
29+
profile_->GetPrefs(),
30+
TemplateURLPrepopulateData::PREPOPULATED_ENGINE_ID_BING);
31+
// Check modified bing provider url.
32+
EXPECT_EQ(data->url(), "https://www.bing.com/search?q={searchTerms}");
33+
}

test/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ test("brave_unit_tests") {
212212
"//brave/components/ntp_widget_utils/browser",
213213
"//brave/components/p3a",
214214
"//brave/components/permissions:unit_tests",
215+
"//brave/components/search_engines:unit_tests",
215216
"//brave/components/services/ipfs/test:ipfs_service_unit_tests",
216217
"//brave/components/sidebar:unit_tests",
217218
"//brave/components/signin/public/identity_manager:unit_tests",

0 commit comments

Comments
 (0)