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

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

Issue 243067: Fix NTP so that it updates on theme change.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.h ('k') | 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 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 #ifdef CHROME_PERSONALIZATION 1673 #ifdef CHROME_PERSONALIZATION
1674 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) { 1674 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) {
1675 AddMessageHandler((new NewTabPageSyncHandler())->Attach(this)); 1675 AddMessageHandler((new NewTabPageSyncHandler())->Attach(this));
1676 } 1676 }
1677 #endif 1677 #endif
1678 1678
1679 AddMessageHandler((new NewTabPageSetHomepageHandler())->Attach(this)); 1679 AddMessageHandler((new NewTabPageSetHomepageHandler())->Attach(this));
1680 1680
1681 // In testing mode there may not be an I/O thread. 1681 // In testing mode there may not be an I/O thread.
1682 if (g_browser_process->io_thread()) { 1682 if (g_browser_process->io_thread()) {
1683 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 1683 InitializeCSSCaches();
1684 NewRunnableMethod(&chrome_url_data_manager,
1685 &ChromeURLDataManager::AddDataSource,
1686 new DOMUIThemeSource(GetProfile())));
1687
1688 NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile()); 1684 NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile());
1689 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 1685 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
1690 NewRunnableMethod(&chrome_url_data_manager, 1686 NewRunnableMethod(&chrome_url_data_manager,
1691 &ChromeURLDataManager::AddDataSource, 1687 &ChromeURLDataManager::AddDataSource,
1692 html_source)); 1688 html_source));
1693 } 1689 }
1694 } 1690 }
1695 1691
1696 // Listen for theme installation. 1692 // Listen for theme installation.
1697 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 1693 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
1698 NotificationService::AllSources()); 1694 NotificationService::AllSources());
1699 // Listen for bookmark bar visibility changes. 1695 // Listen for bookmark bar visibility changes.
1700 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, 1696 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
1701 NotificationService::AllSources()); 1697 NotificationService::AllSources());
1702 } 1698 }
1703 1699
1704 NewTabUI::~NewTabUI() { 1700 NewTabUI::~NewTabUI() {
1705 } 1701 }
1706 1702
1707 void NewTabUI::Observe(NotificationType type, 1703 void NewTabUI::Observe(NotificationType type,
1708 const NotificationSource& source, 1704 const NotificationSource& source,
1709 const NotificationDetails& details) { 1705 const NotificationDetails& details) {
1710 if (NotificationType::BROWSER_THEME_CHANGED == type) { 1706 if (NotificationType::BROWSER_THEME_CHANGED == type) {
1707 InitializeCSSCaches();
1711 CallJavascriptFunction(L"themeChanged"); 1708 CallJavascriptFunction(L"themeChanged");
1712 } else if (NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED) { 1709 } else if (NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED) {
1713 if (GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) 1710 if (GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar))
1714 CallJavascriptFunction(L"bookmarkBarAttached"); 1711 CallJavascriptFunction(L"bookmarkBarAttached");
1715 else 1712 else
1716 CallJavascriptFunction(L"bookmarkBarDetached"); 1713 CallJavascriptFunction(L"bookmarkBarDetached");
1717 } 1714 }
1718 } 1715 }
1719 1716
1717 void NewTabUI::InitializeCSSCaches() {
1718 // In testing mode there may not be an I/O thread.
1719 if (g_browser_process->io_thread()) {
1720 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
1721 NewRunnableMethod(&chrome_url_data_manager,
1722 &ChromeURLDataManager::AddDataSource,
1723 new DOMUIThemeSource(GetProfile())));
1724 }
1725 }
1726
1720 // static 1727 // static
1721 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { 1728 void NewTabUI::RegisterUserPrefs(PrefService* prefs) {
1722 MostVisitedHandler::RegisterUserPrefs(prefs); 1729 MostVisitedHandler::RegisterUserPrefs(prefs);
1723 ShownSectionsHandler::RegisterUserPrefs(prefs); 1730 ShownSectionsHandler::RegisterUserPrefs(prefs);
1724 if (NewTabUI::WebResourcesEnabled()) 1731 if (NewTabUI::WebResourcesEnabled())
1725 TipsHandler::RegisterUserPrefs(prefs); 1732 TipsHandler::RegisterUserPrefs(prefs);
1726 } 1733 }
1727 1734
1728 // static 1735 // static
1729 bool NewTabUI::UseOldNewTabPage() { 1736 bool NewTabUI::UseOldNewTabPage() {
1730 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 1737 const CommandLine* command_line = CommandLine::ForCurrentProcess();
1731 return command_line->HasSwitch(switches::kOldNewTabPage); 1738 return command_line->HasSwitch(switches::kOldNewTabPage);
1732 } 1739 }
1733 1740
1734 // static 1741 // static
1735 bool NewTabUI::WebResourcesEnabled() { 1742 bool NewTabUI::WebResourcesEnabled() {
1736 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 1743 const CommandLine* command_line = CommandLine::ForCurrentProcess();
1737 return !command_line->HasSwitch(switches::kDisableWebResources); 1744 return !command_line->HasSwitch(switches::kDisableWebResources);
1738 } 1745 }
1739 1746
1740 // static 1747 // static
1741 bool NewTabUI::FirstRunDisabled() { 1748 bool NewTabUI::FirstRunDisabled() {
1742 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 1749 const CommandLine* command_line = CommandLine::ForCurrentProcess();
1743 return command_line->HasSwitch(switches::kDisableNewTabFirstRun); 1750 return command_line->HasSwitch(switches::kDisableNewTabFirstRun);
1744 } 1751 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698