OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/animation.h" | 10 #include "app/animation.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 new_tab_incognito_html_ = new RefCountedBytes; | 218 new_tab_incognito_html_ = new RefCountedBytes; |
219 new_tab_incognito_html_->data.resize(full_html.size()); | 219 new_tab_incognito_html_->data.resize(full_html.size()); |
220 std::copy(full_html.begin(), full_html.end(), | 220 std::copy(full_html.begin(), full_html.end(), |
221 new_tab_incognito_html_->data.begin()); | 221 new_tab_incognito_html_->data.begin()); |
222 } | 222 } |
223 | 223 |
224 void NTPResourceCache::CreateNewTabHTML() { | 224 void NTPResourceCache::CreateNewTabHTML() { |
225 // Show the profile name in the title and most visited labels if the current | 225 // Show the profile name in the title and most visited labels if the current |
226 // profile is not the default. | 226 // profile is not the default. |
| 227 string16 apps = l10n_util::GetStringUTF16(IDS_NEW_TAB_APPS); |
227 string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 228 string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
228 string16 most_visited = l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED); | 229 string16 most_visited = l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED); |
229 DictionaryValue localized_strings; | 230 DictionaryValue localized_strings; |
230 localized_strings.SetString("bookmarkbarattached", | 231 localized_strings.SetString("bookmarkbarattached", |
231 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ? | 232 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ? |
232 "true" : "false"); | 233 "true" : "false"); |
233 localized_strings.SetString("hasattribution", | 234 localized_strings.SetString("hasattribution", |
234 profile_->GetThemeProvider()->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? | 235 profile_->GetThemeProvider()->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? |
235 "true" : "false"); | 236 "true" : "false"); |
| 237 localized_strings.SetString("apps", apps); |
236 localized_strings.SetString("title", title); | 238 localized_strings.SetString("title", title); |
237 localized_strings.SetString("mostvisited", most_visited); | 239 localized_strings.SetString("mostvisited", most_visited); |
238 localized_strings.SetString("restorethumbnails", | 240 localized_strings.SetString("restorethumbnails", |
239 l10n_util::GetStringUTF16(IDS_NEW_TAB_RESTORE_THUMBNAILS_LINK)); | 241 l10n_util::GetStringUTF16(IDS_NEW_TAB_RESTORE_THUMBNAILS_LINK)); |
240 localized_strings.SetString("recentlyclosed", | 242 localized_strings.SetString("recentlyclosed", |
241 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED)); | 243 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED)); |
242 localized_strings.SetString("closedwindowsingle", | 244 localized_strings.SetString("closedwindowsingle", |
243 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_SINGLE)); | 245 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_SINGLE)); |
244 localized_strings.SetString("closedwindowmultiple", | 246 localized_strings.SetString("closedwindowmultiple", |
245 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_MULTIPLE)); | 247 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_MULTIPLE)); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE); | 391 tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE); |
390 | 392 |
391 SkColor color_section = | 393 SkColor color_section = |
392 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION); | 394 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION); |
393 SkColor color_section_text = | 395 SkColor color_section_text = |
394 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT); | 396 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT); |
395 SkColor color_section_link = | 397 SkColor color_section_link = |
396 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK); | 398 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK); |
397 SkColor color_section_link_underline = | 399 SkColor color_section_link_underline = |
398 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE); | 400 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE); |
| 401 SkColor color_section_header_text = |
| 402 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT); |
| 403 SkColor color_section_header_text_hover = |
| 404 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT_HOVER); |
399 | 405 |
400 SkColor color_header = | 406 SkColor color_header = |
401 tp->GetColor(BrowserThemeProvider::COLOR_NTP_HEADER); | 407 tp->GetColor(BrowserThemeProvider::COLOR_NTP_HEADER); |
402 // Generate a lighter color for the header gradients. | 408 // Generate a lighter color for the header gradients. |
403 color_utils::HSL header_lighter; | 409 color_utils::HSL header_lighter; |
404 color_utils::SkColorToHSL(color_header, &header_lighter); | 410 color_utils::SkColorToHSL(color_header, &header_lighter); |
405 header_lighter.l += (1 - header_lighter.l) * 0.33; | 411 header_lighter.l += (1 - header_lighter.l) * 0.33; |
406 SkColor color_header_gradient_light = | 412 SkColor color_header_gradient_light = |
407 color_utils::HSLToSkColor(header_lighter, SkColorGetA(color_header)); | 413 color_utils::HSLToSkColor(header_lighter, SkColorGetA(color_header)); |
408 | 414 |
(...skipping 27 matching lines...) Expand all Loading... |
436 subst.push_back(SkColorToRGBAString(color_link)); // $9 | 442 subst.push_back(SkColorToRGBAString(color_link)); // $9 |
437 | 443 |
438 subst2.push_back(SkColorToRGBAString(color_section)); // $$1 | 444 subst2.push_back(SkColorToRGBAString(color_section)); // $$1 |
439 subst2.push_back(SkColorToRGBAString(color_section_border)); // $$2 | 445 subst2.push_back(SkColorToRGBAString(color_section_border)); // $$2 |
440 subst2.push_back(SkColorToRGBAString(color_section_text)); // $$3 | 446 subst2.push_back(SkColorToRGBAString(color_section_text)); // $$3 |
441 subst2.push_back(SkColorToRGBAString(color_section_link)); // $$4 | 447 subst2.push_back(SkColorToRGBAString(color_section_link)); // $$4 |
442 subst2.push_back( | 448 subst2.push_back( |
443 tp->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? "block" : "none"); // $$5 | 449 tp->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? "block" : "none"); // $$5 |
444 subst2.push_back(SkColorToRGBAString(color_link_underline)); // $$6 | 450 subst2.push_back(SkColorToRGBAString(color_link_underline)); // $$6 |
445 subst2.push_back(SkColorToRGBAString(color_section_link_underline)); // $$7 | 451 subst2.push_back(SkColorToRGBAString(color_section_link_underline)); // $$7 |
| 452 subst2.push_back(SkColorToRGBAString(color_section_header_text)); // $$8 |
| 453 subst2.push_back(SkColorToRGBAString( |
| 454 color_section_header_text_hover)); // $$9 |
446 | 455 |
447 // Get our template. | 456 // Get our template. |
448 static const base::StringPiece new_tab_theme_css( | 457 static const base::StringPiece new_tab_theme_css( |
449 ResourceBundle::GetSharedInstance().GetRawDataResource( | 458 ResourceBundle::GetSharedInstance().GetRawDataResource( |
450 IDR_NEW_TAB_THEME_CSS)); | 459 IDR_NEW_TAB_THEME_CSS)); |
451 | 460 |
452 // Create the string from our template and the replacements. | 461 // Create the string from our template and the replacements. |
453 const std::string css_string = ReplaceStringPlaceholders( | 462 std::string css_string; |
454 new_tab_theme_css, subst, NULL); | 463 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
455 std::string full_css = ReplaceStringPlaceholders(css_string, subst2, NULL); | 464 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); |
456 | 465 |
457 new_tab_css_ = new RefCountedBytes; | 466 new_tab_css_ = new RefCountedBytes; |
458 new_tab_css_->data.resize(full_css.size()); | 467 new_tab_css_->data.resize(css_string.size()); |
459 std::copy(full_css.begin(), full_css.end(), | 468 std::copy(css_string.begin(), css_string.end(), |
460 new_tab_css_->data.begin()); | 469 new_tab_css_->data.begin()); |
461 } | 470 } |
OLD | NEW |