| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 AddMessageHandler((new NewTabPageSetHomepageHandler())->Attach(this)); | 571 AddMessageHandler((new NewTabPageSetHomepageHandler())->Attach(this)); |
| 572 | 572 |
| 573 InitializeCSSCaches(); | 573 InitializeCSSCaches(); |
| 574 NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile()); | 574 NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile()); |
| 575 bool posted = ChromeThread::PostTask( | 575 bool posted = ChromeThread::PostTask( |
| 576 ChromeThread::IO, FROM_HERE, | 576 ChromeThread::IO, FROM_HERE, |
| 577 NewRunnableMethod( | 577 NewRunnableMethod( |
| 578 &chrome_url_data_manager, | 578 &chrome_url_data_manager, |
| 579 &ChromeURLDataManager::AddDataSource, | 579 &ChromeURLDataManager::AddDataSource, |
| 580 html_source)); | 580 html_source)); |
| 581 if (!posted) | 581 if (!posted) { |
| 582 delete html_source; // Keep Valgrind happy in tests. | 582 html_source->AddRef(); |
| 583 html_source->Release(); // Keep Valgrind happy in tests. |
| 584 } |
| 583 } | 585 } |
| 584 | 586 |
| 585 // Listen for theme installation. | 587 // Listen for theme installation. |
| 586 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 588 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, |
| 587 NotificationService::AllSources()); | 589 NotificationService::AllSources()); |
| 588 // Listen for bookmark bar visibility changes. | 590 // Listen for bookmark bar visibility changes. |
| 589 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | 591 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, |
| 590 NotificationService::AllSources()); | 592 NotificationService::AllSources()); |
| 591 } | 593 } |
| 592 | 594 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 616 } | 618 } |
| 617 | 619 |
| 618 void NewTabUI::InitializeCSSCaches() { | 620 void NewTabUI::InitializeCSSCaches() { |
| 619 DOMUIThemeSource* theme = new DOMUIThemeSource(GetProfile()); | 621 DOMUIThemeSource* theme = new DOMUIThemeSource(GetProfile()); |
| 620 bool posted = ChromeThread::PostTask( | 622 bool posted = ChromeThread::PostTask( |
| 621 ChromeThread::IO, FROM_HERE, | 623 ChromeThread::IO, FROM_HERE, |
| 622 NewRunnableMethod( | 624 NewRunnableMethod( |
| 623 &chrome_url_data_manager, | 625 &chrome_url_data_manager, |
| 624 &ChromeURLDataManager::AddDataSource, | 626 &ChromeURLDataManager::AddDataSource, |
| 625 theme)); | 627 theme)); |
| 626 if (!posted) | 628 if (!posted) { |
| 627 delete theme; // Keep Valgrind happy in tests. | 629 theme->AddRef(); |
| 630 theme->Release(); // Keep Valgrind happy in tests. |
| 631 } |
| 628 } | 632 } |
| 629 | 633 |
| 630 // static | 634 // static |
| 631 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { | 635 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { |
| 632 MostVisitedHandler::RegisterUserPrefs(prefs); | 636 MostVisitedHandler::RegisterUserPrefs(prefs); |
| 633 ShownSectionsHandler::RegisterUserPrefs(prefs); | 637 ShownSectionsHandler::RegisterUserPrefs(prefs); |
| 634 if (NewTabUI::WebResourcesEnabled()) | 638 if (NewTabUI::WebResourcesEnabled()) |
| 635 TipsHandler::RegisterUserPrefs(prefs); | 639 TipsHandler::RegisterUserPrefs(prefs); |
| 636 } | 640 } |
| 637 | 641 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 std::string json_html; | 914 std::string json_html; |
| 911 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); | 915 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); |
| 912 | 916 |
| 913 static const std::string template_data_placeholder = | 917 static const std::string template_data_placeholder = |
| 914 "<!-- template data placeholder -->"; | 918 "<!-- template data placeholder -->"; |
| 915 ReplaceFirstSubstringAfterOffset(&full_html_, 0, template_data_placeholder, | 919 ReplaceFirstSubstringAfterOffset(&full_html_, 0, template_data_placeholder, |
| 916 json_html); | 920 json_html); |
| 917 | 921 |
| 918 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); | 922 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); |
| 919 } | 923 } |
| OLD | NEW |