Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7395)

Unified Diff: chrome/browser/ui/webui/settings/md_settings_ui.cc

Issue 2919663002: MD Settings: change how valid origins are checked and tested (Closed)
Patch Set: move md_settings_ui_unittest.cc in chrome/test/BUILD.gn Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/md_settings_ui.cc
diff --git a/chrome/browser/ui/webui/settings/md_settings_ui.cc b/chrome/browser/ui/webui/settings/md_settings_ui.cc
index d073d8dfa6643e6d1213fee5e31b6dadcf5a8db7..270df59a401b3cd82ccbc280d573959fb02bc574 100644
--- a/chrome/browser/ui/webui/settings/md_settings_ui.cc
+++ b/chrome/browser/ui/webui/settings/md_settings_ui.cc
@@ -83,6 +83,12 @@
namespace settings {
+bool IsValidOrigin(const GURL& url) {
+ const GURL origin = url.GetOrigin();
+ return origin == GURL(chrome::kChromeUISettingsURL).GetOrigin() ||
+ origin == GURL(chrome::kChromeUIMdSettingsURL).GetOrigin();
+}
+
// static
void MdSettingsUI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
@@ -161,8 +167,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui, const GURL& url)
// Host must be derived from the visible URL, since this might be serving
// either chrome://settings or chrome://md-settings.
- CHECK(url.GetOrigin() == GURL(chrome::kChromeUISettingsURL).GetOrigin() ||
- url.GetOrigin() == GURL(chrome::kChromeUIMdSettingsURL).GetOrigin());
+ CHECK(IsValidOrigin(url));
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(url.host());
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_ui.h ('k') | chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698