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

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

Issue 10825093: Fix regression due to deprecated promo preference. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | « no previous file | chrome/browser/web_resource/notification_promo.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/file_util.h" 11 #include "base/file_util.h"
11 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
12 #include "base/string16.h" 13 #include "base/string16.h"
13 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
14 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
15 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/defaults.h" 18 #include "chrome/browser/defaults.h"
18 #include "chrome/browser/google/google_util.h" 19 #include "chrome/browser/google/google_util.h"
19 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/sync/profile_sync_service.h" 22 #include "chrome/browser/sync/profile_sync_service.h"
22 #include "chrome/browser/sync/profile_sync_service_factory.h" 23 #include "chrome/browser/sync/profile_sync_service_factory.h"
23 #include "chrome/browser/themes/theme_service.h" 24 #include "chrome/browser/themes/theme_service.h"
24 #include "chrome/browser/themes/theme_service_factory.h" 25 #include "chrome/browser/themes/theme_service_factory.h"
25 #include "chrome/browser/ui/search/search.h" 26 #include "chrome/browser/ui/search/search.h"
26 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 27 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
27 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" 28 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
28 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 29 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
29 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" 30 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
30 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" 31 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
31 #include "chrome/browser/ui/webui/sync_setup_handler.h" 32 #include "chrome/browser/ui/webui/sync_setup_handler.h"
32 #include "chrome/browser/web_resource/promo_resource_service.h" 33 #include "chrome/browser/web_resource/notification_promo.h"
33 #include "chrome/common/chrome_notification_types.h" 34 #include "chrome/common/chrome_notification_types.h"
34 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/extensions/extension.h" 36 #include "chrome/common/extensions/extension.h"
36 #include "chrome/common/extensions/extension_constants.h" 37 #include "chrome/common/extensions/extension_constants.h"
37 #include "chrome/common/jstemplate_builder.h" 38 #include "chrome/common/jstemplate_builder.h"
38 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
39 #include "chrome/common/url_constants.h" 40 #include "chrome/common/url_constants.h"
40 #include "content/public/browser/browser_thread.h" 41 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
42 #include "grit/browser_resources.h" 43 #include "grit/browser_resources.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 401
401 // Control fade and resize animations. 402 // Control fade and resize animations.
402 load_time_data.SetBoolean("anim", ui::Animation::ShouldRenderRichAnimation()); 403 load_time_data.SetBoolean("anim", ui::Animation::ShouldRenderRichAnimation());
403 404
404 int alignment; 405 int alignment;
405 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); 406 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
406 tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); 407 tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment);
407 load_time_data.SetString("themegravity", 408 load_time_data.SetString("themegravity",
408 (alignment & ThemeService::ALIGN_RIGHT) ? "right" : ""); 409 (alignment & ThemeService::ALIGN_RIGHT) ? "right" : "");
409 410
410 // If the user has preferences for a start and end time for a promo from 411 // Set the promo string for display if there is a valid outstanding promo.
411 // the server, and this promo string exists, set the localized string. 412 NotificationPromo notification_promo(profile_);
412 if (PromoResourceService::CanShowNotificationPromo(profile_)) { 413 notification_promo.InitFromPrefs();
413 load_time_data.SetString("serverpromo", 414 if (notification_promo.CanShow())
414 prefs->GetString(prefs::kNtpPromoLine)); 415 load_time_data.SetString("serverpromo", notification_promo.promo_text());
415 }
416 416
417 // Determine whether to show the menu for accessing tabs on other devices. 417 // Determine whether to show the menu for accessing tabs on other devices.
418 bool show_other_sessions_menu = !CommandLine::ForCurrentProcess()->HasSwitch( 418 bool show_other_sessions_menu = !CommandLine::ForCurrentProcess()->HasSwitch(
419 switches::kDisableNTPOtherSessionsMenu); 419 switches::kDisableNTPOtherSessionsMenu);
420 load_time_data.SetBoolean("showOtherSessionsMenu", 420 load_time_data.SetBoolean("showOtherSessionsMenu",
421 show_other_sessions_menu); 421 show_other_sessions_menu);
422 load_time_data.SetBoolean("isUserSignedIn", 422 load_time_data.SetBoolean("isUserSignedIn",
423 !prefs->GetString(prefs::kGoogleServicesUsername).empty()); 423 !prefs->GetString(prefs::kGoogleServicesUsername).empty());
424 424
425 // Load the new tab page appropriate for this build 425 // Load the new tab page appropriate for this build
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 subst.push_back(SkColorToRGBAString(color_header)); // $6 530 subst.push_back(SkColorToRGBAString(color_header)); // $6
531 subst.push_back(SkColorToRGBAString(color_header_gradient_light)); // $7 531 subst.push_back(SkColorToRGBAString(color_header_gradient_light)); // $7
532 subst.push_back(SkColorToRGBAString(color_text)); // $8 532 subst.push_back(SkColorToRGBAString(color_text)); // $8
533 subst.push_back(SkColorToRGBAString(color_link)); // $9 533 subst.push_back(SkColorToRGBAString(color_link)); // $9
534 subst.push_back(SkColorToRGBAString(color_section)); // $10 534 subst.push_back(SkColorToRGBAString(color_section)); // $10
535 subst.push_back(SkColorToRGBAString(color_section_border)); // $11 535 subst.push_back(SkColorToRGBAString(color_section_border)); // $11
536 subst.push_back(SkColorToRGBAString(color_section_text)); // $12 536 subst.push_back(SkColorToRGBAString(color_section_text)); // $12
537 subst.push_back(SkColorToRGBAString(color_section_link)); // $13 537 subst.push_back(SkColorToRGBAString(color_section_link)); // $13
538 subst.push_back(SkColorToRGBAString(color_link_underline)); // $14 538 subst.push_back(SkColorToRGBAString(color_link_underline)); // $14
539 subst.push_back(SkColorToRGBAString(color_section_link_underline)); // $15 539 subst.push_back(SkColorToRGBAString(color_section_link_underline)); // $15
540 subst.push_back(SkColorToRGBAString(color_section_header_text)); // $16 540 subst.push_back(SkColorToRGBAString(color_section_header_text)); // $16
541 subst.push_back(SkColorToRGBAString( 541 subst.push_back(SkColorToRGBAString(
542 color_section_header_text_hover)); // $17 542 color_section_header_text_hover)); // $17
543 subst.push_back(SkColorToRGBAString(color_section_header_rule)); // $18 543 subst.push_back(SkColorToRGBAString(color_section_header_rule)); // $18
544 subst.push_back(SkColorToRGBAString( 544 subst.push_back(SkColorToRGBAString(
545 color_section_header_rule_light)); // $19 545 color_section_header_rule_light)); // $19
546 subst.push_back(SkColorToRGBAString( 546 subst.push_back(SkColorToRGBAString(
547 SkColorSetA(color_section_header_rule, 0))); // $20 547 SkColorSetA(color_section_header_rule, 0))); // $20
548 subst.push_back(SkColorToRGBAString(color_text_light)); // $21 548 subst.push_back(SkColorToRGBAString(color_text_light)); // $21
549 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22 549 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22
550 subst.push_back(SkColorToRGBComponents(color_text)); // $23 550 subst.push_back(SkColorToRGBComponents(color_text)); // $23
551 551
552 // Get our template. 552 // Get our template.
553 static const base::StringPiece new_tab_theme_css( 553 static const base::StringPiece new_tab_theme_css(
554 ResourceBundle::GetSharedInstance().GetRawDataResource( 554 ResourceBundle::GetSharedInstance().GetRawDataResource(
555 chrome::search::IsInstantExtendedAPIEnabled(profile_) ? 555 chrome::search::IsInstantExtendedAPIEnabled(profile_) ?
556 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS, 556 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS,
557 ui::SCALE_FACTOR_NONE)); 557 ui::SCALE_FACTOR_NONE));
558 558
559 // Create the string from our template and the replacements. 559 // Create the string from our template and the replacements.
560 std::string css_string; 560 std::string css_string;
561 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 561 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
562 new_tab_css_ = base::RefCountedString::TakeString(&css_string); 562 new_tab_css_ = base::RefCountedString::TakeString(&css_string);
563 } 563 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/web_resource/notification_promo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698