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

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

Issue 7600013: ntp4: make default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unit test failures Created 9 years, 4 months 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/defaults.h" 19 #include "chrome/browser/defaults.h"
20 #include "chrome/browser/google/google_util.h" 20 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/prefs/pref_service.h" 21 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/themes/theme_service.h" 23 #include "chrome/browser/themes/theme_service.h"
24 #include "chrome/browser/themes/theme_service_factory.h" 24 #include "chrome/browser/themes/theme_service_factory.h"
25 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 25 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
26 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" 26 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
27 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
27 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h" 28 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h"
28 #include "chrome/browser/ui/webui/sync_setup_handler.h" 29 #include "chrome/browser/ui/webui/sync_setup_handler.h"
29 #include "chrome/browser/web_resource/promo_resource_service.h" 30 #include "chrome/browser/web_resource/promo_resource_service.h"
30 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/extensions/extension.h" 33 #include "chrome/common/extensions/extension.h"
33 #include "chrome/common/extensions/extension_constants.h" 34 #include "chrome/common/extensions/extension_constants.h"
34 #include "chrome/common/jstemplate_builder.h" 35 #include "chrome/common/jstemplate_builder.h"
35 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
36 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 std::string()); 415 std::string());
415 UserMetrics::RecordAction(UserMetricsAction("NTPPromoShown")); 416 UserMetrics::RecordAction(UserMetricsAction("NTPPromoShown"));
416 } 417 }
417 418
418 // Load the new tab page appropriate for this build 419 // Load the new tab page appropriate for this build
419 // Note that some builds (eg. TOUCHUI) don't make use of everything we 420 // Note that some builds (eg. TOUCHUI) don't make use of everything we
420 // do here (all of the template data, etc.), but we keep the back end 421 // do here (all of the template data, etc.), but we keep the back end
421 // consistent across builds, supporting the union of all NTP front-ends 422 // consistent across builds, supporting the union of all NTP front-ends
422 // for simplicity. 423 // for simplicity.
423 std::string full_html; 424 std::string full_html;
424 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4)) { 425 if (NewTabUI::Ntp4Enabled()) {
425 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). 426 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance().
426 GetRawDataResource(IDR_NEW_TAB_4_HTML)); 427 GetRawDataResource(IDR_NEW_TAB_4_HTML));
427 full_html = jstemplate_builder::GetI18nTemplateHtml(new_tab_html, 428 full_html = jstemplate_builder::GetI18nTemplateHtml(new_tab_html,
428 &localized_strings); 429 &localized_strings);
429 } else { 430 } else {
430 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). 431 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance().
431 GetRawDataResource(IDR_NEW_TAB_HTML)); 432 GetRawDataResource(IDR_NEW_TAB_HTML));
432 433
433 // Inject the template data into the HTML so that it is available before any 434 // Inject the template data into the HTML so that it is available before any
434 // layout is needed. 435 // layout is needed.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 color_section_header_text_hover)); // $17 564 color_section_header_text_hover)); // $17
564 subst.push_back(SkColorToRGBAString(color_section_header_rule)); // $18 565 subst.push_back(SkColorToRGBAString(color_section_header_rule)); // $18
565 subst.push_back(SkColorToRGBAString( 566 subst.push_back(SkColorToRGBAString(
566 color_section_header_rule_light)); // $19 567 color_section_header_rule_light)); // $19
567 subst.push_back(SkColorToRGBAString( 568 subst.push_back(SkColorToRGBAString(
568 SkColorSetA(color_section_header_rule, 0))); // $20 569 SkColorSetA(color_section_header_rule, 0))); // $20
569 subst.push_back(SkColorToRGBAString(color_text_light)); // $21 570 subst.push_back(SkColorToRGBAString(color_text_light)); // $21
570 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22 571 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22
571 572
572 // Get our template. 573 // Get our template.
573 int ntp_css_resource_id = 574 int ntp_css_resource_id = NewTabUI::Ntp4Enabled() ?
574 CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4) ? 575 IDR_NEW_TAB_4_THEME_CSS : IDR_NEW_TAB_THEME_CSS;
575 IDR_NEW_TAB_4_THEME_CSS : IDR_NEW_TAB_THEME_CSS;
576 static const base::StringPiece new_tab_theme_css( 576 static const base::StringPiece new_tab_theme_css(
577 ResourceBundle::GetSharedInstance().GetRawDataResource( 577 ResourceBundle::GetSharedInstance().GetRawDataResource(
578 ntp_css_resource_id)); 578 ntp_css_resource_id));
579 579
580 // Create the string from our template and the replacements. 580 // Create the string from our template and the replacements.
581 std::string css_string; 581 std::string css_string;
582 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 582 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
583 new_tab_css_ = base::RefCountedString::TakeString(&css_string); 583 new_tab_css_ = base::RefCountedString::TakeString(&css_string);
584 } 584 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698