OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
58 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 58 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
59 #elif defined(TOOLKIT_GTK) | 59 #elif defined(TOOLKIT_GTK) |
60 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" | 60 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
61 #endif | 61 #endif |
62 | 62 |
63 #if defined(OS_MACOSX) | 63 #if defined(OS_MACOSX) |
64 #include "chrome/browser/platform_util.h" | 64 #include "chrome/browser/platform_util.h" |
65 #endif | 65 #endif |
66 | 66 |
67 using base::Time; | |
68 using content::BrowserThread; | 67 using content::BrowserThread; |
69 | 68 |
70 namespace { | 69 namespace { |
71 | 70 |
72 // The URL for the the Learn More page shown on incognito new tab. | 71 // The URL for the the Learn More page shown on incognito new tab. |
73 const char kLearnMoreIncognitoUrl[] = | 72 const char kLearnMoreIncognitoUrl[] = |
74 #if defined(OS_CHROMEOS) | 73 #if defined(OS_CHROMEOS) |
75 "https://www.google.com/support/chromeos/bin/answer.py?answer=95464"; | 74 "https://www.google.com/support/chromeos/bin/answer.py?answer=95464"; |
76 #else | 75 #else |
77 "https://www.google.com/support/chrome/bin/answer.py?answer=95464"; | 76 "https://www.google.com/support/chrome/bin/answer.py?answer=95464"; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // How the background image on the new tab page should be tiled (see tiling | 165 // How the background image on the new tab page should be tiled (see tiling |
167 // masks in theme_service.h). | 166 // masks in theme_service.h). |
168 std::string GetNewTabBackgroundTilingCSS( | 167 std::string GetNewTabBackgroundTilingCSS( |
169 const ui::ThemeProvider* theme_provider) { | 168 const ui::ThemeProvider* theme_provider) { |
170 int repeat_mode; | 169 int repeat_mode; |
171 theme_provider->GetDisplayProperty( | 170 theme_provider->GetDisplayProperty( |
172 ThemeService::NTP_BACKGROUND_TILING, &repeat_mode); | 171 ThemeService::NTP_BACKGROUND_TILING, &repeat_mode); |
173 return ThemeService::TilingToString(repeat_mode); | 172 return ThemeService::TilingToString(repeat_mode); |
174 } | 173 } |
175 | 174 |
176 // Is the current time within a given date range? | |
177 bool InDateRange(double begin, double end) { | |
178 Time start_time = Time::FromDoubleT(begin); | |
179 Time end_time = Time::FromDoubleT(end); | |
180 return start_time < Time::Now() && end_time > Time::Now(); | |
181 } | |
182 | |
183 } // namespace | 175 } // namespace |
184 | 176 |
185 NTPResourceCache::NTPResourceCache(Profile* profile) | 177 NTPResourceCache::NTPResourceCache(Profile* profile) |
186 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false) { | 178 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false) { |
187 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 179 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
188 content::Source<ThemeService>( | 180 content::Source<ThemeService>( |
189 ThemeServiceFactory::GetForProfile(profile))); | 181 ThemeServiceFactory::GetForProfile(profile))); |
190 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, | 182 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, |
191 content::NotificationService::AllSources()); | 183 content::NotificationService::AllSources()); |
192 | 184 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 ResourceBundle::GetSharedInstance().GetRawDataResource( | 571 ResourceBundle::GetSharedInstance().GetRawDataResource( |
580 chrome::search::IsInstantExtendedAPIEnabled(profile_) ? | 572 chrome::search::IsInstantExtendedAPIEnabled(profile_) ? |
581 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS, | 573 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS, |
582 ui::SCALE_FACTOR_NONE)); | 574 ui::SCALE_FACTOR_NONE)); |
583 | 575 |
584 // Create the string from our template and the replacements. | 576 // Create the string from our template and the replacements. |
585 std::string css_string; | 577 std::string css_string; |
586 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 578 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
587 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 579 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
588 } | 580 } |
OLD | NEW |