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

Unified Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 115910: Allow themes to change the background of the new tab page.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_theme_source.cc ('k') | chrome/browser/profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/new_tab_ui.cc
===================================================================
--- chrome/browser/dom_ui/new_tab_ui.cc (revision 17403)
+++ chrome/browser/dom_ui/new_tab_ui.cc (working copy)
@@ -185,7 +185,7 @@
class NewTabHTMLSource : public ChromeURLDataManager::DataSource {
public:
- NewTabHTMLSource();
+ explicit NewTabHTMLSource(Profile* profile);
// Called when the network layer has requested a resource underneath
// the path we registered.
@@ -209,13 +209,17 @@
// we think it is the user's startup page.
static bool first_view_;
+ // The user's profile.
+ Profile* profile_;
+
DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource);
};
bool NewTabHTMLSource::first_view_ = true;
-NewTabHTMLSource::NewTabHTMLSource()
- : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()) {
+NewTabHTMLSource::NewTabHTMLSource(Profile* profile)
+ : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()),
+ profile_(profile) {
}
void NewTabHTMLSource::StartDataRequest(const std::string& path,
@@ -245,6 +249,9 @@
profile_name);
}
DictionaryValue localized_strings;
+ localized_strings.SetString(L"bookmarkbarattached",
+ profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ?
+ "true" : "false");
localized_strings.SetString(L"title", title);
localized_strings.SetString(L"mostvisited", most_visited);
localized_strings.SetString(L"searches",
@@ -1226,7 +1233,7 @@
&ChromeURLDataManager::AddDataSource,
new DOMUIThemeSource(GetProfile())));
- NewTabHTMLSource* html_source = new NewTabHTMLSource();
+ NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile());
g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(&chrome_url_data_manager,
&ChromeURLDataManager::AddDataSource,
@@ -1237,6 +1244,9 @@
// Listen for theme installation.
registrar_.Add(this, NotificationType::THEME_INSTALLED,
NotificationService::AllSources());
+ // Listen for bookmark bar visibility changes.
+ registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
+ NotificationService::AllSources());
}
NewTabUI::~NewTabUI() {
@@ -1247,6 +1257,11 @@
const NotificationDetails& details) {
if (NotificationType::THEME_INSTALLED == type) {
CallJavascriptFunction(L"themeChanged");
+ } else if (NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED) {
+ if (GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar))
+ CallJavascriptFunction(L"bookmarkBarAttached");
+ else
+ CallJavascriptFunction(L"bookmarkBarDetached");
}
}
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_theme_source.cc ('k') | chrome/browser/profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698