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 <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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // Invalidate if the current value is different from the cached value. | 205 // Invalidate if the current value is different from the cached value. |
206 bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled(); | 206 bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled(); |
207 if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) { | 207 if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) { |
208 is_swipe_tracking_from_scroll_events_enabled_ = is_enabled; | 208 is_swipe_tracking_from_scroll_events_enabled_ = is_enabled; |
209 return true; | 209 return true; |
210 } | 210 } |
211 #endif | 211 #endif |
212 return false; | 212 return false; |
213 } | 213 } |
214 | 214 |
215 RefCountedMemory* NTPResourceCache::GetNewTabHTML(bool is_incognito) { | 215 base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(bool is_incognito) { |
216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
217 if (is_incognito) { | 217 if (is_incognito) { |
218 if (!new_tab_incognito_html_.get()) | 218 if (!new_tab_incognito_html_.get()) |
219 CreateNewTabIncognitoHTML(); | 219 CreateNewTabIncognitoHTML(); |
220 } else { | 220 } else { |
221 // Refresh the cached HTML if necessary. | 221 // Refresh the cached HTML if necessary. |
222 // NOTE: NewTabCacheNeedsRefresh() must be called every time the new tab | 222 // NOTE: NewTabCacheNeedsRefresh() must be called every time the new tab |
223 // HTML is fetched, because it needs to initialize cached values. | 223 // HTML is fetched, because it needs to initialize cached values. |
224 if (NewTabCacheNeedsRefresh() || !new_tab_html_.get()) | 224 if (NewTabCacheNeedsRefresh() || !new_tab_html_.get()) |
225 CreateNewTabHTML(); | 225 CreateNewTabHTML(); |
226 } | 226 } |
227 return is_incognito ? new_tab_incognito_html_.get() : | 227 return is_incognito ? new_tab_incognito_html_.get() : |
228 new_tab_html_.get(); | 228 new_tab_html_.get(); |
229 } | 229 } |
230 | 230 |
231 RefCountedMemory* NTPResourceCache::GetNewTabCSS(bool is_incognito) { | 231 base::RefCountedMemory* NTPResourceCache::GetNewTabCSS(bool is_incognito) { |
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
233 if (is_incognito) { | 233 if (is_incognito) { |
234 if (!new_tab_incognito_css_.get()) | 234 if (!new_tab_incognito_css_.get()) |
235 CreateNewTabIncognitoCSS(); | 235 CreateNewTabIncognitoCSS(); |
236 } else { | 236 } else { |
237 if (!new_tab_css_.get()) | 237 if (!new_tab_css_.get()) |
238 CreateNewTabCSS(); | 238 CreateNewTabCSS(); |
239 } | 239 } |
240 return is_incognito ? new_tab_incognito_css_.get() : | 240 return is_incognito ? new_tab_incognito_css_.get() : |
241 new_tab_css_.get(); | 241 new_tab_css_.get(); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 // Get our template. | 554 // Get our template. |
555 static const base::StringPiece new_tab_theme_css( | 555 static const base::StringPiece new_tab_theme_css( |
556 ResourceBundle::GetSharedInstance().GetRawDataResource( | 556 ResourceBundle::GetSharedInstance().GetRawDataResource( |
557 IDR_NEW_TAB_4_THEME_CSS)); | 557 IDR_NEW_TAB_4_THEME_CSS)); |
558 | 558 |
559 // Create the string from our template and the replacements. | 559 // Create the string from our template and the replacements. |
560 std::string css_string; | 560 std::string css_string; |
561 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 561 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
562 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 562 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
563 } | 563 } |
OLD | NEW |