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

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

Issue 12013004: alternate ntp: unpinned bookmark bar in ntp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
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 <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 SkColor color = tp->GetColor(id); 113 SkColor color = tp->GetColor(id);
114 // If web contents are being inverted because the system is in high-contrast 114 // If web contents are being inverted because the system is in high-contrast
115 // mode, any system theme colors we use must be inverted too to cancel out. 115 // mode, any system theme colors we use must be inverted too to cancel out.
116 return gfx::IsInvertedColorScheme() ? 116 return gfx::IsInvertedColorScheme() ?
117 color_utils::InvertColor(color) : color; 117 color_utils::InvertColor(color) : color;
118 } 118 }
119 119
120 // Get the CSS string for the background position on the new tab page for the 120 // Get the CSS string for the background position on the new tab page for the
121 // states when the bar is attached or detached. 121 // states when the bar is attached or detached.
122 std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, 122 std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider,
123 bool bar_attached, 123 bool bar_attached) {
124 bool is_ntp_search) {
125 int alignment; 124 int alignment;
126 theme_provider->GetDisplayProperty( 125 theme_provider->GetDisplayProperty(
127 ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); 126 ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment);
128 127
129 // TODO(glen): This is a quick workaround to hide the notused.png image when 128 // TODO(glen): This is a quick workaround to hide the notused.png image when
130 // no image is provided - we don't have time right now to figure out why 129 // no image is provided - we don't have time right now to figure out why
131 // this is painting as white. 130 // this is painting as white.
132 // http://crbug.com/17593 131 // http://crbug.com/17593
133 if (!theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { 132 if (!theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
134 return "-64px"; 133 return "-64px";
135 } 134 }
136 135
137 // For instant extended API i.e. |is_ntp_search| is true, bookmark bar is 136 if (bar_attached)
138 // always detached at bottom of content view in the y-direction, floating on
139 // top of it in the z-order, and not showing any part of the theme background
140 // image, so the content view should show the entire theme background image as
141 // is, with no vertical offset.
142 if (bar_attached || is_ntp_search)
143 return ThemeService::AlignmentToString(alignment); 137 return ThemeService::AlignmentToString(alignment);
144 138
145 if (alignment & ThemeService::ALIGN_TOP) { 139 if (alignment & ThemeService::ALIGN_TOP) {
146 // The bar is detached, so we must offset the background by the bar size 140 // The bar is detached, so we must offset the background by the bar size
147 // if it's a top-aligned bar. 141 // if it's a top-aligned bar.
148 int offset = chrome::kNTPBookmarkBarHeight; 142 int offset = chrome::kNTPBookmarkBarHeight;
149 143
150 if (alignment & ThemeService::ALIGN_LEFT) 144 if (alignment & ThemeService::ALIGN_LEFT)
151 return "left " + base::IntToString(-offset) + "px"; 145 return "left " + base::IntToString(-offset) + "px";
152 else if (alignment & ThemeService::ALIGN_RIGHT) 146 else if (alignment & ThemeService::ALIGN_RIGHT)
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 SkColor color_background = 468 SkColor color_background =
475 GetThemeColor(tp, ThemeService::COLOR_NTP_BACKGROUND); 469 GetThemeColor(tp, ThemeService::COLOR_NTP_BACKGROUND);
476 470
477 // Generate the replacements. 471 // Generate the replacements.
478 std::vector<std::string> subst; 472 std::vector<std::string> subst;
479 473
480 // Cache-buster for background. 474 // Cache-buster for background.
481 subst.push_back( 475 subst.push_back(
482 profile_->GetPrefs()->GetString(prefs::kCurrentThemeID)); // $1 476 profile_->GetPrefs()->GetString(prefs::kCurrentThemeID)); // $1
483 477
484 bool is_ntp_search = chrome::search::IsInstantExtendedAPIEnabled(profile_);
485
486 // Colors. 478 // Colors.
487 subst.push_back(SkColorToRGBAString(color_background)); // $2 479 subst.push_back(SkColorToRGBAString(color_background)); // $2
488 subst.push_back(GetNewTabBackgroundCSS(tp, false, is_ntp_search)); // $3 480 subst.push_back(GetNewTabBackgroundCSS(tp, false)); // $3
489 subst.push_back(GetNewTabBackgroundCSS(tp, true, is_ntp_search)); // $4 481 subst.push_back(GetNewTabBackgroundCSS(tp, true)); // $4
490 subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5 482 subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5
491 483
492 // Get our template. 484 // Get our template.
493 static const base::StringPiece new_tab_theme_css( 485 static const base::StringPiece new_tab_theme_css(
494 ResourceBundle::GetSharedInstance().GetRawDataResource( 486 ResourceBundle::GetSharedInstance().GetRawDataResource(
495 IDR_NEW_INCOGNITO_TAB_THEME_CSS)); 487 IDR_NEW_INCOGNITO_TAB_THEME_CSS));
496 488
497 // Create the string from our template and the replacements. 489 // Create the string from our template and the replacements.
498 std::string full_css = ReplaceStringPlaceholders( 490 std::string full_css = ReplaceStringPlaceholders(
499 new_tab_theme_css, subst, NULL); 491 new_tab_theme_css, subst, NULL);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 SkColorGetG(color_header), 542 SkColorGetG(color_header),
551 SkColorGetB(color_header)); 543 SkColorGetB(color_header));
552 544
553 // Generate the replacements. 545 // Generate the replacements.
554 std::vector<std::string> subst; 546 std::vector<std::string> subst;
555 547
556 // Cache-buster for background. 548 // Cache-buster for background.
557 subst.push_back( 549 subst.push_back(
558 profile_->GetPrefs()->GetString(prefs::kCurrentThemeID)); // $1 550 profile_->GetPrefs()->GetString(prefs::kCurrentThemeID)); // $1
559 551
560 bool is_ntp_search = chrome::search::IsInstantExtendedAPIEnabled(profile_);
561
562 // Colors. 552 // Colors.
563 subst.push_back(SkColorToRGBAString(color_background)); // $2 553 subst.push_back(SkColorToRGBAString(color_background)); // $2
564 subst.push_back(GetNewTabBackgroundCSS(tp, false, is_ntp_search)); // $3 554 subst.push_back(GetNewTabBackgroundCSS(tp, false)); // $3
565 subst.push_back(GetNewTabBackgroundCSS(tp, true, is_ntp_search)); // $4 555 subst.push_back(GetNewTabBackgroundCSS(tp, true)); // $4
566 subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5 556 subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5
567 subst.push_back(SkColorToRGBAString(color_header)); // $6 557 subst.push_back(SkColorToRGBAString(color_header)); // $6
568 subst.push_back(SkColorToRGBAString(color_header_gradient_light)); // $7 558 subst.push_back(SkColorToRGBAString(color_header_gradient_light)); // $7
569 subst.push_back(SkColorToRGBAString(color_text)); // $8 559 subst.push_back(SkColorToRGBAString(color_text)); // $8
570 subst.push_back(SkColorToRGBAString(color_link)); // $9 560 subst.push_back(SkColorToRGBAString(color_link)); // $9
571 subst.push_back(SkColorToRGBAString(color_section)); // $10 561 subst.push_back(SkColorToRGBAString(color_section)); // $10
572 subst.push_back(SkColorToRGBAString(color_section_border)); // $11 562 subst.push_back(SkColorToRGBAString(color_section_border)); // $11
573 subst.push_back(SkColorToRGBAString(color_section_text)); // $12 563 subst.push_back(SkColorToRGBAString(color_section_text)); // $12
574 subst.push_back(SkColorToRGBAString(color_section_link)); // $13 564 subst.push_back(SkColorToRGBAString(color_section_link)); // $13
575 subst.push_back(SkColorToRGBAString(color_link_underline)); // $14 565 subst.push_back(SkColorToRGBAString(color_link_underline)); // $14
576 subst.push_back(SkColorToRGBAString(color_section_link_underline)); // $15 566 subst.push_back(SkColorToRGBAString(color_section_link_underline)); // $15
577 subst.push_back(SkColorToRGBAString(color_section_header_text)); // $16 567 subst.push_back(SkColorToRGBAString(color_section_header_text)); // $16
578 subst.push_back(SkColorToRGBAString( 568 subst.push_back(SkColorToRGBAString(
579 color_section_header_text_hover)); // $17 569 color_section_header_text_hover)); // $17
580 subst.push_back(SkColorToRGBAString(color_section_header_rule)); // $18 570 subst.push_back(SkColorToRGBAString(color_section_header_rule)); // $18
581 subst.push_back(SkColorToRGBAString( 571 subst.push_back(SkColorToRGBAString(
582 color_section_header_rule_light)); // $19 572 color_section_header_rule_light)); // $19
583 subst.push_back(SkColorToRGBAString( 573 subst.push_back(SkColorToRGBAString(
584 SkColorSetA(color_section_header_rule, 0))); // $20 574 SkColorSetA(color_section_header_rule, 0))); // $20
585 subst.push_back(SkColorToRGBAString(color_text_light)); // $21 575 subst.push_back(SkColorToRGBAString(color_text_light)); // $21
586 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22 576 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22
587 subst.push_back(SkColorToRGBComponents(color_text)); // $23 577 subst.push_back(SkColorToRGBComponents(color_text)); // $23
588 578
589 // Get our template. 579 // Get our template.
590 static const base::StringPiece new_tab_theme_css( 580 static const base::StringPiece new_tab_theme_css(
591 ResourceBundle::GetSharedInstance().GetRawDataResource(is_ntp_search ? 581 ResourceBundle::GetSharedInstance().GetRawDataResource(
582 chrome::search::IsInstantExtendedAPIEnabled(profile_) ?
592 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS)); 583 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS));
593 584
594 // Create the string from our template and the replacements. 585 // Create the string from our template and the replacements.
595 std::string css_string; 586 std::string css_string;
596 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 587 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
597 new_tab_css_ = base::RefCountedString::TakeString(&css_string); 588 new_tab_css_ = base::RefCountedString::TakeString(&css_string);
598 } 589 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/instant_preview_controller_views.cc ('k') | ui/views/controls/button/text_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698