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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/search/instant_service.h" 5 #include "chrome/browser/search/instant_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 24 matching lines...) Expand all
35 #include "components/favicon/core/large_icon_service.h" 35 #include "components/favicon/core/large_icon_service.h"
36 #include "components/history/core/browser/top_sites.h" 36 #include "components/history/core/browser/top_sites.h"
37 #include "components/keyed_service/core/service_access_type.h" 37 #include "components/keyed_service/core/service_access_type.h"
38 #include "components/search/search.h" 38 #include "components/search/search.h"
39 #include "components/search_engines/template_url_service.h" 39 #include "components/search_engines/template_url_service.h"
40 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/notification_service.h" 41 #include "content/public/browser/notification_service.h"
42 #include "content/public/browser/notification_types.h" 42 #include "content/public/browser/notification_types.h"
43 #include "content/public/browser/render_process_host.h" 43 #include "content/public/browser/render_process_host.h"
44 #include "content/public/browser/url_data_source.h" 44 #include "content/public/browser/url_data_source.h"
45 #include "content/public/common/url_constants.h"
45 #include "grit/theme_resources.h" 46 #include "grit/theme_resources.h"
46 #include "third_party/skia/include/core/SkColor.h" 47 #include "third_party/skia/include/core/SkColor.h"
47 #include "ui/gfx/color_utils.h" 48 #include "ui/gfx/color_utils.h"
48 #include "ui/gfx/image/image_skia.h" 49 #include "ui/gfx/image/image_skia.h"
50 #include "url/url_constants.h"
49 51
50 #if !defined(OS_ANDROID) 52 #if !defined(OS_ANDROID)
51 #include "chrome/browser/search/local_ntp_source.h" 53 #include "chrome/browser/search/local_ntp_source.h"
52 #endif 54 #endif
53 55
54 #if defined(ENABLE_THEMES) 56 #if defined(ENABLE_THEMES)
55 #include "chrome/browser/themes/theme_properties.h" 57 #include "chrome/browser/themes/theme_properties.h"
56 #include "chrome/browser/themes/theme_service.h" 58 #include "chrome/browser/themes/theme_service.h"
57 #include "chrome/browser/themes/theme_service_factory.h" 59 #include "chrome/browser/themes/theme_service_factory.h"
58 #endif // defined(ENABLE_THEMES) 60 #endif // defined(ENABLE_THEMES)
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 default: 295 default:
294 NOTREACHED() << "Unexpected notification type in InstantService."; 296 NOTREACHED() << "Unexpected notification type in InstantService.";
295 } 297 }
296 } 298 }
297 299
298 void InstantService::SendSearchURLsToRenderer(content::RenderProcessHost* rph) { 300 void InstantService::SendSearchURLsToRenderer(content::RenderProcessHost* rph) {
299 rph->Send(new ChromeViewMsg_SetSearchURLs( 301 rph->Send(new ChromeViewMsg_SetSearchURLs(
300 search::GetSearchURLs(profile_), search::GetNewTabPageURL(profile_))); 302 search::GetSearchURLs(profile_), search::GetNewTabPageURL(profile_)));
301 } 303 }
302 304
305 bool InstantService::IsValidURLForNavigation(const GURL& url) const {
306 // Certain URLs are privileged and should never be considered valid
307 // navigation targets.
308 // TODO(treib): Ideally this should deny by default and only allow if the
309 // scheme passes the content::ChildProcessSecurityPolicy::IsWebSafeScheme()
310 // check.
311 if (url.SchemeIs(content::kChromeUIScheme))
312 return false;
313
314 // javascript: URLs never make sense as a most visited item either.
315 if (url.SchemeIs(url::kJavaScriptScheme))
316 return false;
317
318 for (const auto& item : most_visited_items_) {
319 if (item.url == url)
320 return true;
321 }
322 for (const auto& item : suggestions_items_) {
323 if (item.url == url)
324 return true;
325 }
326 return false;
327 }
328
303 void InstantService::OnRendererProcessTerminated(int process_id) { 329 void InstantService::OnRendererProcessTerminated(int process_id) {
304 process_ids_.erase(process_id); 330 process_ids_.erase(process_id);
305 331
306 if (instant_io_context_.get()) { 332 if (instant_io_context_.get()) {
307 content::BrowserThread::PostTask( 333 content::BrowserThread::PostTask(
308 content::BrowserThread::IO, FROM_HERE, 334 content::BrowserThread::IO, FROM_HERE,
309 base::Bind(&InstantIOContext::RemoveInstantProcessOnIO, 335 base::Bind(&InstantIOContext::RemoveInstantProcessOnIO,
310 instant_io_context_, process_id)); 336 instant_io_context_, process_id));
311 } 337 }
312 } 338 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 561 }
536 562
537 void InstantService::ResetInstantSearchPrerenderer() { 563 void InstantService::ResetInstantSearchPrerenderer() {
538 if (!search::ShouldPrefetchSearchResults()) 564 if (!search::ShouldPrefetchSearchResults())
539 return; 565 return;
540 566
541 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); 567 GURL url(search::GetSearchResultPrefetchBaseURL(profile_));
542 instant_prerenderer_.reset( 568 instant_prerenderer_.reset(
543 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); 569 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL);
544 } 570 }
OLDNEW
« 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