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

Unified Diff: chrome/browser/browser_theme_provider.cc

Issue 149741: Allow the tiling of theme background images on the NTP.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser_theme_provider.h ('k') | chrome/browser/dom_ui/dom_ui_theme_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_theme_provider.cc
===================================================================
--- chrome/browser/browser_theme_provider.cc (revision 20990)
+++ chrome/browser/browser_theme_provider.cc (working copy)
@@ -64,6 +64,8 @@
// Strings used by themes to identify miscellaneous numerical properties.
const char* BrowserThemeProvider::kDisplayPropertyNTPAlignment =
"ntp_background_alignment";
+const char* BrowserThemeProvider::kDisplayPropertyNTPTiling =
+ "ntp_background_repeat";
// Strings used in alignment properties.
const char* BrowserThemeProvider::kAlignmentTop = "top";
@@ -71,6 +73,12 @@
const char* BrowserThemeProvider::kAlignmentLeft = "left";
const char* BrowserThemeProvider::kAlignmentRight = "right";
+// Strings used in background tiling repetition properties.
+const char* BrowserThemeProvider::kTilingNoRepeat = "no-repeat";
+const char* BrowserThemeProvider::kTilingRepeatX = "repeat-x";
+const char* BrowserThemeProvider::kTilingRepeatY = "repeat-y";
+const char* BrowserThemeProvider::kTilingRepeat = "repeat";
+
// Default colors.
const SkColor BrowserThemeProvider::kDefaultColorFrame =
SkColorSetRGB(77, 139, 217);
@@ -118,6 +126,8 @@
// Default display properties.
static const int kDefaultDisplayPropertyNTPAlignment =
BrowserThemeProvider::ALIGN_BOTTOM;
+static const int kDefaultDisplayPropertyNTPTiling =
+ BrowserThemeProvider::NO_REPEAT;
// The image resources that will be tinted by the 'button' tint value.
static const int kToolbarButtonIDs[] = {
@@ -264,6 +274,14 @@
*result = kDefaultDisplayPropertyNTPAlignment;
}
return true;
+ case NTP_BACKGROUND_TILING:
+ if (display_properties_.find(kDisplayPropertyNTPTiling) !=
+ display_properties_.end()) {
+ *result = display_properties_[kDisplayPropertyNTPTiling];
+ } else {
+ *result = kDefaultDisplayPropertyNTPTiling;
+ }
+ return true;
default:
NOTREACHED() << "Unknown property requested";
}
@@ -507,13 +525,19 @@
DictionaryValue::key_iterator iter = display_properties_value->begin_keys();
while (iter != display_properties_value->end_keys()) {
- // New tab page alignment.
+ // New tab page alignment and background tiling.
if (base::strcasecmp(WideToUTF8(*iter).c_str(),
kDisplayPropertyNTPAlignment) == 0) {
std::string val;
if (display_properties_value->GetString(*iter, &val))
display_properties_[kDisplayPropertyNTPAlignment] =
StringToAlignment(val);
+ } else if (base::strcasecmp(WideToUTF8(*iter).c_str(),
+ kDisplayPropertyNTPTiling) == 0) {
+ std::string val;
+ if (display_properties_value->GetString(*iter, &val))
+ display_properties_[kDisplayPropertyNTPTiling] =
+ StringToTiling(val);
}
++iter;
}
@@ -568,6 +592,33 @@
return vertical_string;
}
+// static
+int BrowserThemeProvider::StringToTiling(const std::string &tiling) {
+ const char* component = tiling.c_str();
+
+ if (base::strcasecmp(component, kTilingRepeatX) == 0)
+ return BrowserThemeProvider::REPEAT_X;
+ else if (base::strcasecmp(component, kTilingRepeatY) == 0)
+ return BrowserThemeProvider::REPEAT_Y;
+ else if (base::strcasecmp(component, kTilingRepeat) == 0)
+ return BrowserThemeProvider::REPEAT;
+ // NO_REPEAT is the default choice.
+ return BrowserThemeProvider::NO_REPEAT;
+}
+
+// static
+std::string BrowserThemeProvider::TilingToString(int tiling) {
+ // Convert from a TilingProperty back into a string.
+ if (tiling == BrowserThemeProvider::REPEAT_X)
+ return kTilingRepeatX;
+ else if (tiling == BrowserThemeProvider::REPEAT_Y)
+ return kTilingRepeatY;
+ else if (tiling == BrowserThemeProvider::REPEAT)
+ return kTilingRepeat;
+ else
+ return kTilingNoRepeat;
+}
+
void BrowserThemeProvider::SetColor(const char* key, const SkColor& color) {
colors_[key] = color;
}
@@ -742,6 +793,11 @@
pref_display_properties->
SetString(UTF8ToWide((*iter).first), AlignmentToString(
(*iter).second));
+ } else if (base::strcasecmp((*iter).first.c_str(),
+ kDisplayPropertyNTPTiling) == 0) {
+ pref_display_properties->
+ SetString(UTF8ToWide((*iter).first), TilingToString(
+ (*iter).second));
}
++iter;
}
« no previous file with comments | « chrome/browser/browser_theme_provider.h ('k') | chrome/browser/dom_ui/dom_ui_theme_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698