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

Side by Side Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 348003: Fix memory leaks in unit tests from my previous checkin. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 #if !defined(OS_POSIX) 565 #if !defined(OS_POSIX)
566 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) { 566 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) {
567 AddMessageHandler((new NewTabPageSyncHandler())->Attach(this)); 567 AddMessageHandler((new NewTabPageSyncHandler())->Attach(this));
568 } 568 }
569 #endif 569 #endif
570 570
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 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)
582 delete html_source; // Keep Valgrind happy in tests.
581 } 583 }
582 584
583 // Listen for theme installation. 585 // Listen for theme installation.
584 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 586 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
585 NotificationService::AllSources()); 587 NotificationService::AllSources());
586 // Listen for bookmark bar visibility changes. 588 // Listen for bookmark bar visibility changes.
587 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, 589 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
588 NotificationService::AllSources()); 590 NotificationService::AllSources());
589 } 591 }
590 592
(...skipping 16 matching lines...) Expand all
607 CallJavascriptFunction(L"themeChanged"); 609 CallJavascriptFunction(L"themeChanged");
608 } else if (NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED) { 610 } else if (NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED) {
609 if (GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) 611 if (GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar))
610 CallJavascriptFunction(L"bookmarkBarAttached"); 612 CallJavascriptFunction(L"bookmarkBarAttached");
611 else 613 else
612 CallJavascriptFunction(L"bookmarkBarDetached"); 614 CallJavascriptFunction(L"bookmarkBarDetached");
613 } 615 }
614 } 616 }
615 617
616 void NewTabUI::InitializeCSSCaches() { 618 void NewTabUI::InitializeCSSCaches() {
617 ChromeThread::PostTask( 619 DOMUIThemeSource* theme = new DOMUIThemeSource(GetProfile());
620 bool posted = ChromeThread::PostTask(
618 ChromeThread::IO, FROM_HERE, 621 ChromeThread::IO, FROM_HERE,
619 NewRunnableMethod( 622 NewRunnableMethod(
620 &chrome_url_data_manager, 623 &chrome_url_data_manager,
621 &ChromeURLDataManager::AddDataSource, 624 &ChromeURLDataManager::AddDataSource,
622 new DOMUIThemeSource(GetProfile()))); 625 theme));
626 if (!posted)
627 delete theme; // Keep Valgrind happy in tests.
623 } 628 }
624 629
625 // static 630 // static
626 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { 631 void NewTabUI::RegisterUserPrefs(PrefService* prefs) {
627 MostVisitedHandler::RegisterUserPrefs(prefs); 632 MostVisitedHandler::RegisterUserPrefs(prefs);
628 ShownSectionsHandler::RegisterUserPrefs(prefs); 633 ShownSectionsHandler::RegisterUserPrefs(prefs);
629 if (NewTabUI::WebResourcesEnabled()) 634 if (NewTabUI::WebResourcesEnabled())
630 TipsHandler::RegisterUserPrefs(prefs); 635 TipsHandler::RegisterUserPrefs(prefs);
631 } 636 }
632 637
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 std::string json_html; 910 std::string json_html;
906 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); 911 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html);
907 912
908 static const std::string template_data_placeholder = 913 static const std::string template_data_placeholder =
909 "<!-- template data placeholder -->"; 914 "<!-- template data placeholder -->";
910 ReplaceFirstSubstringAfterOffset(&full_html_, 0, template_data_placeholder, 915 ReplaceFirstSubstringAfterOffset(&full_html_, 0, template_data_placeholder,
911 json_html); 916 json_html);
912 917
913 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); 918 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_);
914 } 919 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698