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/dom_ui/ntp_resource_cache.h" | 5 #include "chrome/browser/dom_ui/ntp_resource_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // Pass the shown_sections pref early so that we can prevent flicker. | 361 // Pass the shown_sections pref early so that we can prevent flicker. |
362 const int shown_sections = ShownSectionsHandler::GetShownSections( | 362 const int shown_sections = ShownSectionsHandler::GetShownSections( |
363 profile_->GetPrefs()); | 363 profile_->GetPrefs()); |
364 localized_strings.SetInteger("shown_sections", shown_sections); | 364 localized_strings.SetInteger("shown_sections", shown_sections); |
365 | 365 |
366 // If the user has preferences for a start and end time for a custom logo, | 366 // If the user has preferences for a start and end time for a custom logo, |
367 // and the time now is between these two times, show the custom logo. | 367 // and the time now is between these two times, show the custom logo. |
368 if (profile_->GetPrefs()->FindPreference(prefs::kNTPCustomLogoStart) && | 368 if (profile_->GetPrefs()->FindPreference(prefs::kNTPCustomLogoStart) && |
369 profile_->GetPrefs()->FindPreference(prefs::kNTPCustomLogoEnd)) { | 369 profile_->GetPrefs()->FindPreference(prefs::kNTPCustomLogoEnd)) { |
370 localized_strings.SetString("customlogo", | 370 localized_strings.SetString("customlogo", |
371 InDateRange(profile_->GetPrefs()->GetReal(prefs::kNTPCustomLogoStart), | 371 InDateRange(profile_->GetPrefs()->GetDouble(prefs::kNTPCustomLogoStart), |
372 profile_->GetPrefs()->GetReal(prefs::kNTPCustomLogoEnd)) ? | 372 profile_->GetPrefs()->GetDouble(prefs::kNTPCustomLogoEnd)) ? |
373 "true" : "false"); | 373 "true" : "false"); |
374 } else { | 374 } else { |
375 localized_strings.SetString("customlogo", "false"); | 375 localized_strings.SetString("customlogo", "false"); |
376 } | 376 } |
377 | 377 |
378 // If the user has preferences for a start and end time for a promo from | 378 // If the user has preferences for a start and end time for a promo from |
379 // the server, and this promo string exists, set the localized string. | 379 // the server, and this promo string exists, set the localized string. |
380 if (profile_->GetPrefs()->FindPreference(prefs::kNTPPromoStart) && | 380 if (profile_->GetPrefs()->FindPreference(prefs::kNTPPromoStart) && |
381 profile_->GetPrefs()->FindPreference(prefs::kNTPPromoEnd) && | 381 profile_->GetPrefs()->FindPreference(prefs::kNTPPromoEnd) && |
382 profile_->GetPrefs()->FindPreference(prefs::kNTPPromoLine) && | 382 profile_->GetPrefs()->FindPreference(prefs::kNTPPromoLine) && |
383 WebResourceServiceUtil::CanShowPromo(profile_)) { | 383 WebResourceServiceUtil::CanShowPromo(profile_)) { |
384 localized_strings.SetString("serverpromo", | 384 localized_strings.SetString("serverpromo", |
385 InDateRange(profile_->GetPrefs()->GetReal(prefs::kNTPPromoStart), | 385 InDateRange(profile_->GetPrefs()->GetDouble(prefs::kNTPPromoStart), |
386 profile_->GetPrefs()->GetReal(prefs::kNTPPromoEnd)) ? | 386 profile_->GetPrefs()->GetDouble(prefs::kNTPPromoEnd)) ? |
387 profile_->GetPrefs()->GetString(prefs::kNTPPromoLine) : | 387 profile_->GetPrefs()->GetString(prefs::kNTPPromoLine) : |
388 std::string()); | 388 std::string()); |
389 } | 389 } |
390 | 390 |
391 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). | 391 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). |
392 GetRawDataResource(IDR_NEW_NEW_TAB_HTML)); | 392 GetRawDataResource(IDR_NEW_NEW_TAB_HTML)); |
393 | 393 |
394 // Inject the template data into the HTML so that it is available before any | 394 // Inject the template data into the HTML so that it is available before any |
395 // layout is needed. | 395 // layout is needed. |
396 std::string json_html; | 396 std::string json_html; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 std::string css_string; | 550 std::string css_string; |
551 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 551 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
552 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); | 552 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); |
553 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); | 553 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); |
554 | 554 |
555 new_tab_css_ = new RefCountedBytes; | 555 new_tab_css_ = new RefCountedBytes; |
556 new_tab_css_->data.resize(css_string.size()); | 556 new_tab_css_->data.resize(css_string.size()); |
557 std::copy(css_string.begin(), css_string.end(), | 557 std::copy(css_string.begin(), css_string.end(), |
558 new_tab_css_->data.begin()); | 558 new_tab_css_->data.begin()); |
559 } | 559 } |
OLD | NEW |