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

Unified Diff: chrome/browser/search/instant_service.cc

Issue 1669723002: NTP: don't allow navigateContentWindow to navigate where it pleases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better comments Created 4 years, 10 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
« no previous file with comments | « chrome/browser/search/instant_service.h ('k') | chrome/browser/search/instant_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/instant_service.cc
diff --git a/chrome/browser/search/instant_service.cc b/chrome/browser/search/instant_service.cc
index 9b62978a7d814fc3b94c5468897eefc8632bc892..f21b684e983d1af1d2c579eff010d35d128d6f6c 100644
--- a/chrome/browser/search/instant_service.cc
+++ b/chrome/browser/search/instant_service.cc
@@ -42,10 +42,12 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/url_data_source.h"
+#include "content/public/common/url_constants.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image_skia.h"
+#include "url/url_constants.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/search/local_ntp_source.h"
@@ -300,6 +302,30 @@ void InstantService::SendSearchURLsToRenderer(content::RenderProcessHost* rph) {
search::GetSearchURLs(profile_), search::GetNewTabPageURL(profile_)));
}
+bool InstantService::IsValidURLForNavigation(const GURL& url) const {
+ // Certain URLs are privileged and should never be considered valid
+ // navigation targets.
+ // TODO(treib): Ideally this should deny by default and only allow if the
+ // scheme passes the content::ChildProcessSecurityPolicy::IsWebSafeScheme()
+ // check.
+ if (url.SchemeIs(content::kChromeUIScheme))
+ return false;
+
+ // javascript: URLs never make sense as a most visited item either.
+ if (url.SchemeIs(url::kJavaScriptScheme))
+ return false;
+
+ for (const auto& item : most_visited_items_) {
+ if (item.url == url)
+ return true;
+ }
+ for (const auto& item : suggestions_items_) {
+ if (item.url == url)
+ return true;
+ }
+ return false;
+}
+
void InstantService::OnRendererProcessTerminated(int process_id) {
process_ids_.erase(process_id);
« no previous file with comments | « chrome/browser/search/instant_service.h ('k') | chrome/browser/search/instant_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698