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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2643833002: Add a New Tab page location group policy (Closed)
Patch Set: Fixed browser tests Created 3 years, 11 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/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index a0f3bf2981887da9c26f878da086aec12709069f..5006c8e95c687335d5b40e65d586376996520731 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -513,6 +513,24 @@ bool RemoveUberHost(GURL* url) {
return true;
}
+// Handles the rewriting of the new tab page URL based on group policy.
+bool HandleNewTabPageLocationOverride(
+ GURL* url,
+ content::BrowserContext* browser_context) {
+ if (!url->SchemeIs(content::kChromeUIScheme) ||
+ url->host() != chrome::kChromeUINewTabHost)
+ return false;
+
+ Profile* profile = Profile::FromBrowserContext(browser_context);
+ std::string ntp_location =
+ profile->GetPrefs()->GetString(prefs::kNewTabPageLocationOverride);
+ if (ntp_location.empty())
+ return false;
+
+ *url = GURL(ntp_location);
+ return true;
+}
+
// Handles rewriting Web UI URLs.
bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
// Do not handle special URLs such as "about:foo"
@@ -2555,6 +2573,11 @@ void ChromeContentBrowserClient::BrowserURLHandlerCreated(
handler->AddHandlerPair(&WillHandleBrowserAboutURL,
BrowserURLHandler::null_handler());
+ // The group policy NTP URL handler must be registered before the other NTP
+ // URL handlers below.
+ handler->AddHandlerPair(&HandleNewTabPageLocationOverride,
+ BrowserURLHandler::null_handler());
+
#if defined(OS_ANDROID)
// Handler to rewrite chrome://newtab on Android.
handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL,

Powered by Google App Engine
This is Rietveld 408576698