OLD | NEW |
---|---|
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 28 matching lines...) Expand all Loading... | |
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 "grit/theme_resources.h" | 45 #include "grit/theme_resources.h" |
46 #include "third_party/skia/include/core/SkColor.h" | 46 #include "third_party/skia/include/core/SkColor.h" |
47 #include "ui/gfx/color_utils.h" | 47 #include "ui/gfx/color_utils.h" |
48 #include "ui/gfx/image/image_skia.h" | 48 #include "ui/gfx/image/image_skia.h" |
49 #include "url/url_constants.h" | |
49 | 50 |
50 #if !defined(OS_ANDROID) | 51 #if !defined(OS_ANDROID) |
51 #include "chrome/browser/search/local_ntp_source.h" | 52 #include "chrome/browser/search/local_ntp_source.h" |
52 #endif | 53 #endif |
53 | 54 |
54 #if defined(ENABLE_THEMES) | 55 #if defined(ENABLE_THEMES) |
55 #include "chrome/browser/themes/theme_properties.h" | 56 #include "chrome/browser/themes/theme_properties.h" |
56 #include "chrome/browser/themes/theme_service.h" | 57 #include "chrome/browser/themes/theme_service.h" |
57 #include "chrome/browser/themes/theme_service_factory.h" | 58 #include "chrome/browser/themes/theme_service_factory.h" |
58 #endif // defined(ENABLE_THEMES) | 59 #endif // defined(ENABLE_THEMES) |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 default: | 294 default: |
294 NOTREACHED() << "Unexpected notification type in InstantService."; | 295 NOTREACHED() << "Unexpected notification type in InstantService."; |
295 } | 296 } |
296 } | 297 } |
297 | 298 |
298 void InstantService::SendSearchURLsToRenderer(content::RenderProcessHost* rph) { | 299 void InstantService::SendSearchURLsToRenderer(content::RenderProcessHost* rph) { |
299 rph->Send(new ChromeViewMsg_SetSearchURLs( | 300 rph->Send(new ChromeViewMsg_SetSearchURLs( |
300 search::GetSearchURLs(profile_), search::GetNewTabPageURL(profile_))); | 301 search::GetSearchURLs(profile_), search::GetNewTabPageURL(profile_))); |
301 } | 302 } |
302 | 303 |
304 bool InstantService::IsValidURLForNavigation(const GURL& url) const { | |
305 // Certain URLs are privileged and should never be considered valid | |
306 // navigation targets. | |
307 if (url.SchemeIs("chrome") || url.SchemeIs("chrome-extension")) | |
Marc Treib
2016/02/04 14:00:14
nit: content::kChromeUIScheme and extensions::kExt
dcheng
2016/02/04 16:21:00
Ah, thanks. Done.
| |
308 return false; | |
309 | |
310 // javascript: URLs never make sense as a most visited item either. | |
311 if (url.SchemeIs(url::kJavaScriptScheme)) | |
312 return false; | |
313 | |
314 for (const auto& item : most_visited_items_) { | |
315 if (item.url == url) | |
316 return true; | |
317 } | |
318 for (const auto& item : suggestions_items_) { | |
319 if (item.url == url) | |
320 return true; | |
321 } | |
322 return false; | |
323 } | |
324 | |
303 void InstantService::OnRendererProcessTerminated(int process_id) { | 325 void InstantService::OnRendererProcessTerminated(int process_id) { |
304 process_ids_.erase(process_id); | 326 process_ids_.erase(process_id); |
305 | 327 |
306 if (instant_io_context_.get()) { | 328 if (instant_io_context_.get()) { |
307 content::BrowserThread::PostTask( | 329 content::BrowserThread::PostTask( |
308 content::BrowserThread::IO, FROM_HERE, | 330 content::BrowserThread::IO, FROM_HERE, |
309 base::Bind(&InstantIOContext::RemoveInstantProcessOnIO, | 331 base::Bind(&InstantIOContext::RemoveInstantProcessOnIO, |
310 instant_io_context_, process_id)); | 332 instant_io_context_, process_id)); |
311 } | 333 } |
312 } | 334 } |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 } | 557 } |
536 | 558 |
537 void InstantService::ResetInstantSearchPrerenderer() { | 559 void InstantService::ResetInstantSearchPrerenderer() { |
538 if (!search::ShouldPrefetchSearchResults()) | 560 if (!search::ShouldPrefetchSearchResults()) |
539 return; | 561 return; |
540 | 562 |
541 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); | 563 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); |
542 instant_prerenderer_.reset( | 564 instant_prerenderer_.reset( |
543 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); | 565 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); |
544 } | 566 } |
OLD | NEW |