| 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_resource_cache.h" | 5 #include "chrome/browser/ui/webui/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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 PromoResourceServiceUtil::CanShowPromo(profile_)) { | 383 PromoResourceServiceUtil::CanShowPromo(profile_)) { |
| 384 localized_strings.SetString("serverpromo", | 384 localized_strings.SetString("serverpromo", |
| 385 InDateRange(profile_->GetPrefs()->GetDouble(prefs::kNTPPromoStart), | 385 InDateRange(profile_->GetPrefs()->GetDouble(prefs::kNTPPromoStart), |
| 386 profile_->GetPrefs()->GetDouble(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 // Load the new tab page appropriate for this build |
| 392 // Note that some builds (eg. TOUCHUI) don't make use of everything we |
| 393 // do here (all of the template data, etc.), but we keep the back end |
| 394 // consistent across builds, supporting the union of all NTP front-ends |
| 395 // for simplicity. |
| 391 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). | 396 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). |
| 392 GetRawDataResource(IDR_NEW_NEW_TAB_HTML)); | 397 GetRawDataResource(IDR_NEW_TAB_HTML)); |
| 393 | 398 |
| 394 // Inject the template data into the HTML so that it is available before any | 399 // Inject the template data into the HTML so that it is available before any |
| 395 // layout is needed. | 400 // layout is needed. |
| 396 std::string json_html; | 401 std::string json_html; |
| 397 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); | 402 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); |
| 398 | 403 |
| 399 static const base::StringPiece template_data_placeholder( | 404 static const base::StringPiece template_data_placeholder( |
| 400 "<!-- template data placeholder -->"); | 405 "<!-- template data placeholder -->"); |
| 401 size_t pos = new_tab_html.find(template_data_placeholder); | 406 size_t pos = new_tab_html.find(template_data_placeholder); |
| 402 | 407 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 std::string css_string; | 555 std::string css_string; |
| 551 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 556 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
| 552 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); | 557 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); |
| 553 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); | 558 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); |
| 554 | 559 |
| 555 new_tab_css_ = new RefCountedBytes; | 560 new_tab_css_ = new RefCountedBytes; |
| 556 new_tab_css_->data.resize(css_string.size()); | 561 new_tab_css_->data.resize(css_string.size()); |
| 557 std::copy(css_string.begin(), css_string.end(), | 562 std::copy(css_string.begin(), css_string.end(), |
| 558 new_tab_css_->data.begin()); | 563 new_tab_css_->data.begin()); |
| 559 } | 564 } |
| OLD | NEW |