| 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 "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
| 6 | 6 |
| 7 #include <algorithm> | |
| 8 #include <vector> | 7 #include <vector> |
| 9 | 8 |
| 10 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 11 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 12 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
| 13 #include "base/string16.h" | 12 #include "base/string16.h" |
| 14 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 15 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 16 #include "base/time.h" | 15 #include "base/time.h" |
| 17 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 170 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 172 Source<ThemeService>( | 171 Source<ThemeService>( |
| 173 ThemeServiceFactory::GetForProfile(profile))); | 172 ThemeServiceFactory::GetForProfile(profile))); |
| 174 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, | 173 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, |
| 175 NotificationService::AllSources()); | 174 NotificationService::AllSources()); |
| 176 | 175 |
| 177 // Watch for pref changes that cause us to need to invalidate the HTML cache. | 176 // Watch for pref changes that cause us to need to invalidate the HTML cache. |
| 178 pref_change_registrar_.Init(profile_->GetPrefs()); | 177 pref_change_registrar_.Init(profile_->GetPrefs()); |
| 179 pref_change_registrar_.Add(prefs::kSyncAcknowledgedSyncTypes, this); | 178 pref_change_registrar_.Add(prefs::kSyncAcknowledgedSyncTypes, this); |
| 180 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); | 179 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); |
| 181 pref_change_registrar_.Add(prefs::kEnableBookmarkBar, this); | |
| 182 pref_change_registrar_.Add(prefs::kHomePageIsNewTabPage, this); | 180 pref_change_registrar_.Add(prefs::kHomePageIsNewTabPage, this); |
| 183 pref_change_registrar_.Add(prefs::kNTPShownSections, this); | 181 pref_change_registrar_.Add(prefs::kNTPShownSections, this); |
| 184 pref_change_registrar_.Add(prefs::kNTPShownPage, this); | 182 pref_change_registrar_.Add(prefs::kNTPShownPage, this); |
| 185 pref_change_registrar_.Add(prefs::kNTP4IntroDisplayCount, this); | 183 pref_change_registrar_.Add(prefs::kNTP4IntroDisplayCount, this); |
| 186 } | 184 } |
| 187 | 185 |
| 188 NTPResourceCache::~NTPResourceCache() {} | 186 NTPResourceCache::~NTPResourceCache() {} |
| 189 | 187 |
| 190 RefCountedMemory* NTPResourceCache::GetNewTabHTML(bool is_incognito) { | 188 RefCountedMemory* NTPResourceCache::GetNewTabHTML(bool is_incognito) { |
| 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 IDR_NEW_TAB_4_THEME_CSS : IDR_NEW_TAB_THEME_CSS; | 585 IDR_NEW_TAB_4_THEME_CSS : IDR_NEW_TAB_THEME_CSS; |
| 588 static const base::StringPiece new_tab_theme_css( | 586 static const base::StringPiece new_tab_theme_css( |
| 589 ResourceBundle::GetSharedInstance().GetRawDataResource( | 587 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 590 ntp_css_resource_id)); | 588 ntp_css_resource_id)); |
| 591 | 589 |
| 592 // Create the string from our template and the replacements. | 590 // Create the string from our template and the replacements. |
| 593 std::string css_string; | 591 std::string css_string; |
| 594 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 592 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
| 595 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 593 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
| 596 } | 594 } |
| OLD | NEW |