Skip to content

Commit

Permalink
Merge pull request #1345 from brave/sync-autosuggest-0.59.x
Browse files Browse the repository at this point in the history
Autocomplete to chrome://sync and not chrome://sync-internals
  • Loading branch information
bbondy authored Jan 15, 2019
2 parents bde566a + c4cc65c commit 577931d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
15 changes: 15 additions & 0 deletions browser/autocomplete/brave_autocomplete_provider_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

#include "brave/browser/autocomplete/brave_autocomplete_provider_client.h"

#include "base/strings/utf_string_conversions.h"
#include "brave/common/webui_url_constants.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/webui_url_constants.h"

BraveAutocompleteProviderClient::BraveAutocompleteProviderClient(
Profile* profile)
Expand All @@ -24,3 +27,15 @@ const TemplateURLService*
BraveAutocompleteProviderClient::GetTemplateURLService() const {
return TemplateURLServiceFactory::GetForProfile(profile_);
}

std::vector<base::string16> BraveAutocompleteProviderClient::GetBuiltinURLs() {
std::vector<base::string16> v =
ChromeAutocompleteProviderClient::GetBuiltinURLs();
auto it = std::find(v.begin(), v.end(),
base::ASCIIToUTF16(chrome::kChromeUISyncInternalsHost));
DCHECK(it != v.end());
if (it != v.end()) {
*it = base::ASCIIToUTF16(kBraveUISyncHost);
}
return v;
}
1 change: 1 addition & 0 deletions browser/autocomplete/brave_autocomplete_provider_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BraveAutocompleteProviderClient

TemplateURLService* GetTemplateURLService() override;
const TemplateURLService* GetTemplateURLService() const override;
std::vector<base::string16> GetBuiltinURLs() override;

private:
Profile* profile_;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/autocomplete/brave_autocomplete_provider_client.h"

#include "base/strings/utf_string_conversions.h"
#include "brave/common/webui_url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/fake_service_worker_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"

class BraveAutocompleteProviderClientUnitTest : public testing::Test {
public:
void SetUp() override {
profile_ = std::make_unique<TestingProfile>();
client_ =
std::make_unique<BraveAutocompleteProviderClient>(profile_.get());
}

bool BuiltinExists(const base::string16& builtin) {
std::vector<base::string16> v = client_->GetBuiltinURLs();
auto it = std::find(v.begin(), v.end(), builtin);
return it != v.end();
}

protected:
content::TestBrowserThreadBundle test_browser_thread_bundle_;
std::unique_ptr<TestingProfile> profile_;
std::unique_ptr<BraveAutocompleteProviderClient> client_;
};

TEST_F(BraveAutocompleteProviderClientUnitTest,
SyncURLSuggestedNotSyncInternal) {
ASSERT_FALSE(BuiltinExists(base::ASCIIToUTF16(chrome::kChromeUISyncInternalsHost)));
ASSERT_TRUE(BuiltinExists(base::ASCIIToUTF16(kBraveUISyncHost)));
}
10 changes: 10 additions & 0 deletions chromium_src/chrome/browser/ui/omnibox/chrome_omnibox_client.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/autocomplete/brave_autocomplete_provider_client.h"

#define ChromeAutocompleteProviderClient BraveAutocompleteProviderClient
#include "../../../../../../chrome/browser/ui/omnibox/chrome_omnibox_client.cc"
#undef ChromeAutocompleteProviderClient

1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static_library("brave_test_support_unit") {

test("brave_unit_tests") {
sources = [
"//brave/browser/autocomplete/brave_autocomplete_provider_client_unittest.cc",
"//brave/browser/autoplay/autoplay_permission_context_unittest.cc",
"//brave/browser/brave_resources_util_unittest.cc",
"//brave/browser/brave_stats_updater_unittest.cc",
Expand Down

0 comments on commit 577931d

Please sign in to comment.