OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/dom_ui/new_tab_ui.h" | 7 #include "chrome/browser/dom_ui/new_tab_ui.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 // Initializing the CSS and HTML can require some CPU, so do it after | 389 // Initializing the CSS and HTML can require some CPU, so do it after |
390 // we've hooked up the most visited handler. This allows the DB query | 390 // we've hooked up the most visited handler. This allows the DB query |
391 // for the new tab thumbs to happen earlier. | 391 // for the new tab thumbs to happen earlier. |
392 InitializeCSSCaches(); | 392 InitializeCSSCaches(); |
393 NewTabHTMLSource* html_source = | 393 NewTabHTMLSource* html_source = |
394 new NewTabHTMLSource(GetProfile()->GetOriginalProfile()); | 394 new NewTabHTMLSource(GetProfile()->GetOriginalProfile()); |
395 BrowserThread::PostTask( | 395 BrowserThread::PostTask( |
396 BrowserThread::IO, FROM_HERE, | 396 BrowserThread::IO, FROM_HERE, |
397 NewRunnableMethod( | 397 NewRunnableMethod( |
398 Singleton<ChromeURLDataManager>::get(), | 398 ChromeURLDataManager::GetInstance(), |
399 &ChromeURLDataManager::AddDataSource, | 399 &ChromeURLDataManager::AddDataSource, |
400 make_scoped_refptr(html_source))); | 400 make_scoped_refptr(html_source))); |
401 | 401 |
402 // Listen for theme installation. | 402 // Listen for theme installation. |
403 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 403 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, |
404 NotificationService::AllSources()); | 404 NotificationService::AllSources()); |
405 // Listen for bookmark bar visibility changes. | 405 // Listen for bookmark bar visibility changes. |
406 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | 406 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, |
407 NotificationService::AllSources()); | 407 NotificationService::AllSources()); |
408 } | 408 } |
(...skipping 26 matching lines...) Expand all Loading... |
435 else | 435 else |
436 CallJavascriptFunction(L"bookmarkBarDetached"); | 436 CallJavascriptFunction(L"bookmarkBarDetached"); |
437 } | 437 } |
438 } | 438 } |
439 | 439 |
440 void NewTabUI::InitializeCSSCaches() { | 440 void NewTabUI::InitializeCSSCaches() { |
441 DOMUIThemeSource* theme = new DOMUIThemeSource(GetProfile()); | 441 DOMUIThemeSource* theme = new DOMUIThemeSource(GetProfile()); |
442 BrowserThread::PostTask( | 442 BrowserThread::PostTask( |
443 BrowserThread::IO, FROM_HERE, | 443 BrowserThread::IO, FROM_HERE, |
444 NewRunnableMethod( | 444 NewRunnableMethod( |
445 Singleton<ChromeURLDataManager>::get(), | 445 ChromeURLDataManager::GetInstance(), |
446 &ChromeURLDataManager::AddDataSource, | 446 &ChromeURLDataManager::AddDataSource, |
447 make_scoped_refptr(theme))); | 447 make_scoped_refptr(theme))); |
448 } | 448 } |
449 | 449 |
450 // static | 450 // static |
451 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { | 451 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { |
452 prefs->RegisterIntegerPref(prefs::kNTPPrefVersion, 0); | 452 prefs->RegisterIntegerPref(prefs::kNTPPrefVersion, 0); |
453 | 453 |
454 MostVisitedHandler::RegisterUserPrefs(prefs); | 454 MostVisitedHandler::RegisterUserPrefs(prefs); |
455 ShownSectionsHandler::RegisterUserPrefs(prefs); | 455 ShownSectionsHandler::RegisterUserPrefs(prefs); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 616 |
617 scoped_refptr<RefCountedBytes> html_bytes( | 617 scoped_refptr<RefCountedBytes> html_bytes( |
618 profile_->GetNTPResourceCache()->GetNewTabHTML(is_off_the_record)); | 618 profile_->GetNTPResourceCache()->GetNewTabHTML(is_off_the_record)); |
619 | 619 |
620 SendResponse(request_id, html_bytes); | 620 SendResponse(request_id, html_bytes); |
621 } | 621 } |
622 | 622 |
623 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { | 623 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { |
624 return "text/html"; | 624 return "text/html"; |
625 } | 625 } |
OLD | NEW |