| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/browser/web_resource/promo_resource_service.h" | 31 #include "chrome/browser/web_resource/promo_resource_service.h" |
| 32 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
| 33 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/extensions/extension.h" | 34 #include "chrome/common/extensions/extension.h" |
| 35 #include "chrome/common/extensions/extension_constants.h" | 35 #include "chrome/common/extensions/extension_constants.h" |
| 36 #include "chrome/common/jstemplate_builder.h" | 36 #include "chrome/common/jstemplate_builder.h" |
| 37 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 38 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 39 #include "content/browser/browser_thread.h" | 39 #include "content/browser/browser_thread.h" |
| 40 #include "content/browser/user_metrics.h" | 40 #include "content/browser/user_metrics.h" |
| 41 #include "content/common/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 42 #include "grit/browser_resources.h" | 42 #include "grit/browser_resources.h" |
| 43 #include "grit/chromium_strings.h" | 43 #include "grit/chromium_strings.h" |
| 44 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
| 45 #include "grit/locale_settings.h" | 45 #include "grit/locale_settings.h" |
| 46 #include "grit/theme_resources.h" | 46 #include "grit/theme_resources.h" |
| 47 #include "ui/base/animation/animation.h" | 47 #include "ui/base/animation/animation.h" |
| 48 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
| 49 #include "ui/base/resource/resource_bundle.h" | 49 #include "ui/base/resource/resource_bundle.h" |
| 50 #include "ui/base/theme_provider.h" | 50 #include "ui/base/theme_provider.h" |
| 51 #include "ui/gfx/color_utils.h" | 51 #include "ui/gfx/color_utils.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return start_time < Time::Now() && end_time > Time::Now(); | 165 return start_time < Time::Now() && end_time > Time::Now(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace | 168 } // namespace |
| 169 | 169 |
| 170 NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) { | 170 NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) { |
| 171 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 171 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 172 content::Source<ThemeService>( | 172 content::Source<ThemeService>( |
| 173 ThemeServiceFactory::GetForProfile(profile))); | 173 ThemeServiceFactory::GetForProfile(profile))); |
| 174 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, | 174 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, |
| 175 NotificationService::AllSources()); | 175 content::NotificationService::AllSources()); |
| 176 | 176 |
| 177 // Watch for pref changes that cause us to need to invalidate the HTML cache. | 177 // Watch for pref changes that cause us to need to invalidate the HTML cache. |
| 178 pref_change_registrar_.Init(profile_->GetPrefs()); | 178 pref_change_registrar_.Init(profile_->GetPrefs()); |
| 179 pref_change_registrar_.Add(prefs::kSyncAcknowledgedSyncTypes, this); | 179 pref_change_registrar_.Add(prefs::kSyncAcknowledgedSyncTypes, this); |
| 180 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); | 180 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); |
| 181 pref_change_registrar_.Add(prefs::kHomePageIsNewTabPage, this); | 181 pref_change_registrar_.Add(prefs::kHomePageIsNewTabPage, this); |
| 182 pref_change_registrar_.Add(prefs::kNTPShownSections, this); | 182 pref_change_registrar_.Add(prefs::kNTPShownSections, this); |
| 183 pref_change_registrar_.Add(prefs::kNTPShownPage, this); | 183 pref_change_registrar_.Add(prefs::kNTPShownPage, this); |
| 184 pref_change_registrar_.Add(prefs::kNTP4IntroDisplayCount, this); | 184 pref_change_registrar_.Add(prefs::kNTP4IntroDisplayCount, this); |
| 185 } | 185 } |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 IDR_NEW_TAB_4_THEME_CSS : IDR_NEW_TAB_THEME_CSS; | 591 IDR_NEW_TAB_4_THEME_CSS : IDR_NEW_TAB_THEME_CSS; |
| 592 static const base::StringPiece new_tab_theme_css( | 592 static const base::StringPiece new_tab_theme_css( |
| 593 ResourceBundle::GetSharedInstance().GetRawDataResource( | 593 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 594 ntp_css_resource_id)); | 594 ntp_css_resource_id)); |
| 595 | 595 |
| 596 // Create the string from our template and the replacements. | 596 // Create the string from our template and the replacements. |
| 597 std::string css_string; | 597 std::string css_string; |
| 598 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 598 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
| 599 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 599 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
| 600 } | 600 } |
| OLD | NEW |