diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-18 03:23:33 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-18 03:23:33 +0000 |
commit | 1df50c8de4ca23b55ac99e26497fe8ba5864b6f3 (patch) | |
tree | 572ce80a9d0d7270222b45ebd2ab801a90fc428d /chrome/browser/dom_ui | |
parent | c8ced031ff61f75ebe05b3ac4d2a27ab8936fc18 (diff) | |
download | chromium_src-1df50c8de4ca23b55ac99e26497fe8ba5864b6f3.zip chromium_src-1df50c8de4ca23b55ac99e26497fe8ba5864b6f3.tar.gz chromium_src-1df50c8de4ca23b55ac99e26497fe8ba5864b6f3.tar.bz2 |
Allow the tiling of theme background images on the NTP.
BUG= http://crbug/com/15796
TEST= Add a property for tiling to a theme manifest.json. Observe that the theme image is tiled on the NTP.
Review URL: http://codereview.chromium.org/149741
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/dom_ui_theme_source.cc | 21 | ||||
-rw-r--r-- | chrome/browser/dom_ui/dom_ui_theme_source.h | 4 |
2 files changed, 22 insertions, 3 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_theme_source.cc b/chrome/browser/dom_ui/dom_ui_theme_source.cc index edf9e07..d98c313 100644 --- a/chrome/browser/dom_ui/dom_ui_theme_source.cc +++ b/chrome/browser/dom_ui/dom_ui_theme_source.cc @@ -102,6 +102,9 @@ void DOMUIThemeSource::SendNewTabCSS(int request_id) { // Generate the replacements. std::vector<string16> subst; + // A second list of replacements, each of which must be in $$x format, + // where x is a digit from 1-9. + std::vector<string16> subst2; // Cache-buster for background. subst.push_back(UTF8ToUTF16(IntToString(static_cast<int>( @@ -117,6 +120,8 @@ void DOMUIThemeSource::SendNewTabCSS(int request_id) { subst.push_back(SkColorToRGBAString(color_section_text)); subst.push_back(SkColorToRGBAString(color_section_link)); + subst2.push_back(UTF8ToUTF16(GetNewTabBackgroundTilingCSS())); + // Get our template. static const StringPiece new_tab_theme_css( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -126,11 +131,13 @@ void DOMUIThemeSource::SendNewTabCSS(int request_id) { string16 format_string = ASCIIToUTF16(new_tab_theme_css.as_string()); const std::string css_string = UTF16ToASCII(ReplaceStringPlaceholders( format_string, subst, NULL)); + const std::string css_string2 = UTF16ToASCII(ReplaceStringPlaceholders( + ASCIIToUTF16(css_string), subst2, NULL)); // Convert to a format appropriate for sending. scoped_refptr<RefCountedBytes> css_bytes(new RefCountedBytes); - css_bytes->data.resize(css_string.size()); - std::copy(css_string.begin(), css_string.end(), css_bytes->data.begin()); + css_bytes->data.resize(css_string2.size()); + std::copy(css_string2.begin(), css_string2.end(), css_bytes->data.begin()); // Send. SendResponse(request_id, css_bytes); @@ -171,7 +178,15 @@ std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) { return "0% " + IntToString(-offset) + "px"; else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) return "100% " + IntToString(-offset) + "px"; - return IntToString(-offset) + "px"; + return "center " + IntToString(-offset) + "px"; } return BrowserThemeProvider::AlignmentToString(alignment); } + +std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { + int repeat_mode; + profile_->GetThemeProvider()->GetDisplayProperty( + BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); + return BrowserThemeProvider::TilingToString(repeat_mode); +} + diff --git a/chrome/browser/dom_ui/dom_ui_theme_source.h b/chrome/browser/dom_ui/dom_ui_theme_source.h index e31e21b..8be214f 100644 --- a/chrome/browser/dom_ui/dom_ui_theme_source.h +++ b/chrome/browser/dom_ui/dom_ui_theme_source.h @@ -35,6 +35,10 @@ class DOMUIThemeSource : public ChromeURLDataManager::DataSource { // states when the bar is attached or detached. std::string GetNewTabBackgroundCSS(bool bar_attached); + // How the background image on the new tab page should be tiled (see tiling + // masks in browser_theme_provider.h). + std::string GetNewTabBackgroundTilingCSS(); + Profile* profile_; DISALLOW_COPY_AND_ASSIGN(DOMUIThemeSource); }; |