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 "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/favicon/fallback_icon_service_factory.h" | 8 #include "chrome/browser/favicon/fallback_icon_service_factory.h" |
9 #include "chrome/browser/favicon/large_icon_service_factory.h" | 9 #include "chrome/browser/favicon/large_icon_service_factory.h" |
10 #include "chrome/browser/history/top_sites_factory.h" | 10 #include "chrome/browser/history/top_sites_factory.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 21 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
22 #include "chrome/browser/ui/webui/fallback_icon_source.h" | 22 #include "chrome/browser/ui/webui/fallback_icon_source.h" |
23 #include "chrome/browser/ui/webui/favicon_source.h" | 23 #include "chrome/browser/ui/webui/favicon_source.h" |
24 #include "chrome/browser/ui/webui/large_icon_source.h" | 24 #include "chrome/browser/ui/webui/large_icon_source.h" |
25 #include "chrome/browser/ui/webui/theme_source.h" | 25 #include "chrome/browser/ui/webui/theme_source.h" |
26 #include "chrome/common/render_messages.h" | 26 #include "chrome/common/render_messages.h" |
27 #include "components/favicon/core/fallback_icon_service.h" | 27 #include "components/favicon/core/fallback_icon_service.h" |
28 #include "components/favicon/core/large_icon_service.h" | 28 #include "components/favicon/core/large_icon_service.h" |
29 #include "components/history/core/browser/top_sites.h" | 29 #include "components/history/core/browser/top_sites.h" |
30 #include "components/keyed_service/core/service_access_type.h" | 30 #include "components/keyed_service/core/service_access_type.h" |
| 31 #include "components/search/search.h" |
31 #include "components/search_engines/template_url_service.h" | 32 #include "components/search_engines/template_url_service.h" |
32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
35 #include "content/public/browser/render_process_host.h" | 36 #include "content/public/browser/render_process_host.h" |
36 #include "content/public/browser/url_data_source.h" | 37 #include "content/public/browser/url_data_source.h" |
37 #include "grit/theme_resources.h" | 38 #include "grit/theme_resources.h" |
38 #include "third_party/skia/include/core/SkColor.h" | 39 #include "third_party/skia/include/core/SkColor.h" |
39 #include "ui/gfx/color_utils.h" | 40 #include "ui/gfx/color_utils.h" |
40 #include "ui/gfx/image/image_skia.h" | 41 #include "ui/gfx/image/image_skia.h" |
41 | 42 |
42 #if !defined(OS_ANDROID) | 43 #if !defined(OS_ANDROID) |
43 #include "chrome/browser/search/local_ntp_source.h" | 44 #include "chrome/browser/search/local_ntp_source.h" |
44 #endif | 45 #endif |
45 | 46 |
46 #if defined(ENABLE_THEMES) | 47 #if defined(ENABLE_THEMES) |
47 #include "chrome/browser/themes/theme_properties.h" | 48 #include "chrome/browser/themes/theme_properties.h" |
48 #include "chrome/browser/themes/theme_service.h" | 49 #include "chrome/browser/themes/theme_service.h" |
49 #include "chrome/browser/themes/theme_service_factory.h" | 50 #include "chrome/browser/themes/theme_service_factory.h" |
50 #endif // defined(ENABLE_THEMES) | 51 #endif // defined(ENABLE_THEMES) |
51 | 52 |
52 InstantService::InstantService(Profile* profile) | 53 InstantService::InstantService(Profile* profile) |
53 : profile_(profile), | 54 : profile_(profile), |
54 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile_)), | 55 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile_)), |
55 omnibox_start_margin_(chrome::kDisableStartMargin), | 56 omnibox_start_margin_(search::kDisableStartMargin), |
56 weak_ptr_factory_(this) { | 57 weak_ptr_factory_(this) { |
57 // The initialization below depends on a typical set of browser threads. Skip | 58 // The initialization below depends on a typical set of browser threads. Skip |
58 // it if we are running in a unit test without the full suite. | 59 // it if we are running in a unit test without the full suite. |
59 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) | 60 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) |
60 return; | 61 return; |
61 | 62 |
62 // This depends on the existence of the typical browser threads. Therefore it | 63 // This depends on the existence of the typical browser threads. Therefore it |
63 // is only instantiated here (after the check for a UI thread above). | 64 // is only instantiated here (after the check for a UI thread above). |
64 instant_io_context_ = new InstantIOContext(); | 65 instant_io_context_ = new InstantIOContext(); |
65 | 66 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 break; | 239 break; |
239 } | 240 } |
240 #endif // defined(ENABLE_THEMES) | 241 #endif // defined(ENABLE_THEMES) |
241 default: | 242 default: |
242 NOTREACHED() << "Unexpected notification type in InstantService."; | 243 NOTREACHED() << "Unexpected notification type in InstantService."; |
243 } | 244 } |
244 } | 245 } |
245 | 246 |
246 void InstantService::SendSearchURLsToRenderer(content::RenderProcessHost* rph) { | 247 void InstantService::SendSearchURLsToRenderer(content::RenderProcessHost* rph) { |
247 rph->Send(new ChromeViewMsg_SetSearchURLs( | 248 rph->Send(new ChromeViewMsg_SetSearchURLs( |
248 chrome::GetSearchURLs(profile_), chrome::GetNewTabPageURL(profile_))); | 249 search::GetSearchURLs(profile_), search::GetNewTabPageURL(profile_))); |
249 } | 250 } |
250 | 251 |
251 void InstantService::OnOmniboxStartMarginChanged(int start_margin) { | 252 void InstantService::OnOmniboxStartMarginChanged(int start_margin) { |
252 omnibox_start_margin_ = start_margin; | 253 omnibox_start_margin_ = start_margin; |
253 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, | 254 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, |
254 OmniboxStartMarginChanged(omnibox_start_margin_)); | 255 OmniboxStartMarginChanged(omnibox_start_margin_)); |
255 } | 256 } |
256 | 257 |
257 void InstantService::OnRendererProcessTerminated(int process_id) { | 258 void InstantService::OnRendererProcessTerminated(int process_id) { |
258 process_ids_.erase(process_id); | 259 process_ids_.erase(process_id); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 // As forced urls already come from tiles, we can safely ignore those updates. | 455 // As forced urls already come from tiles, we can safely ignore those updates. |
455 if (change_reason == history::TopSitesObserver::ChangeReason::FORCED_URL) | 456 if (change_reason == history::TopSitesObserver::ChangeReason::FORCED_URL) |
456 return; | 457 return; |
457 top_sites->GetMostVisitedURLs( | 458 top_sites->GetMostVisitedURLs( |
458 base::Bind(&InstantService::OnMostVisitedItemsReceived, | 459 base::Bind(&InstantService::OnMostVisitedItemsReceived, |
459 weak_ptr_factory_.GetWeakPtr()), | 460 weak_ptr_factory_.GetWeakPtr()), |
460 false); | 461 false); |
461 } | 462 } |
462 | 463 |
463 void InstantService::ResetInstantSearchPrerenderer() { | 464 void InstantService::ResetInstantSearchPrerenderer() { |
464 if (!chrome::ShouldPrefetchSearchResults()) | 465 if (!search::ShouldPrefetchSearchResults()) |
465 return; | 466 return; |
466 | 467 |
467 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); | 468 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); |
468 instant_prerenderer_.reset( | 469 instant_prerenderer_.reset( |
469 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); | 470 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); |
470 } | 471 } |
OLD | NEW |