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

Side by Side Diff: chrome/browser/search/instant_service.cc

Issue 1086973003: Misc undefined symbol fixes for Android+LTO. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « chrome/browser/search/instant_service.h ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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/favicon_service_factory.h" 9 #include "chrome/browser/favicon/favicon_service_factory.h"
10 #include "chrome/browser/history/top_sites_factory.h" 10 #include "chrome/browser/history/top_sites_factory.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/search/instant_io_context.h" 12 #include "chrome/browser/search/instant_io_context.h"
13 #include "chrome/browser/search/instant_service_observer.h" 13 #include "chrome/browser/search/instant_service_observer.h"
14 #include "chrome/browser/search/most_visited_iframe_source.h" 14 #include "chrome/browser/search/most_visited_iframe_source.h"
15 #include "chrome/browser/search/search.h" 15 #include "chrome/browser/search/search.h"
16 #include "chrome/browser/search/suggestions/suggestions_source.h" 16 #include "chrome/browser/search/suggestions/suggestions_source.h"
17 #include "chrome/browser/search_engines/template_url_service_factory.h" 17 #include "chrome/browser/search_engines/template_url_service_factory.h"
18 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 18 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
19 #if defined(ENABLE_THEMES)
19 #include "chrome/browser/themes/theme_properties.h" 20 #include "chrome/browser/themes/theme_properties.h"
20 #include "chrome/browser/themes/theme_service.h" 21 #include "chrome/browser/themes/theme_service.h"
21 #include "chrome/browser/themes/theme_service_factory.h" 22 #include "chrome/browser/themes/theme_service_factory.h"
23 #endif // defined(ENABLE_THEMES)
Nico 2015/04/15 16:29:49 style nit: Move this down (like the !defined(OS_AN
pcc1 2015/04/15 21:05:23 Done.
22 #include "chrome/browser/thumbnails/thumbnail_list_source.h" 24 #include "chrome/browser/thumbnails/thumbnail_list_source.h"
23 #include "chrome/browser/ui/search/instant_search_prerenderer.h" 25 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
24 #include "chrome/browser/ui/webui/fallback_icon_source.h" 26 #include "chrome/browser/ui/webui/fallback_icon_source.h"
25 #include "chrome/browser/ui/webui/favicon_source.h" 27 #include "chrome/browser/ui/webui/favicon_source.h"
26 #include "chrome/browser/ui/webui/large_icon_source.h" 28 #include "chrome/browser/ui/webui/large_icon_source.h"
27 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 29 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
28 #include "chrome/browser/ui/webui/theme_source.h" 30 #include "chrome/browser/ui/webui/theme_source.h"
29 #include "chrome/common/render_messages.h" 31 #include "chrome/common/render_messages.h"
30 #include "components/favicon/core/fallback_icon_service.h" 32 #include "components/favicon/core/fallback_icon_service.h"
31 #include "components/favicon/core/favicon_service.h" 33 #include "components/favicon/core/favicon_service.h"
32 #include "components/history/core/browser/top_sites.h" 34 #include "components/history/core/browser/top_sites.h"
33 #include "components/keyed_service/core/service_access_type.h" 35 #include "components/keyed_service/core/service_access_type.h"
34 #include "components/search_engines/template_url_service.h" 36 #include "components/search_engines/template_url_service.h"
35 #include "content/public/browser/browser_thread.h" 37 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/notification_types.h" 39 #include "content/public/browser/notification_types.h"
38 #include "content/public/browser/render_process_host.h" 40 #include "content/public/browser/render_process_host.h"
39 #include "content/public/browser/url_data_source.h" 41 #include "content/public/browser/url_data_source.h"
40 #include "grit/theme_resources.h" 42 #include "grit/theme_resources.h"
41 #include "third_party/skia/include/core/SkColor.h" 43 #include "third_party/skia/include/core/SkColor.h"
42 #include "ui/gfx/color_utils.h" 44 #include "ui/gfx/color_utils.h"
43 #include "ui/gfx/image/image_skia.h" 45 #include "ui/gfx/image/image_skia.h"
44 #include "ui/gfx/sys_color_change_listener.h" 46 #include "ui/gfx/sys_color_change_listener.h"
45 47
46 #if !defined(OS_ANDROID) 48 #if !defined(OS_ANDROID)
47 #include "chrome/browser/search/local_ntp_source.h" 49 #include "chrome/browser/search/local_ntp_source.h"
48 #endif 50 #endif
49 51
50 namespace {
51
52 const int kSectionBorderAlphaTransparency = 80;
53
54 // Converts SkColor to RGBAColor
55 RGBAColor SkColorToRGBAColor(const SkColor& sKColor) {
56 RGBAColor color;
57 color.r = SkColorGetR(sKColor);
58 color.g = SkColorGetG(sKColor);
59 color.b = SkColorGetB(sKColor);
60 color.a = SkColorGetA(sKColor);
61 return color;
62 }
63
64 } // namespace
65
66 InstantService::InstantService(Profile* profile) 52 InstantService::InstantService(Profile* profile)
67 : profile_(profile), 53 : profile_(profile),
68 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile_)), 54 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile_)),
69 omnibox_start_margin_(chrome::kDisableStartMargin), 55 omnibox_start_margin_(chrome::kDisableStartMargin),
70 weak_ptr_factory_(this) { 56 weak_ptr_factory_(this) {
71 // The initialization below depends on a typical set of browser threads. Skip 57 // The initialization below depends on a typical set of browser threads. Skip
72 // it if we are running in a unit test without the full suite. 58 // it if we are running in a unit test without the full suite.
73 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) 59 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI))
74 return; 60 return;
75 61
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 void InstantService::UndoAllMostVisitedDeletions() { 183 void InstantService::UndoAllMostVisitedDeletions() {
198 scoped_refptr<history::TopSites> top_sites = 184 scoped_refptr<history::TopSites> top_sites =
199 TopSitesFactory::GetForProfile(profile_); 185 TopSitesFactory::GetForProfile(profile_);
200 if (!top_sites) 186 if (!top_sites)
201 return; 187 return;
202 188
203 top_sites->ClearBlacklistedURLs(); 189 top_sites->ClearBlacklistedURLs();
204 } 190 }
205 191
206 void InstantService::UpdateThemeInfo() { 192 void InstantService::UpdateThemeInfo() {
193 #if defined(ENABLE_THEMES)
207 // Update theme background info. 194 // Update theme background info.
208 // Initialize |theme_info| if necessary. 195 // Initialize |theme_info| if necessary.
209 if (!theme_info_) 196 if (!theme_info_)
210 OnThemeChanged(ThemeServiceFactory::GetForProfile(profile_)); 197 OnThemeChanged(ThemeServiceFactory::GetForProfile(profile_));
211 else 198 else
212 OnThemeChanged(NULL); 199 OnThemeChanged(NULL);
200 #endif // defined(ENABLE_THEMES)
213 } 201 }
214 202
215 void InstantService::UpdateMostVisitedItemsInfo() { 203 void InstantService::UpdateMostVisitedItemsInfo() {
216 NotifyAboutMostVisitedItems(); 204 NotifyAboutMostVisitedItems();
217 } 205 }
218 206
219 void InstantService::Shutdown() { 207 void InstantService::Shutdown() {
220 process_ids_.clear(); 208 process_ids_.clear();
221 209
222 if (instant_io_context_.get()) { 210 if (instant_io_context_.get()) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 281
294 most_visited_items_ = new_most_visited_items; 282 most_visited_items_ = new_most_visited_items;
295 NotifyAboutMostVisitedItems(); 283 NotifyAboutMostVisitedItems();
296 } 284 }
297 285
298 void InstantService::NotifyAboutMostVisitedItems() { 286 void InstantService::NotifyAboutMostVisitedItems() {
299 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, 287 FOR_EACH_OBSERVER(InstantServiceObserver, observers_,
300 MostVisitedItemsChanged(most_visited_items_)); 288 MostVisitedItemsChanged(most_visited_items_));
301 } 289 }
302 290
291 #if defined(ENABLE_THEMES)
292
293 namespace {
294
295 const int kSectionBorderAlphaTransparency = 80;
296
297 // Converts SkColor to RGBAColor
298 RGBAColor SkColorToRGBAColor(const SkColor& sKColor) {
299 RGBAColor color;
300 color.r = SkColorGetR(sKColor);
301 color.g = SkColorGetG(sKColor);
302 color.b = SkColorGetB(sKColor);
303 color.a = SkColorGetA(sKColor);
304 return color;
305 }
306
307 } // namespace
308
303 void InstantService::OnThemeChanged(ThemeService* theme_service) { 309 void InstantService::OnThemeChanged(ThemeService* theme_service) {
304 if (!theme_service) { 310 if (!theme_service) {
305 DCHECK(theme_info_.get()); 311 DCHECK(theme_info_.get());
306 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, 312 FOR_EACH_OBSERVER(InstantServiceObserver, observers_,
307 ThemeInfoChanged(*theme_info_)); 313 ThemeInfoChanged(*theme_info_));
308 return; 314 return;
309 } 315 }
310 316
311 // Get theme information from theme service. 317 // Get theme information from theme service.
312 theme_info_.reset(new ThemeBackgroundInfo()); 318 theme_info_.reset(new ThemeBackgroundInfo());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 DCHECK(image); 406 DCHECK(image);
401 theme_info_->image_height = image->height(); 407 theme_info_->image_height = image->height();
402 408
403 theme_info_->has_attribution = 409 theme_info_->has_attribution =
404 theme_service->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION); 410 theme_service->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION);
405 } 411 }
406 412
407 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, 413 FOR_EACH_OBSERVER(InstantServiceObserver, observers_,
408 ThemeInfoChanged(*theme_info_)); 414 ThemeInfoChanged(*theme_info_));
409 } 415 }
416 #endif // defined(ENABLE_THEMES)
410 417
411 void InstantService::OnTemplateURLServiceChanged() { 418 void InstantService::OnTemplateURLServiceChanged() {
412 // Check whether the default search provider was changed. 419 // Check whether the default search provider was changed.
413 const TemplateURL* template_url = 420 const TemplateURL* template_url =
414 template_url_service_->GetDefaultSearchProvider(); 421 template_url_service_->GetDefaultSearchProvider();
415 bool default_search_provider_changed = !TemplateURL::MatchesData( 422 bool default_search_provider_changed = !TemplateURL::MatchesData(
416 template_url, previous_default_search_provider_.get(), 423 template_url, previous_default_search_provider_.get(),
417 UIThreadSearchTermsData(profile_)); 424 UIThreadSearchTermsData(profile_));
418 if (default_search_provider_changed) { 425 if (default_search_provider_changed) {
419 previous_default_search_provider_.reset( 426 previous_default_search_provider_.reset(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 } 459 }
453 460
454 void InstantService::ResetInstantSearchPrerenderer() { 461 void InstantService::ResetInstantSearchPrerenderer() {
455 if (!chrome::ShouldPrefetchSearchResults()) 462 if (!chrome::ShouldPrefetchSearchResults())
456 return; 463 return;
457 464
458 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); 465 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_));
459 instant_prerenderer_.reset( 466 instant_prerenderer_.reset(
460 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); 467 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL);
461 } 468 }
OLDNEW
« no previous file with comments | « chrome/browser/search/instant_service.h ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698