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; | 67 using base::Time; |
Lei Zhang
2012/09/28 18:41:24
remove
Nico
2012/09/29 11:08:40
Done.
| |
68 using content::BrowserThread; | 68 using content::BrowserThread; |
69 | 69 |
70 namespace { | 70 namespace { |
71 | 71 |
72 // The URL for the the Learn More page shown on incognito new tab. | 72 // The URL for the the Learn More page shown on incognito new tab. |
73 const char kLearnMoreIncognitoUrl[] = | 73 const char kLearnMoreIncognitoUrl[] = |
74 #if defined(OS_CHROMEOS) | 74 #if defined(OS_CHROMEOS) |
75 "https://www.google.com/support/chromeos/bin/answer.py?answer=95464"; | 75 "https://www.google.com/support/chromeos/bin/answer.py?answer=95464"; |
76 #else | 76 #else |
77 "https://www.google.com/support/chrome/bin/answer.py?answer=95464"; | 77 "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 | 166 // How the background image on the new tab page should be tiled (see tiling |
167 // masks in theme_service.h). | 167 // masks in theme_service.h). |
168 std::string GetNewTabBackgroundTilingCSS( | 168 std::string GetNewTabBackgroundTilingCSS( |
169 const ui::ThemeProvider* theme_provider) { | 169 const ui::ThemeProvider* theme_provider) { |
170 int repeat_mode; | 170 int repeat_mode; |
171 theme_provider->GetDisplayProperty( | 171 theme_provider->GetDisplayProperty( |
172 ThemeService::NTP_BACKGROUND_TILING, &repeat_mode); | 172 ThemeService::NTP_BACKGROUND_TILING, &repeat_mode); |
173 return ThemeService::TilingToString(repeat_mode); | 173 return ThemeService::TilingToString(repeat_mode); |
174 } | 174 } |
175 | 175 |
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 | 176 } // namespace |
184 | 177 |
185 NTPResourceCache::NTPResourceCache(Profile* profile) | 178 NTPResourceCache::NTPResourceCache(Profile* profile) |
186 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false) { | 179 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false) { |
187 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 180 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
188 content::Source<ThemeService>( | 181 content::Source<ThemeService>( |
189 ThemeServiceFactory::GetForProfile(profile))); | 182 ThemeServiceFactory::GetForProfile(profile))); |
190 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, | 183 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, |
191 content::NotificationService::AllSources()); | 184 content::NotificationService::AllSources()); |
192 | 185 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 ResourceBundle::GetSharedInstance().GetRawDataResource( | 572 ResourceBundle::GetSharedInstance().GetRawDataResource( |
580 chrome::search::IsInstantExtendedAPIEnabled(profile_) ? | 573 chrome::search::IsInstantExtendedAPIEnabled(profile_) ? |
581 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS, | 574 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS, |
582 ui::SCALE_FACTOR_NONE)); | 575 ui::SCALE_FACTOR_NONE)); |
583 | 576 |
584 // Create the string from our template and the replacements. | 577 // Create the string from our template and the replacements. |
585 std::string css_string; | 578 std::string css_string; |
586 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 579 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
587 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 580 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
588 } | 581 } |
OLD | NEW |