OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this)); | 325 AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this)); |
326 AddMessageHandler((new NewTabPageClosePromoHandler())->Attach(this)); | 326 AddMessageHandler((new NewTabPageClosePromoHandler())->Attach(this)); |
327 } | 327 } |
328 | 328 |
329 // Initializing the CSS and HTML can require some CPU, so do it after | 329 // Initializing the CSS and HTML can require some CPU, so do it after |
330 // we've hooked up the most visited handler. This allows the DB query | 330 // we've hooked up the most visited handler. This allows the DB query |
331 // for the new tab thumbs to happen earlier. | 331 // for the new tab thumbs to happen earlier. |
332 InitializeCSSCaches(); | 332 InitializeCSSCaches(); |
333 NewTabHTMLSource* html_source = | 333 NewTabHTMLSource* html_source = |
334 new NewTabHTMLSource(GetProfile()->GetOriginalProfile()); | 334 new NewTabHTMLSource(GetProfile()->GetOriginalProfile()); |
335 BrowserThread::PostTask( | 335 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
336 BrowserThread::IO, FROM_HERE, | |
337 NewRunnableMethod( | |
338 ChromeURLDataManager::GetInstance(), | |
339 &ChromeURLDataManager::AddDataSource, | |
340 make_scoped_refptr(html_source))); | |
341 | 336 |
342 // Listen for theme installation. | 337 // Listen for theme installation. |
343 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 338 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, |
344 NotificationService::AllSources()); | 339 NotificationService::AllSources()); |
345 // Listen for bookmark bar visibility changes. | 340 // Listen for bookmark bar visibility changes. |
346 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | 341 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, |
347 NotificationService::AllSources()); | 342 NotificationService::AllSources()); |
348 } | 343 } |
349 | 344 |
350 NewTabUI::~NewTabUI() { | 345 NewTabUI::~NewTabUI() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 case NotificationType::RENDER_WIDGET_HOST_DID_PAINT: { | 410 case NotificationType::RENDER_WIDGET_HOST_DID_PAINT: { |
416 last_paint_ = base::TimeTicks::Now(); | 411 last_paint_ = base::TimeTicks::Now(); |
417 break; | 412 break; |
418 } | 413 } |
419 default: | 414 default: |
420 CHECK(false) << "Unexpected notification: " << type.value; | 415 CHECK(false) << "Unexpected notification: " << type.value; |
421 } | 416 } |
422 } | 417 } |
423 | 418 |
424 void NewTabUI::InitializeCSSCaches() { | 419 void NewTabUI::InitializeCSSCaches() { |
425 WebUIThemeSource* theme = new WebUIThemeSource(GetProfile()); | 420 Profile* profile = GetProfile(); |
426 BrowserThread::PostTask( | 421 WebUIThemeSource* theme = new WebUIThemeSource(profile); |
427 BrowserThread::IO, FROM_HERE, | 422 profile->GetChromeURLDataManager()->AddDataSource(theme); |
428 NewRunnableMethod( | |
429 ChromeURLDataManager::GetInstance(), | |
430 &ChromeURLDataManager::AddDataSource, | |
431 make_scoped_refptr(theme))); | |
432 } | 423 } |
433 | 424 |
434 // static | 425 // static |
435 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { | 426 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { |
436 prefs->RegisterIntegerPref(prefs::kNTPPrefVersion, 0); | 427 prefs->RegisterIntegerPref(prefs::kNTPPrefVersion, 0); |
437 | 428 |
438 MostVisitedHandler::RegisterUserPrefs(prefs); | 429 MostVisitedHandler::RegisterUserPrefs(prefs); |
439 ShownSectionsHandler::RegisterUserPrefs(prefs); | 430 ShownSectionsHandler::RegisterUserPrefs(prefs); |
440 if (NewTabUI::WebResourcesEnabled()) | 431 if (NewTabUI::WebResourcesEnabled()) |
441 TipsHandler::RegisterUserPrefs(prefs); | 432 TipsHandler::RegisterUserPrefs(prefs); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 591 |
601 scoped_refptr<RefCountedBytes> html_bytes( | 592 scoped_refptr<RefCountedBytes> html_bytes( |
602 profile_->GetNTPResourceCache()->GetNewTabHTML(is_off_the_record)); | 593 profile_->GetNTPResourceCache()->GetNewTabHTML(is_off_the_record)); |
603 | 594 |
604 SendResponse(request_id, html_bytes); | 595 SendResponse(request_id, html_bytes); |
605 } | 596 } |
606 | 597 |
607 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { | 598 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { |
608 return "text/html"; | 599 return "text/html"; |
609 } | 600 } |
OLD | NEW |