Commit b3ec0e07 authored by David Black's avatar David Black Committed by Commit Bot

Fix DCHECK when deep linking to OS Settings > languages.

We currently deep link to "chrome://os-settings/lanugages" which will
bring us to the languages section of top-level OS settings. The subpage
that is DCHECKed against is "chrome://os-settings/languages/details"
which will actually load the languages subpage.

We will now deep link to the actual subpage.

Bug: b:148303041
Change-Id: I4498e25d30dd890e43b8562a998d832cff4ea18e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2023467Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#735501}
parent b6814bcd
......@@ -4,7 +4,6 @@
#include "ash/assistant/util/deep_link_util.h"
#include <array>
#include <set>
#include "ash/assistant/util/i18n_util.h"
......@@ -351,15 +350,16 @@ GURL GetChromeSettingsUrl(const base::Optional<std::string>& page) {
static constexpr char kChromeOsSettingsUrl[] = "chrome://os-settings/";
// Note that we only allow deep linking to a subset of pages. If a deep link
// requests a page not contained in this array, we fallback gracefully to
// requests a page not contained in this map, we fallback gracefully to
// top-level Chrome OS Settings. We may wish to allow deep linking into
// Browser Settings at some point in the future at which point we will define
// an analogous collection of |kAllowedBrowserPages|.
static constexpr std::array<char[16], 2> kAllowedOsPages = {"googleAssistant",
"languages"};
static const std::map<std::string, std::string> kAllowedOsPages = {
{/*page=*/"googleAssistant", /*os_page=*/"googleAssistant"},
{/*page=*/"languages", /*os_page=*/"languages/details"}};
return page && base::Contains(kAllowedOsPages, page.value())
? GURL(kChromeOsSettingsUrl + page.value())
? GURL(kChromeOsSettingsUrl + kAllowedOsPages.at(page.value()))
: GURL(kChromeOsSettingsUrl);
}
......
......@@ -681,7 +681,7 @@ TEST_F(DeepLinkUtilTest, GetChromeSettingsUrl) {
{base::Optional<std::string>("googleAssistant"),
"chrome://os-settings/googleAssistant"},
{base::Optional<std::string>("languages"),
"chrome://os-settings/languages"},
"chrome://os-settings/languages/details"},
// FALLBACK: Allowed pages are case sensitive.
{base::Optional<std::string>("GOOGLEASSISTANT"), "chrome://os-settings/"},
......
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