Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc

Issue 8689013: Remove TOUCH_UI specific new tab page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 localized_strings.SetString("serverpromo", 417 localized_strings.SetString("serverpromo",
418 profile_->GetPrefs()->GetString(prefs::kNTPPromoLine)); 418 profile_->GetPrefs()->GetString(prefs::kNTPPromoLine));
419 UserMetrics::RecordAction(UserMetricsAction("NTPPromoShown")); 419 UserMetrics::RecordAction(UserMetricsAction("NTPPromoShown"));
420 } 420 }
421 421
422 // Enable or disable bookmark features based on an about flag. 422 // Enable or disable bookmark features based on an about flag.
423 localized_strings.SetString("bookmark_features", 423 localized_strings.SetString("bookmark_features",
424 NewTabUI::NTP4BookmarkFeaturesEnabled() ? "true" : "false"); 424 NewTabUI::NTP4BookmarkFeaturesEnabled() ? "true" : "false");
425 425
426 // Load the new tab page appropriate for this build 426 // Load the new tab page appropriate for this build
427 // Note that some builds (eg. TOUCHUI) don't make use of everything we
428 // do here (all of the template data, etc.), but we keep the back end
429 // consistent across builds, supporting the union of all NTP front-ends
430 // for simplicity.
431 std::string full_html; 427 std::string full_html;
432 if (NewTabUI::NTP4Enabled()) { 428 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance().
433 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). 429 GetRawDataResource(IDR_NEW_TAB_4_HTML));
434 GetRawDataResource(IDR_NEW_TAB_4_HTML)); 430 full_html = jstemplate_builder::GetI18nTemplateHtml(new_tab_html,
435 full_html = jstemplate_builder::GetI18nTemplateHtml(new_tab_html, 431 &localized_strings);
436 &localized_strings);
437 } else {
438 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance().
439 GetRawDataResource(IDR_NEW_TAB_HTML));
440
441 // Inject the template data into the HTML so that it is available before any
442 // layout is needed.
443 std::string json_html;
444 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html);
445
446 static const base::StringPiece template_data_placeholder(
447 "<!-- template data placeholder -->");
448 size_t pos = new_tab_html.find(template_data_placeholder);
449
450 if (pos != base::StringPiece::npos) {
451 full_html.assign(new_tab_html.data(), pos);
452 full_html.append(json_html);
453 size_t after_offset = pos + template_data_placeholder.size();
454 full_html.append(new_tab_html.data() + after_offset,
455 new_tab_html.size() - after_offset);
456 } else {
457 NOTREACHED();
458 full_html.assign(new_tab_html.data(), new_tab_html.size());
459 }
460 }
461
462 new_tab_html_ = base::RefCountedString::TakeString(&full_html); 432 new_tab_html_ = base::RefCountedString::TakeString(&full_html);
463 } 433 }
464 434
465 void NTPResourceCache::CreateNewTabIncognitoCSS() { 435 void NTPResourceCache::CreateNewTabIncognitoCSS() {
466 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); 436 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
467 DCHECK(tp); 437 DCHECK(tp);
468 438
469 // Get our theme colors 439 // Get our theme colors
470 SkColor color_background = 440 SkColor color_background =
471 tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND); 441 tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 subst.push_back(SkColorToRGBAString(color_section_header_rule)); // $18 542 subst.push_back(SkColorToRGBAString(color_section_header_rule)); // $18
573 subst.push_back(SkColorToRGBAString( 543 subst.push_back(SkColorToRGBAString(
574 color_section_header_rule_light)); // $19 544 color_section_header_rule_light)); // $19
575 subst.push_back(SkColorToRGBAString( 545 subst.push_back(SkColorToRGBAString(
576 SkColorSetA(color_section_header_rule, 0))); // $20 546 SkColorSetA(color_section_header_rule, 0))); // $20
577 subst.push_back(SkColorToRGBAString(color_text_light)); // $21 547 subst.push_back(SkColorToRGBAString(color_text_light)); // $21
578 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22 548 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22
579 subst.push_back(SkColorToRGBComponents(color_text)); // $23 549 subst.push_back(SkColorToRGBComponents(color_text)); // $23
580 550
581 // Get our template. 551 // Get our template.
582 int ntp_css_resource_id = NewTabUI::NTP4Enabled() ?
583 IDR_NEW_TAB_4_THEME_CSS : IDR_NEW_TAB_THEME_CSS;
584 static const base::StringPiece new_tab_theme_css( 552 static const base::StringPiece new_tab_theme_css(
585 ResourceBundle::GetSharedInstance().GetRawDataResource( 553 ResourceBundle::GetSharedInstance().GetRawDataResource(
586 ntp_css_resource_id)); 554 IDR_NEW_TAB_4_THEME_CSS));
587 555
588 // Create the string from our template and the replacements. 556 // Create the string from our template and the replacements.
589 std::string css_string; 557 std::string css_string;
590 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 558 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
591 new_tab_css_ = base::RefCountedString::TakeString(&css_string); 559 new_tab_css_ = base::RefCountedString::TakeString(&css_string);
592 } 560 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698