Commit 95dfe564 authored by May Lippert's avatar May Lippert Committed by Commit Bot

Remove ChromeOS settings from autocomplete suggestions if #split-settings flag is on.

With the upcoming plan to split out OS settings, chrome://settings will
not have certain settings anymore so those need to be removed from the
autocomplete suggestion list.


BUG=984744
TEST=wrote unit test, ran code on an Eve device with the flag on and
off and verified that the autocomplete suggestions are accurate.

Change-Id: I9b055f120e4f3d9c61b676e126bf5bde9feec125
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713566
Commit-Queue: May Lippert <maybelle@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680072}
parent ce2ec40b
......@@ -58,6 +58,10 @@
#include "chrome/browser/upgrade_detector/upgrade_detector.h"
#endif
#if defined(OS_CHROMEOS)
#include "chromeos/constants/chromeos_features.h"
#endif
namespace {
#if !defined(OS_ANDROID)
......@@ -69,18 +73,22 @@ const char* const kChromeSettingsSubPages[] = {
chrome::kLanguageOptionsSubPage, chrome::kPasswordManagerSubPage,
chrome::kPaymentsSubPage, chrome::kResetProfileSettingsSubPage,
chrome::kSearchEnginesSubPage, chrome::kSyncSetupSubPage,
#if defined(OS_CHROMEOS)
chrome::kAccessibilitySubPage, chrome::kBluetoothSubPage,
chrome::kDateTimeSubPage, chrome::kDisplaySubPage,
chrome::kInternetSubPage, chrome::kPowerSubPage,
chrome::kStylusSubPage,
#else
#if !defined(OS_CHROMEOS)
chrome::kCreateProfileSubPage, chrome::kImportDataSubPage,
chrome::kManageProfileSubPage, chrome::kPeopleSubPage,
#endif
};
#endif // !defined(OS_ANDROID)
#if defined(OS_CHROMEOS)
const char* const kChromeOSSettingsSubPages[] = {
chrome::kAccessibilitySubPage, chrome::kBluetoothSubPage,
chrome::kDateTimeSubPage, chrome::kDisplaySubPage,
chrome::kInternetSubPage, chrome::kPowerSubPage,
chrome::kStylusSubPage,
};
#endif // defined(OS_CHROMEOS)
} // namespace
ChromeAutocompleteProviderClient::ChromeAutocompleteProviderClient(
......@@ -227,6 +235,18 @@ std::vector<base::string16> ChromeAutocompleteProviderClient::GetBuiltinURLs() {
}
#endif
#if defined(OS_CHROMEOS)
// TODO(crbug/950007): Delete this after the settings split is complete since
// the OS setting routes should not show up as an autocomplete suggestion in
// browser.
if (!base::FeatureList::IsEnabled(chromeos::features::kSplitSettings)) {
for (size_t i = 0; i < base::size(kChromeOSSettingsSubPages); i++) {
builtins.push_back(settings +
base::ASCIIToUTF16(kChromeOSSettingsSubPages[i]));
}
}
#endif
return builtins;
}
......
......@@ -7,6 +7,7 @@
#include <memory>
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h"
......@@ -16,6 +17,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#if defined(OS_CHROMEOS)
#include "chromeos/constants/chromeos_features.h"
#endif
namespace {
class TestSchemeClassifier : public AutocompleteSchemeClassifier {
......@@ -146,3 +151,24 @@ TEST_F(ChromeAutocompleteProviderClientTest, TestStrippedURLsAreEqual) {
GURL(test_case.url2), &input));
}
}
// TODO(crbug/950007): Remove this test when the split settings work is complete
#if defined(OS_CHROMEOS)
TEST_F(ChromeAutocompleteProviderClientTest, OSSettingsDoNotShowUp) {
size_t builtin_urls_with_os_settings;
size_t builtin_urls_without_os_settings;
{
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(chromeos::features::kSplitSettings);
builtin_urls_with_os_settings = client_->GetBuiltinURLs().size();
}
{
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(chromeos::features::kSplitSettings);
builtin_urls_without_os_settings = client_->GetBuiltinURLs().size();
}
EXPECT_GT(builtin_urls_with_os_settings, builtin_urls_without_os_settings);
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment