diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-18 18:55:39 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-18 18:55:39 +0000 |
commit | e119b80b91009a120b1e98eb9afdfb163a132ffc (patch) | |
tree | f804cbdc93478f4c8b6440f013b804ea04e4eaed | |
parent | 94e3081488a6f27dd8b9c7c287a9d0c11e3baa3b (diff) | |
download | chromium_src-e119b80b91009a120b1e98eb9afdfb163a132ffc.zip chromium_src-e119b80b91009a120b1e98eb9afdfb163a132ffc.tar.gz chromium_src-e119b80b91009a120b1e98eb9afdfb163a132ffc.tar.bz2 |
Split out the static methods from ThemeService to ThemeProperties.
The goal of this change is to make BrowserThemePack not depend on ThemeService anymore and to make it clearer as
to which changes require updating the version number in
browser_theme_pack.h
BUG=None
Test=None
Review URL: https://chromiumcodereview.appspot.com/12207103
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183134 0039d316-1c4b-4281-b951-d872f2087c98
69 files changed, 1090 insertions, 968 deletions
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc index 254a34f..cd928ce 100644 --- a/chrome/browser/devtools/devtools_window.cc +++ b/chrome/browser/devtools/devtools_window.cc @@ -22,6 +22,7 @@ #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/session_tab_helper.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" @@ -581,9 +582,9 @@ GURL DevToolsWindow::GetDevToolsUrl(Profile* profile, CHECK(tp); SkColor color_toolbar = - tp->GetColor(ThemeService::COLOR_TOOLBAR); + tp->GetColor(ThemeProperties::COLOR_TOOLBAR); SkColor color_tab_text = - tp->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); + tp->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); const CommandLine& command_line = *CommandLine::ForCurrentProcess(); bool experiments_enabled = @@ -605,9 +606,9 @@ void DevToolsWindow::UpdateTheme() { CHECK(tp); SkColor color_toolbar = - tp->GetColor(ThemeService::COLOR_TOOLBAR); + tp->GetColor(ThemeProperties::COLOR_TOOLBAR); SkColor color_tab_text = - tp->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); + tp->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); std::string command = StringPrintf( "InspectorFrontendAPI.setToolbarColors(\"%s\", \"%s\")", SkColorToRGBAString(color_toolbar).c_str(), diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index 9755502..d6e18ce 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -14,7 +14,7 @@ #include "base/threading/thread_restrictions.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/common/extensions/api/themes/theme_handler.h" #include "content/public/browser/browser_thread.h" #include "grit/theme_resources.h" @@ -41,7 +41,7 @@ namespace { // Version number of the current theme pack. We just throw out and rebuild // theme packs that aren't int-equal to this. Increment this number if you // change default theme assets. -const int kThemePackVersion = 27; +const int kThemePackVersion = 28; // IDs that are in the DataPack won't clash with the positive integer // uint16. kHeaderID should always have the maximum value because we want the @@ -56,11 +56,6 @@ const int kDisplayPropertiesID = kMaxID - 4; const int kSourceImagesID = kMaxID - 5; const int kScaleFactorsID = kMaxID - 6; -// Static size of the tint/color/display property arrays that are mmapped. -const int kTintArraySize = 6; -const int kColorArraySize = 18; -const int kDisplayPropertySize = 3; - // The sum of kFrameBorderThickness and kNonClientRestoredExtraThickness from // OpaqueBrowserFrameView. const int kRestoredTabVerticalOffset = 15; @@ -163,7 +158,7 @@ PersistingImagesTable kPersistingImages[] = { { 44, IDR_THROBBER_WAITING, NULL }, { 45, IDR_THROBBER_LIGHT, NULL }, }; -size_t kPersistingImagesLength = arraysize(kPersistingImages); +const size_t kPersistingImagesLength = arraysize(kPersistingImages); int GetPersistentIDByName(const std::string& key) { for (size_t i = 0; i < kPersistingImagesLength; ++i) { @@ -220,66 +215,59 @@ std::string GetScaleFactorsAsString( struct StringToIntTable { const char* key; - int id; + ThemeProperties::OverwritableByUserThemeProperty id; }; // Strings used by themes to identify tints in the JSON. StringToIntTable kTintTable[] = { - { "buttons", ThemeService::TINT_BUTTONS }, - { "frame", ThemeService::TINT_FRAME }, - { "frame_inactive", ThemeService::TINT_FRAME_INACTIVE }, - { "frame_incognito", ThemeService::TINT_FRAME_INCOGNITO }, + { "buttons", ThemeProperties::TINT_BUTTONS }, + { "frame", ThemeProperties::TINT_FRAME }, + { "frame_inactive", ThemeProperties::TINT_FRAME_INACTIVE }, + { "frame_incognito", ThemeProperties::TINT_FRAME_INCOGNITO }, { "frame_incognito_inactive", - ThemeService::TINT_FRAME_INCOGNITO_INACTIVE }, - { "background_tab", ThemeService::TINT_BACKGROUND_TAB }, - { NULL, 0 } + ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, + { "background_tab", ThemeProperties::TINT_BACKGROUND_TAB }, }; +const size_t kTintTableLength = arraysize(kTintTable); // Strings used by themes to identify colors in the JSON. StringToIntTable kColorTable[] = { - { "frame", ThemeService::COLOR_FRAME }, - { "frame_inactive", ThemeService::COLOR_FRAME_INACTIVE }, - { "frame_incognito", ThemeService::COLOR_FRAME_INCOGNITO }, + { "frame", ThemeProperties::COLOR_FRAME }, + { "frame_inactive", ThemeProperties::COLOR_FRAME_INACTIVE }, + { "frame_incognito", ThemeProperties::COLOR_FRAME_INCOGNITO }, { "frame_incognito_inactive", - ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE }, - { "toolbar", ThemeService::COLOR_TOOLBAR }, - { "tab_text", ThemeService::COLOR_TAB_TEXT }, - { "tab_background_text", ThemeService::COLOR_BACKGROUND_TAB_TEXT }, - { "bookmark_text", ThemeService::COLOR_BOOKMARK_TEXT }, - { "ntp_background", ThemeService::COLOR_NTP_BACKGROUND }, - { "ntp_text", ThemeService::COLOR_NTP_TEXT }, - { "ntp_link", ThemeService::COLOR_NTP_LINK }, - { "ntp_link_underline", ThemeService::COLOR_NTP_LINK_UNDERLINE }, - { "ntp_header", ThemeService::COLOR_NTP_HEADER }, - { "ntp_section", ThemeService::COLOR_NTP_SECTION }, - { "ntp_section_text", ThemeService::COLOR_NTP_SECTION_TEXT }, - { "ntp_section_link", ThemeService::COLOR_NTP_SECTION_LINK }, + ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE }, + { "toolbar", ThemeProperties::COLOR_TOOLBAR }, + { "tab_text", ThemeProperties::COLOR_TAB_TEXT }, + { "tab_background_text", ThemeProperties::COLOR_BACKGROUND_TAB_TEXT }, + { "bookmark_text", ThemeProperties::COLOR_BOOKMARK_TEXT }, + { "ntp_background", ThemeProperties::COLOR_NTP_BACKGROUND }, + { "ntp_text", ThemeProperties::COLOR_NTP_TEXT }, + { "ntp_link", ThemeProperties::COLOR_NTP_LINK }, + { "ntp_link_underline", ThemeProperties::COLOR_NTP_LINK_UNDERLINE }, + { "ntp_header", ThemeProperties::COLOR_NTP_HEADER }, + { "ntp_section", ThemeProperties::COLOR_NTP_SECTION }, + { "ntp_section_text", ThemeProperties::COLOR_NTP_SECTION_TEXT }, + { "ntp_section_link", ThemeProperties::COLOR_NTP_SECTION_LINK }, { "ntp_section_link_underline", - ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE }, - { "button_background", ThemeService::COLOR_BUTTON_BACKGROUND }, - { NULL, 0 } + ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE }, + { "button_background", ThemeProperties::COLOR_BUTTON_BACKGROUND }, }; +const size_t kColorTableLength = arraysize(kColorTable); // Strings used by themes to identify display properties keys in JSON. StringToIntTable kDisplayProperties[] = { { "ntp_background_alignment", - ThemeService::NTP_BACKGROUND_ALIGNMENT }, - { "ntp_background_repeat", ThemeService::NTP_BACKGROUND_TILING }, - { "ntp_logo_alternate", ThemeService::NTP_LOGO_ALTERNATE }, - { NULL, 0 } -}; - -// Strings used by the tiling values in JSON. -StringToIntTable kTilingStrings[] = { - { "no-repeat", ThemeService::NO_REPEAT }, - { "repeat-x", ThemeService::REPEAT_X }, - { "repeat-y", ThemeService::REPEAT_Y }, - { "repeat", ThemeService::REPEAT }, - { NULL, 0 } + ThemeProperties::NTP_BACKGROUND_ALIGNMENT }, + { "ntp_background_repeat", ThemeProperties::NTP_BACKGROUND_TILING }, + { "ntp_logo_alternate", ThemeProperties::NTP_LOGO_ALTERNATE }, }; +const size_t kDisplayPropertiesSize = arraysize(kDisplayProperties); -int GetIntForString(const std::string& key, StringToIntTable* table) { - for (int i = 0; table[i].key != NULL; ++i) { +int GetIntForString(const std::string& key, + StringToIntTable* table, + size_t table_length) { + for (size_t i = 0; i < table_length; ++i) { if (base::strcasecmp(key.c_str(), table[i].key) == 0) { return table[i].id; } @@ -296,14 +284,14 @@ struct IntToIntTable { // Mapping used in GenerateFrameImages() to associate frame images with the // tint ID that should maybe be applied to it. IntToIntTable kFrameTintMap[] = { - { PRS_THEME_FRAME, ThemeService::TINT_FRAME }, - { PRS_THEME_FRAME_INACTIVE, ThemeService::TINT_FRAME_INACTIVE }, - { PRS_THEME_FRAME_OVERLAY, ThemeService::TINT_FRAME }, + { PRS_THEME_FRAME, ThemeProperties::TINT_FRAME }, + { PRS_THEME_FRAME_INACTIVE, ThemeProperties::TINT_FRAME_INACTIVE }, + { PRS_THEME_FRAME_OVERLAY, ThemeProperties::TINT_FRAME }, { PRS_THEME_FRAME_OVERLAY_INACTIVE, - ThemeService::TINT_FRAME_INACTIVE }, - { PRS_THEME_FRAME_INCOGNITO, ThemeService::TINT_FRAME_INCOGNITO }, + ThemeProperties::TINT_FRAME_INACTIVE }, + { PRS_THEME_FRAME_INCOGNITO, ThemeProperties::TINT_FRAME_INCOGNITO }, { PRS_THEME_FRAME_INCOGNITO_INACTIVE, - ThemeService::TINT_FRAME_INCOGNITO_INACTIVE } + ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE } }; // Mapping used in GenerateTabBackgroundImages() to associate what frame image @@ -359,7 +347,7 @@ gfx::Image* CreateHSLShiftedImage(const gfx::Image& image, // if the ImageSkiaRep for the target scale factor isn't available. class ThemeImageSource: public gfx::ImageSkiaSource { public: - ThemeImageSource(const gfx::ImageSkia& source) : source_(source) { + explicit ThemeImageSource(const gfx::ImageSkia& source) : source_(source) { } virtual ~ThemeImageSource() {} @@ -562,13 +550,14 @@ bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const { resources[kHeaderID] = base::StringPiece( reinterpret_cast<const char*>(header_), sizeof(BrowserThemePackHeader)); resources[kTintsID] = base::StringPiece( - reinterpret_cast<const char*>(tints_), sizeof(TintEntry[kTintArraySize])); + reinterpret_cast<const char*>(tints_), + sizeof(TintEntry[kTintTableLength])); resources[kColorsID] = base::StringPiece( reinterpret_cast<const char*>(colors_), - sizeof(ColorPair[kColorArraySize])); + sizeof(ColorPair[kColorTableLength])); resources[kDisplayPropertiesID] = base::StringPiece( reinterpret_cast<const char*>(display_properties_), - sizeof(DisplayPropertyPair[kDisplayPropertySize])); + sizeof(DisplayPropertyPair[kDisplayPropertiesSize])); int source_count = 1; int* end = source_images_; @@ -594,7 +583,7 @@ bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const { bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const { if (tints_) { - for (int i = 0; i < kTintArraySize; ++i) { + for (size_t i = 0; i < kTintTableLength; ++i) { if (tints_[i].id == id) { hsl->h = tints_[i].h; hsl->s = tints_[i].s; @@ -609,7 +598,7 @@ bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const { bool BrowserThemePack::GetColor(int id, SkColor* color) const { if (colors_) { - for (int i = 0; i < kColorArraySize; ++i) { + for (size_t i = 0; i < kColorTableLength; ++i) { if (colors_[i].id == id) { *color = colors_[i].color; return true; @@ -622,7 +611,7 @@ bool BrowserThemePack::GetColor(int id, SkColor* color) const { bool BrowserThemePack::GetDisplayProperty(int id, int* result) const { if (display_properties_) { - for (int i = 0; i < kDisplayPropertySize; ++i) { + for (size_t i = 0; i < kDisplayPropertiesSize; ++i) { if (display_properties_[i].id == id) { *result = display_properties_[i].property; return true; @@ -694,6 +683,16 @@ base::RefCountedMemory* BrowserThemePack::GetRawData( return memory; } +// static +void BrowserThemePack::GetThemeableImageIDRs(std::set<int>* result) { + if (!result) + return; + + result->clear(); + for (size_t i = 0; i < kPersistingImagesLength; ++i) + result->insert(kPersistingImages[i].idr_id); +} + bool BrowserThemePack::HasCustomImage(int idr_id) const { int prs_id = GetPersistentIDByIDR(idr_id); if (prs_id == -1) @@ -740,8 +739,8 @@ void BrowserThemePack::BuildHeader(const Extension* extension) { } void BrowserThemePack::BuildTintsFromJSON(DictionaryValue* tints_value) { - tints_ = new TintEntry[kTintArraySize]; - for (int i = 0; i < kTintArraySize; ++i) { + tints_ = new TintEntry[kTintTableLength]; + for (size_t i = 0; i < kTintTableLength; ++i) { tints_[i].id = -1; tints_[i].h = -1; tints_[i].s = -1; @@ -763,7 +762,7 @@ void BrowserThemePack::BuildTintsFromJSON(DictionaryValue* tints_value) { if (tint_list->GetDouble(0, &hsl.h) && tint_list->GetDouble(1, &hsl.s) && tint_list->GetDouble(2, &hsl.l)) { - int id = GetIntForString(*iter, kTintTable); + int id = GetIntForString(*iter, kTintTable, kTintTableLength); if (id != -1) { temp_tints[id] = hsl; } @@ -772,9 +771,10 @@ void BrowserThemePack::BuildTintsFromJSON(DictionaryValue* tints_value) { } // Copy data from the intermediary data structure to the array. - int count = 0; + size_t count = 0; for (std::map<int, color_utils::HSL>::const_iterator it = - temp_tints.begin(); it != temp_tints.end() && count < kTintArraySize; + temp_tints.begin(); + it != temp_tints.end() && count < kTintTableLength; ++it, ++count) { tints_[count].id = it->first; tints_[count].h = it->second.h; @@ -784,8 +784,8 @@ void BrowserThemePack::BuildTintsFromJSON(DictionaryValue* tints_value) { } void BrowserThemePack::BuildColorsFromJSON(DictionaryValue* colors_value) { - colors_ = new ColorPair[kColorArraySize]; - for (int i = 0; i < kColorArraySize; ++i) { + colors_ = new ColorPair[kColorTableLength]; + for (size_t i = 0; i < kColorTableLength; ++i) { colors_[i].id = -1; colors_[i].color = SkColorSetRGB(0, 0, 0); } @@ -796,9 +796,9 @@ void BrowserThemePack::BuildColorsFromJSON(DictionaryValue* colors_value) { GenerateMissingColors(&temp_colors); // Copy data from the intermediary data structure to the array. - int count = 0; + size_t count = 0; for (std::map<int, SkColor>::const_iterator it = temp_colors.begin(); - it != temp_colors.end() && count < kColorArraySize; ++it, ++count) { + it != temp_colors.end() && count < kColorTableLength; ++it, ++count) { colors_[count].id = it->first; colors_[count].color = it->second; } @@ -834,7 +834,7 @@ void BrowserThemePack::ReadColorsFromJSON( color = SkColorSetRGB(r, g, b); } - int id = GetIntForString(*iter, kColorTable); + int id = GetIntForString(*iter, kColorTable, kColorTableLength); if (id != -1) { (*temp_colors)[id] = color; } @@ -846,63 +846,63 @@ void BrowserThemePack::ReadColorsFromJSON( void BrowserThemePack::GenerateMissingColors( std::map<int, SkColor>* colors) { // Generate link colors, if missing. (See GetColor()). - if (!colors->count(ThemeService::COLOR_NTP_HEADER) && - colors->count(ThemeService::COLOR_NTP_SECTION)) { - (*colors)[ThemeService::COLOR_NTP_HEADER] = - (*colors)[ThemeService::COLOR_NTP_SECTION]; + if (!colors->count(ThemeProperties::COLOR_NTP_HEADER) && + colors->count(ThemeProperties::COLOR_NTP_SECTION)) { + (*colors)[ThemeProperties::COLOR_NTP_HEADER] = + (*colors)[ThemeProperties::COLOR_NTP_SECTION]; } - if (!colors->count(ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE) && - colors->count(ThemeService::COLOR_NTP_SECTION_LINK)) { + if (!colors->count(ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE) && + colors->count(ThemeProperties::COLOR_NTP_SECTION_LINK)) { SkColor color_section_link = - (*colors)[ThemeService::COLOR_NTP_SECTION_LINK]; - (*colors)[ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE] = + (*colors)[ThemeProperties::COLOR_NTP_SECTION_LINK]; + (*colors)[ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE] = SkColorSetA(color_section_link, SkColorGetA(color_section_link) / 3); } - if (!colors->count(ThemeService::COLOR_NTP_LINK_UNDERLINE) && - colors->count(ThemeService::COLOR_NTP_LINK)) { - SkColor color_link = (*colors)[ThemeService::COLOR_NTP_LINK]; - (*colors)[ThemeService::COLOR_NTP_LINK_UNDERLINE] = + if (!colors->count(ThemeProperties::COLOR_NTP_LINK_UNDERLINE) && + colors->count(ThemeProperties::COLOR_NTP_LINK)) { + SkColor color_link = (*colors)[ThemeProperties::COLOR_NTP_LINK]; + (*colors)[ThemeProperties::COLOR_NTP_LINK_UNDERLINE] = SkColorSetA(color_link, SkColorGetA(color_link) / 3); } // Generate frame colors, if missing. (See GenerateFrameColors()). SkColor frame; std::map<int, SkColor>::const_iterator it = - colors->find(ThemeService::COLOR_FRAME); + colors->find(ThemeProperties::COLOR_FRAME); if (it != colors->end()) { frame = it->second; } else { - frame = ThemeService::GetDefaultColor( - ThemeService::COLOR_FRAME); + frame = ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_FRAME); } - if (!colors->count(ThemeService::COLOR_FRAME)) { - (*colors)[ThemeService::COLOR_FRAME] = - HSLShift(frame, GetTintInternal(ThemeService::TINT_FRAME)); + if (!colors->count(ThemeProperties::COLOR_FRAME)) { + (*colors)[ThemeProperties::COLOR_FRAME] = + HSLShift(frame, GetTintInternal(ThemeProperties::TINT_FRAME)); } - if (!colors->count(ThemeService::COLOR_FRAME_INACTIVE)) { - (*colors)[ThemeService::COLOR_FRAME_INACTIVE] = + if (!colors->count(ThemeProperties::COLOR_FRAME_INACTIVE)) { + (*colors)[ThemeProperties::COLOR_FRAME_INACTIVE] = HSLShift(frame, GetTintInternal( - ThemeService::TINT_FRAME_INACTIVE)); + ThemeProperties::TINT_FRAME_INACTIVE)); } - if (!colors->count(ThemeService::COLOR_FRAME_INCOGNITO)) { - (*colors)[ThemeService::COLOR_FRAME_INCOGNITO] = + if (!colors->count(ThemeProperties::COLOR_FRAME_INCOGNITO)) { + (*colors)[ThemeProperties::COLOR_FRAME_INCOGNITO] = HSLShift(frame, GetTintInternal( - ThemeService::TINT_FRAME_INCOGNITO)); + ThemeProperties::TINT_FRAME_INCOGNITO)); } - if (!colors->count(ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE)) { - (*colors)[ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE] = + if (!colors->count(ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE)) { + (*colors)[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = HSLShift(frame, GetTintInternal( - ThemeService::TINT_FRAME_INCOGNITO_INACTIVE)); + ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE)); } } void BrowserThemePack::BuildDisplayPropertiesFromJSON( DictionaryValue* display_properties_value) { - display_properties_ = new DisplayPropertyPair[kDisplayPropertySize]; - for (int i = 0; i < kDisplayPropertySize; ++i) { + display_properties_ = new DisplayPropertyPair[kDisplayPropertiesSize]; + for (size_t i = 0; i < kDisplayPropertiesSize; ++i) { display_properties_[i].id = -1; display_properties_[i].property = 0; } @@ -914,37 +914,38 @@ void BrowserThemePack::BuildDisplayPropertiesFromJSON( for (DictionaryValue::key_iterator iter( display_properties_value->begin_keys()); iter != display_properties_value->end_keys(); ++iter) { - int property_id = GetIntForString(*iter, kDisplayProperties); + int property_id = GetIntForString(*iter, kDisplayProperties, + kDisplayPropertiesSize); switch (property_id) { - case ThemeService::NTP_BACKGROUND_ALIGNMENT: { + case ThemeProperties::NTP_BACKGROUND_ALIGNMENT: { std::string val; if (display_properties_value->GetString(*iter, &val)) { - temp_properties[ThemeService::NTP_BACKGROUND_ALIGNMENT] = - ThemeService::StringToAlignment(val); + temp_properties[ThemeProperties::NTP_BACKGROUND_ALIGNMENT] = + ThemeProperties::StringToAlignment(val); } break; } - case ThemeService::NTP_BACKGROUND_TILING: { + case ThemeProperties::NTP_BACKGROUND_TILING: { std::string val; if (display_properties_value->GetString(*iter, &val)) { - temp_properties[ThemeService::NTP_BACKGROUND_TILING] = - GetIntForString(val, kTilingStrings); + temp_properties[ThemeProperties::NTP_BACKGROUND_TILING] = + ThemeProperties::StringToTiling(val); } break; } - case ThemeService::NTP_LOGO_ALTERNATE: { + case ThemeProperties::NTP_LOGO_ALTERNATE: { int val = 0; if (display_properties_value->GetInteger(*iter, &val)) - temp_properties[ThemeService::NTP_LOGO_ALTERNATE] = val; + temp_properties[ThemeProperties::NTP_LOGO_ALTERNATE] = val; break; } } } // Copy data from the intermediary data structure to the array. - int count = 0; + size_t count = 0; for (std::map<int, int>::const_iterator it = temp_properties.begin(); - it != temp_properties.end() && count < kDisplayPropertySize; + it != temp_properties.end() && count < kDisplayPropertiesSize; ++it, ++count) { display_properties_[count].id = it->first; display_properties_[count].property = it->second; @@ -1029,7 +1030,7 @@ bool BrowserThemePack::LoadRawBitmapsTo( void BrowserThemePack::CreateImages(ImageCache* images) const { CreateFrameImages(images); - CreateTintedButtons(GetTintInternal(ThemeService::TINT_BUTTONS), images); + CreateTintedButtons(GetTintInternal(ThemeProperties::TINT_BUTTONS), images); CreateTabBackgroundImages(images); } @@ -1092,7 +1093,7 @@ void BrowserThemePack::CreateTintedButtons( if (button_tint.h != -1 || button_tint.s != -1 || button_tint.l != -1) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); const std::set<int>& idr_ids = - ThemeService::GetTintableToolbarButtons(); + ThemeProperties::GetTintableToolbarButtons(); for (std::set<int>::const_iterator it = idr_ids.begin(); it != idr_ids.end(); ++it) { int prs_id = GetPersistentIDByIDR(*it); @@ -1120,7 +1121,7 @@ void BrowserThemePack::CreateTabBackgroundImages(ImageCache* images) const { if (it != images->end()) { const gfx::ImageSkia* image_to_tint = (it->second)->ToImageSkia(); color_utils::HSL hsl_shift = GetTintInternal( - ThemeService::TINT_BACKGROUND_TAB); + ThemeProperties::TINT_BACKGROUND_TAB); int vertical_offset = images->count(prs_id) ? kRestoredTabVerticalOffset : 0; @@ -1197,7 +1198,7 @@ void BrowserThemePack::AddRawImagesTo(const RawImages& images, color_utils::HSL BrowserThemePack::GetTintInternal(int id) const { if (tints_) { - for (int i = 0; i < kTintArraySize; ++i) { + for (size_t i = 0; i < kTintTableLength; ++i) { if (tints_[i].id == id) { color_utils::HSL hsl; hsl.h = tints_[i].h; @@ -1208,7 +1209,7 @@ color_utils::HSL BrowserThemePack::GetTintInternal(int id) const { } } - return ThemeService::GetDefaultTint(id); + return ThemeProperties::GetDefaultTint(id); } int BrowserThemePack::GetRawIDByPersistentID( diff --git a/chrome/browser/themes/browser_theme_pack.h b/chrome/browser/themes/browser_theme_pack.h index 6447566..ce5b318 100644 --- a/chrome/browser/themes/browser_theme_pack.h +++ b/chrome/browser/themes/browser_theme_pack.h @@ -15,6 +15,7 @@ #include "base/sequenced_task_runner_helpers.h" #include "chrome/common/extensions/extension.h" #include "content/public/browser/browser_thread.h" +#include "third_party/skia/include/core/SkColor.h" #include "ui/base/layout.h" #include "ui/gfx/color_utils.h" @@ -91,6 +92,10 @@ class BrowserThemePack : public base::RefCountedThreadSafe< base::RefCountedMemory* GetRawData(int id, ui::ScaleFactor scale_factor) const; + // Returns the set of image idrs which can be overwritten by a user provided + // theme. + static void GetThemeableImageIDRs(std::set<int>* result); + // Whether this theme provides an image for |id|. bool HasCustomImage(int id) const; diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc index a297bd9..e1f22d6 100644 --- a/chrome/browser/themes/browser_theme_pack_unittest.cc +++ b/chrome/browser/themes/browser_theme_pack_unittest.cc @@ -11,7 +11,7 @@ #include "base/message_loop.h" #include "base/path_service.h" #include "base/values.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/api/themes/theme_handler.h" #include "chrome/common/extensions/extension_manifest_constants.h" @@ -48,9 +48,9 @@ class BrowserThemePackTest : public ::testing::Test { void GenerateDefaultFrameColor(std::map<int, SkColor>* colors, int color, int tint) { (*colors)[color] = HSLShift( - ThemeService::GetDefaultColor( - ThemeService::COLOR_FRAME), - ThemeService::GetDefaultTint(tint)); + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_FRAME), + ThemeProperties::GetDefaultTint(tint)); } // Returns a mapping from each COLOR_* constant to the default value for this @@ -58,23 +58,23 @@ class BrowserThemePackTest : public ::testing::Test { // run the resulting thing through VerifyColorMap(). std::map<int, SkColor> GetDefaultColorMap() { std::map<int, SkColor> colors; - for (int i = ThemeService::COLOR_FRAME; - i <= ThemeService::COLOR_BUTTON_BACKGROUND; ++i) { - colors[i] = ThemeService::GetDefaultColor(i); + for (int i = ThemeProperties::COLOR_FRAME; + i <= ThemeProperties::COLOR_BUTTON_BACKGROUND; ++i) { + colors[i] = ThemeProperties::GetDefaultColor(i); } - GenerateDefaultFrameColor(&colors, ThemeService::COLOR_FRAME, - ThemeService::TINT_FRAME); + GenerateDefaultFrameColor(&colors, ThemeProperties::COLOR_FRAME, + ThemeProperties::TINT_FRAME); GenerateDefaultFrameColor(&colors, - ThemeService::COLOR_FRAME_INACTIVE, - ThemeService::TINT_FRAME_INACTIVE); + ThemeProperties::COLOR_FRAME_INACTIVE, + ThemeProperties::TINT_FRAME_INACTIVE); GenerateDefaultFrameColor(&colors, - ThemeService::COLOR_FRAME_INCOGNITO, - ThemeService::TINT_FRAME_INCOGNITO); + ThemeProperties::COLOR_FRAME_INCOGNITO, + ThemeProperties::TINT_FRAME_INCOGNITO); GenerateDefaultFrameColor( &colors, - ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE, - ThemeService::TINT_FRAME_INCOGNITO_INACTIVE); + ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE, + ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE); return colors; } @@ -82,7 +82,7 @@ class BrowserThemePackTest : public ::testing::Test { void VerifyColorMap(const std::map<int, SkColor>& color_map) { for (std::map<int, SkColor>::const_iterator it = color_map.begin(); it != color_map.end(); ++it) { - SkColor color = ThemeService::GetDefaultColor(it->first); + SkColor color = ThemeProperties::GetDefaultColor(it->first); theme_pack_->GetColor(it->first, &color); EXPECT_EQ(it->second, color) << "Color id = " << it->first; } @@ -162,25 +162,25 @@ class BrowserThemePackTest : public ::testing::Test { void VerifyStarGazing(BrowserThemePack* pack) { // First check that values we know exist, exist. SkColor color; - EXPECT_TRUE(pack->GetColor(ThemeService::COLOR_BOOKMARK_TEXT, + EXPECT_TRUE(pack->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT, &color)); EXPECT_EQ(SK_ColorBLACK, color); - EXPECT_TRUE(pack->GetColor(ThemeService::COLOR_NTP_BACKGROUND, + EXPECT_TRUE(pack->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND, &color)); EXPECT_EQ(SkColorSetRGB(57, 137, 194), color); color_utils::HSL expected = { 0.6, 0.553, 0.5 }; color_utils::HSL actual; - EXPECT_TRUE(pack->GetTint(ThemeService::TINT_BUTTONS, &actual)); + EXPECT_TRUE(pack->GetTint(ThemeProperties::TINT_BUTTONS, &actual)); EXPECT_DOUBLE_EQ(expected.h, actual.h); EXPECT_DOUBLE_EQ(expected.s, actual.s); EXPECT_DOUBLE_EQ(expected.l, actual.l); int val; EXPECT_TRUE(pack->GetDisplayProperty( - ThemeService::NTP_BACKGROUND_ALIGNMENT, &val)); - EXPECT_EQ(ThemeService::ALIGN_TOP, val); + ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &val)); + EXPECT_EQ(ThemeProperties::ALIGN_TOP, val); // The stargazing theme defines the following images: EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_BUTTON_BACKGROUND)); @@ -199,9 +199,9 @@ class BrowserThemePackTest : public ::testing::Test { EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_TAB_BACKGROUND_INCOGNITO)); // Make sure we don't have phantom data. - EXPECT_FALSE(pack->GetColor(ThemeService::COLOR_CONTROL_BACKGROUND, + EXPECT_FALSE(pack->GetColor(ThemeProperties::COLOR_CONTROL_BACKGROUND, &color)); - EXPECT_FALSE(pack->GetTint(ThemeService::TINT_FRAME, &actual)); + EXPECT_FALSE(pack->GetTint(ThemeProperties::TINT_FRAME, &actual)); } MessageLoop message_loop; @@ -221,11 +221,11 @@ TEST_F(BrowserThemePackTest, DeriveUnderlineLinkColor) { std::map<int, SkColor> colors = GetDefaultColorMap(); SkColor link_color = SkColorSetRGB(128, 128, 128); - colors[ThemeService::COLOR_NTP_LINK] = link_color; - colors[ThemeService::COLOR_NTP_LINK_UNDERLINE] = + colors[ThemeProperties::COLOR_NTP_LINK] = link_color; + colors[ThemeProperties::COLOR_NTP_LINK_UNDERLINE] = BuildThirdOpacity(link_color); - colors[ThemeService::COLOR_NTP_SECTION_LINK] = link_color; - colors[ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE] = + colors[ThemeProperties::COLOR_NTP_SECTION_LINK] = link_color; + colors[ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE] = BuildThirdOpacity(link_color); VerifyColorMap(colors); @@ -243,10 +243,10 @@ TEST_F(BrowserThemePackTest, ProvideUnderlineLinkColor) { std::map<int, SkColor> colors = GetDefaultColorMap(); SkColor link_color = SkColorSetRGB(128, 128, 128); SkColor underline_color = SkColorSetRGB(255, 255, 255); - colors[ThemeService::COLOR_NTP_LINK] = link_color; - colors[ThemeService::COLOR_NTP_LINK_UNDERLINE] = underline_color; - colors[ThemeService::COLOR_NTP_SECTION_LINK] = link_color; - colors[ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE] = + colors[ThemeProperties::COLOR_NTP_LINK] = link_color; + colors[ThemeProperties::COLOR_NTP_LINK_UNDERLINE] = underline_color; + colors[ThemeProperties::COLOR_NTP_SECTION_LINK] = link_color; + colors[ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE] = underline_color; VerifyColorMap(colors); @@ -258,8 +258,8 @@ TEST_F(BrowserThemePackTest, UseSectionColorAsNTPHeader) { std::map<int, SkColor> colors = GetDefaultColorMap(); SkColor ntp_color = SkColorSetRGB(190, 190, 190); - colors[ThemeService::COLOR_NTP_HEADER] = ntp_color; - colors[ThemeService::COLOR_NTP_SECTION] = ntp_color; + colors[ThemeProperties::COLOR_NTP_HEADER] = ntp_color; + colors[ThemeProperties::COLOR_NTP_SECTION] = ntp_color; VerifyColorMap(colors); } @@ -271,8 +271,8 @@ TEST_F(BrowserThemePackTest, ProvideNtpHeaderColor) { std::map<int, SkColor> colors = GetDefaultColorMap(); SkColor ntp_header = SkColorSetRGB(120, 120, 120); SkColor ntp_section = SkColorSetRGB(190, 190, 190); - colors[ThemeService::COLOR_NTP_HEADER] = ntp_header; - colors[ThemeService::COLOR_NTP_SECTION] = ntp_section; + colors[ThemeProperties::COLOR_NTP_HEADER] = ntp_header; + colors[ThemeProperties::COLOR_NTP_SECTION] = ntp_section; VerifyColorMap(colors); } @@ -283,7 +283,7 @@ TEST_F(BrowserThemePackTest, CanReadTints) { color_utils::HSL expected = { 0.5, 0.5, 0.5 }; color_utils::HSL actual = { -1, -1, -1 }; EXPECT_TRUE(theme_pack_->GetTint( - ThemeService::TINT_BUTTONS, &actual)); + ThemeProperties::TINT_BUTTONS, &actual)); EXPECT_DOUBLE_EQ(expected.h, actual.h); EXPECT_DOUBLE_EQ(expected.s, actual.s); EXPECT_DOUBLE_EQ(expected.l, actual.l); @@ -297,15 +297,15 @@ TEST_F(BrowserThemePackTest, CanReadDisplayProperties) { int out_val; EXPECT_TRUE(theme_pack_->GetDisplayProperty( - ThemeService::NTP_BACKGROUND_ALIGNMENT, &out_val)); - EXPECT_EQ(ThemeService::ALIGN_BOTTOM, out_val); + ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &out_val)); + EXPECT_EQ(ThemeProperties::ALIGN_BOTTOM, out_val); EXPECT_TRUE(theme_pack_->GetDisplayProperty( - ThemeService::NTP_BACKGROUND_TILING, &out_val)); - EXPECT_EQ(ThemeService::REPEAT_X, out_val); + ThemeProperties::NTP_BACKGROUND_TILING, &out_val)); + EXPECT_EQ(ThemeProperties::REPEAT_X, out_val); EXPECT_TRUE(theme_pack_->GetDisplayProperty( - ThemeService::NTP_LOGO_ALTERNATE, &out_val)); + ThemeProperties::NTP_LOGO_ALTERNATE, &out_val)); EXPECT_EQ(0, out_val); } @@ -349,7 +349,7 @@ TEST_F(BrowserThemePackTest, InvalidTints) { // We shouldn't have a buttons tint, as it was invalid. color_utils::HSL actual = { -1, -1, -1 }; - EXPECT_FALSE(theme_pack_->GetTint(ThemeService::TINT_BUTTONS, + EXPECT_FALSE(theme_pack_->GetTint(ThemeProperties::TINT_BUTTONS, &actual)); } @@ -360,7 +360,7 @@ TEST_F(BrowserThemePackTest, InvalidDisplayProperties) { int out_val; EXPECT_FALSE(theme_pack_->GetDisplayProperty( - ThemeService::NTP_BACKGROUND_ALIGNMENT, &out_val)); + ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &out_val)); } // These three tests should just not cause a segmentation fault. diff --git a/chrome/browser/themes/theme_properties.cc b/chrome/browser/themes/theme_properties.cc new file mode 100644 index 0000000..1498d67 --- /dev/null +++ b/chrome/browser/themes/theme_properties.cc @@ -0,0 +1,319 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/themes/theme_properties.h" + +#include "base/memory/scoped_ptr.h" +#include "base/string_split.h" +#include "base/string_util.h" +#include "chrome/browser/themes/browser_theme_pack.h" +#include "grit/theme_resources.h" +#include "grit/ui_resources.h" + +namespace { + +// ---------------------------------------------------------------------------- +// Defaults for properties which are stored in the browser theme pack. If you +// change these defaults, you must increment the version number in +// browser_theme_pack.h + +// Default colors. +#if defined(USE_AURA) +// Used for theme fallback colors. +const SkColor kDefaultColorFrame = SkColorSetRGB(109, 109, 109); +const SkColor kDefaultColorFrameInactive = SkColorSetRGB(176, 176, 176); +#else +const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); +const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); +#endif // USE_AURA +const SkColor kDefaultColorFrameIncognito = SkColorSetRGB(83, 106, 139); +const SkColor kDefaultColorFrameIncognitoInactive = + SkColorSetRGB(126, 139, 156); +#if defined(OS_MACOSX) +const SkColor kDefaultColorToolbar = SkColorSetRGB(230, 230, 230); +#else +const SkColor kDefaultColorToolbar = SkColorSetRGB(223, 223, 223); +#endif +const SkColor kDefaultColorTabText = SK_ColorBLACK; +#if defined(OS_MACOSX) +const SkColor kDefaultColorBackgroundTabText = SK_ColorBLACK; +#else +const SkColor kDefaultColorBackgroundTabText = SkColorSetRGB(64, 64, 64); +#endif +const SkColor kDefaultColorBookmarkText = SK_ColorBLACK; +#if defined(OS_WIN) +const SkColor kDefaultColorNTPBackground = + color_utils::GetSysSkColor(COLOR_WINDOW); +const SkColor kDefaultColorNTPText = + color_utils::GetSysSkColor(COLOR_WINDOWTEXT); +const SkColor kDefaultColorNTPLink = + color_utils::GetSysSkColor(COLOR_HOTLIGHT); +#else +// TODO(beng): source from theme provider. +const SkColor kDefaultColorNTPBackground = SK_ColorWHITE; +const SkColor kDefaultColorNTPText = SK_ColorBLACK; +const SkColor kDefaultColorNTPLink = SkColorSetRGB(6, 55, 116); +#endif +const SkColor kDefaultColorNTPHeader = SkColorSetRGB(150, 150, 150); +const SkColor kDefaultColorNTPSection = SkColorSetRGB(229, 229, 229); +const SkColor kDefaultColorNTPSectionText = SK_ColorBLACK; +const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(6, 55, 116); +const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); + +// Default tints. +const color_utils::HSL kDefaultTintButtons = { -1, -1, -1 }; +const color_utils::HSL kDefaultTintFrame = { -1, -1, -1 }; +const color_utils::HSL kDefaultTintFrameInactive = { -1, -1, 0.75f }; +const color_utils::HSL kDefaultTintFrameIncognito = { -1, 0.2f, 0.35f }; +const color_utils::HSL kDefaultTintFrameIncognitoInactive = { -1, 0.3f, 0.6f }; +const color_utils::HSL kDefaultTintBackgroundTab = { -1, 0.5, 0.75 }; + +// Default display properties. +const int kDefaultDisplayPropertyNTPAlignment = + ThemeProperties::ALIGN_BOTTOM; +const int kDefaultDisplayPropertyNTPTiling = + ThemeProperties::NO_REPEAT; +const int kDefaultDisplayPropertyNTPInverseLogo = 0; + +// ---------------------------------------------------------------------------- +// Defaults for properties which are not stored in the browser theme pack. + +const SkColor kDefaultColorControlBackground = SK_ColorWHITE; +const SkColor kDefaultColorToolbarSeparator = SkColorSetRGB(170, 170, 171); + +#if defined(OS_MACOSX) +const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); +const SkColor kDefaultColorToolbarButtonStrokeInactive = + SkColorSetARGB(75, 99, 99, 99); +const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); +const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); +const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163); +#endif + +// ---------------------------------------------------------------------------- + +// Strings used in alignment properties. +const char* kAlignmentCenter = "center"; +const char* kAlignmentTop = "top"; +const char* kAlignmentBottom = "bottom"; +const char* kAlignmentLeft = "left"; +const char* kAlignmentRight = "right"; + +// Strings used in background tiling repetition properties. +const char* kTilingNoRepeat = "no-repeat"; +const char* kTilingRepeatX = "repeat-x"; +const char* kTilingRepeatY = "repeat-y"; +const char* kTilingRepeat = "repeat"; + +// The image resources that will be tinted by the 'button' tint value. +// If you change this list, you must increment the version number in +// browser_theme_pack.cc, and you should assign persistent IDs to the +// data table at the start of said file or else tinted versions of +// these resources will not be created. +const int kToolbarButtonIDs[] = { + IDR_BACK, IDR_BACK_D, IDR_BACK_H, IDR_BACK_P, + IDR_FORWARD, IDR_FORWARD_D, IDR_FORWARD_H, IDR_FORWARD_P, + IDR_HOME, IDR_HOME_H, IDR_HOME_P, + IDR_RELOAD, IDR_RELOAD_H, IDR_RELOAD_P, + IDR_STOP, IDR_STOP_D, IDR_STOP_H, IDR_STOP_P, + IDR_LOCATIONBG_C, IDR_LOCATIONBG_L, IDR_LOCATIONBG_R, + IDR_BROWSER_ACTIONS_OVERFLOW, IDR_BROWSER_ACTIONS_OVERFLOW_H, + IDR_BROWSER_ACTIONS_OVERFLOW_P, + IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, + IDR_MENU_DROPARROW, + IDR_THROBBER, IDR_THROBBER_WAITING, IDR_THROBBER_LIGHT, +}; + +SkColor TintForUnderline(SkColor input) { + return SkColorSetA(input, SkColorGetA(input) / 3); +} + +} // namespace + +// static +int ThemeProperties::StringToAlignment(const std::string& alignment) { + std::vector<std::string> split; + base::SplitStringAlongWhitespace(alignment, &split); + + int alignment_mask = 0; + for (std::vector<std::string>::iterator component(split.begin()); + component != split.end(); ++component) { + if (LowerCaseEqualsASCII(*component, kAlignmentTop)) + alignment_mask |= ALIGN_TOP; + else if (LowerCaseEqualsASCII(*component, kAlignmentBottom)) + alignment_mask |= ALIGN_BOTTOM; + else if (LowerCaseEqualsASCII(*component, kAlignmentLeft)) + alignment_mask |= ALIGN_LEFT; + else if (LowerCaseEqualsASCII(*component, kAlignmentRight)) + alignment_mask |= ALIGN_RIGHT; + } + return alignment_mask; +} + +// static +int ThemeProperties::StringToTiling(const std::string& tiling) { + const char* component = tiling.c_str(); + + if (base::strcasecmp(component, kTilingRepeatX) == 0) + return REPEAT_X; + if (base::strcasecmp(component, kTilingRepeatY) == 0) + return REPEAT_Y; + if (base::strcasecmp(component, kTilingRepeat) == 0) + return REPEAT; + // NO_REPEAT is the default choice. + return NO_REPEAT; +} + +// static +std::string ThemeProperties::AlignmentToString(int alignment) { + // Convert from an AlignmentProperty back into a string. + std::string vertical_string(kAlignmentCenter); + std::string horizontal_string(kAlignmentCenter); + + if (alignment & ALIGN_TOP) + vertical_string = kAlignmentTop; + else if (alignment & ALIGN_BOTTOM) + vertical_string = kAlignmentBottom; + + if (alignment & ALIGN_LEFT) + horizontal_string = kAlignmentLeft; + else if (alignment & ALIGN_RIGHT) + horizontal_string = kAlignmentRight; + + return horizontal_string + " " + vertical_string; +} + +// static +std::string ThemeProperties::TilingToString(int tiling) { + // Convert from a TilingProperty back into a string. + if (tiling == REPEAT_X) + return kTilingRepeatX; + if (tiling == REPEAT_Y) + return kTilingRepeatY; + if (tiling == REPEAT) + return kTilingRepeat; + return kTilingNoRepeat; +} + +// static +bool ThemeProperties::IsThemeableImage(int id) { + // TODO(pkotwicz): Cache results to improve lookup speed. + std::set<int> themeable_idrs; + BrowserThemePack::GetThemeableImageIDRs(&themeable_idrs); + return themeable_idrs.find(id) != themeable_idrs.end(); +} + +// static +const std::set<int>& ThemeProperties::GetTintableToolbarButtons() { + CR_DEFINE_STATIC_LOCAL(std::set<int>, button_set, ()); + if (button_set.empty()) { + button_set = std::set<int>( + kToolbarButtonIDs, + kToolbarButtonIDs + arraysize(kToolbarButtonIDs)); + } + + return button_set; +} + +// static +color_utils::HSL ThemeProperties::GetDefaultTint(int id) { + switch (id) { + case TINT_FRAME: + return kDefaultTintFrame; + case TINT_FRAME_INACTIVE: + return kDefaultTintFrameInactive; + case TINT_FRAME_INCOGNITO: + return kDefaultTintFrameIncognito; + case TINT_FRAME_INCOGNITO_INACTIVE: + return kDefaultTintFrameIncognitoInactive; + case TINT_BUTTONS: + return kDefaultTintButtons; + case TINT_BACKGROUND_TAB: + return kDefaultTintBackgroundTab; + default: + color_utils::HSL result = {-1, -1, -1}; + return result; + } +} + +// static +SkColor ThemeProperties::GetDefaultColor(int id) { + switch (id) { + // Properties stored in theme pack. + case COLOR_FRAME: + return kDefaultColorFrame; + case COLOR_FRAME_INACTIVE: + return kDefaultColorFrameInactive; + case COLOR_FRAME_INCOGNITO: + return kDefaultColorFrameIncognito; + case COLOR_FRAME_INCOGNITO_INACTIVE: + return kDefaultColorFrameIncognitoInactive; + case COLOR_TOOLBAR: + return kDefaultColorToolbar; + case COLOR_TAB_TEXT: + return kDefaultColorTabText; + case COLOR_BACKGROUND_TAB_TEXT: + return kDefaultColorBackgroundTabText; + case COLOR_BOOKMARK_TEXT: + return kDefaultColorBookmarkText; + case COLOR_NTP_BACKGROUND: + return kDefaultColorNTPBackground; + case COLOR_NTP_TEXT: + return kDefaultColorNTPText; + case COLOR_NTP_LINK: + return kDefaultColorNTPLink; + case COLOR_NTP_LINK_UNDERLINE: + return TintForUnderline(kDefaultColorNTPLink); + case COLOR_NTP_HEADER: + return kDefaultColorNTPHeader; + case COLOR_NTP_SECTION: + return kDefaultColorNTPSection; + case COLOR_NTP_SECTION_TEXT: + return kDefaultColorNTPSectionText; + case COLOR_NTP_SECTION_LINK: + return kDefaultColorNTPSectionLink; + case COLOR_NTP_SECTION_LINK_UNDERLINE: + return TintForUnderline(kDefaultColorNTPSectionLink); + case COLOR_BUTTON_BACKGROUND: + return kDefaultColorButtonBackground; + + // Properties not stored in theme pack. + case COLOR_CONTROL_BACKGROUND: + return kDefaultColorControlBackground; + case COLOR_TOOLBAR_SEPARATOR: + return kDefaultColorToolbarSeparator; +#if defined(OS_MACOSX) + case COLOR_TOOLBAR_BUTTON_STROKE: + return kDefaultColorToolbarButtonStroke; + case COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE: + return kDefaultColorToolbarButtonStrokeInactive; + case COLOR_TOOLBAR_BEZEL: + return kDefaultColorToolbarBezel; + case COLOR_TOOLBAR_STROKE: + return kDefaultColorToolbarStroke; + case COLOR_TOOLBAR_STROKE_INACTIVE: + return kDefaultColorToolbarStrokeInactive; +#endif + default: + // Return a debugging red color. + return SK_ColorRED; + } +} + +// static +bool ThemeProperties::GetDefaultDisplayProperty(int id, int* result) { + switch (id) { + case NTP_BACKGROUND_ALIGNMENT: + *result = kDefaultDisplayPropertyNTPAlignment; + return true; + case NTP_BACKGROUND_TILING: + *result = kDefaultDisplayPropertyNTPTiling; + return true; + case NTP_LOGO_ALTERNATE: + *result = kDefaultDisplayPropertyNTPInverseLogo; + return true; + } + + return false; +} diff --git a/chrome/browser/themes/theme_properties.h b/chrome/browser/themes/theme_properties.h new file mode 100644 index 0000000..46ec597 --- /dev/null +++ b/chrome/browser/themes/theme_properties.h @@ -0,0 +1,148 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_ +#define CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_ + +#include <set> +#include <string> + +#include "base/basictypes.h" +#include "third_party/skia/include/core/SkColor.h" +#include "ui/gfx/color_utils.h" + +// Static only class for querying which properties / images are themeable and +// the defaults of these properties. +// All methods are thread safe unless indicated otherwise. +class ThemeProperties { + public: + // --------------------------------------------------------------------------- + // The int values of OverwritableByUserThemeProperties, Alignment, and Tiling + // are used as a key to store the property in the browser theme pack. If you + // modify any of these enums, increment the version number in + // browser_theme_pack.h + + enum OverwritableByUserThemeProperty { + COLOR_FRAME, + COLOR_FRAME_INACTIVE, + COLOR_FRAME_INCOGNITO, + COLOR_FRAME_INCOGNITO_INACTIVE, + COLOR_TOOLBAR, + COLOR_TAB_TEXT, + COLOR_BACKGROUND_TAB_TEXT, + COLOR_BOOKMARK_TEXT, + COLOR_NTP_BACKGROUND, + COLOR_NTP_TEXT, + COLOR_NTP_LINK, + COLOR_NTP_LINK_UNDERLINE, + COLOR_NTP_HEADER, + COLOR_NTP_SECTION, + COLOR_NTP_SECTION_TEXT, + COLOR_NTP_SECTION_LINK, + COLOR_NTP_SECTION_LINK_UNDERLINE, + COLOR_BUTTON_BACKGROUND, + + TINT_BUTTONS, + TINT_FRAME, + TINT_FRAME_INACTIVE, + TINT_FRAME_INCOGNITO, + TINT_FRAME_INCOGNITO_INACTIVE, + TINT_BACKGROUND_TAB, + + NTP_BACKGROUND_ALIGNMENT, + NTP_BACKGROUND_TILING, + NTP_LOGO_ALTERNATE + }; + + // A bitfield mask for alignments. + enum Alignment { + ALIGN_CENTER = 0, + ALIGN_LEFT = 1 << 0, + ALIGN_TOP = 1 << 1, + ALIGN_RIGHT = 1 << 2, + ALIGN_BOTTOM = 1 << 3, + }; + + // Background tiling choices. + enum Tiling { + NO_REPEAT = 0, + REPEAT_X = 1, + REPEAT_Y = 2, + REPEAT = 3 + }; + + // -------------------------------------------------------------------------- + // The int value of the properties in NotOverwritableByUserThemeProperties + // has no special meaning. Modify the enum to your heart's content. + // The enum takes on values >= 1000 as not to overlap with + // OverwritableByUserThemeProperties. + enum NotOverwritableByUserThemeProperty { + COLOR_CONTROL_BACKGROUND = 1000, + COLOR_TOOLBAR_SEPARATOR, + + // These colors don't have constant default values. They are derived from + // the runtime value of other colors. + COLOR_NTP_SECTION_HEADER_TEXT, + COLOR_NTP_SECTION_HEADER_TEXT_HOVER, + COLOR_NTP_SECTION_HEADER_RULE, + COLOR_NTP_SECTION_HEADER_RULE_LIGHT, + COLOR_NTP_TEXT_LIGHT, + +#if defined(OS_MACOSX) + COLOR_TOOLBAR_BEZEL, + COLOR_TOOLBAR_STROKE, + COLOR_TOOLBAR_STROKE_INACTIVE, + COLOR_TOOLBAR_BUTTON_STROKE, + COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + GRADIENT_FRAME_INCOGNITO, + GRADIENT_FRAME_INCOGNITO_INACTIVE, + GRADIENT_TOOLBAR, + GRADIENT_TOOLBAR_INACTIVE, + GRADIENT_TOOLBAR_BUTTON, + GRADIENT_TOOLBAR_BUTTON_INACTIVE, + GRADIENT_TOOLBAR_BUTTON_PRESSED, + GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE +#endif // OS_MACOSX + }; + + // Used by the browser theme pack to parse alignments from something like + // "top left" into a bitmask of Alignment. + static int StringToAlignment(const std::string& alignment); + + // Used by the browser theme pack to parse alignments from something like + // "no-repeat" into a Tiling value. + static int StringToTiling(const std::string& tiling); + + // Converts a bitmask of Alignment into a string like "top left". The result + // is used to generate a CSS value. + static std::string AlignmentToString(int alignment); + + // Converts a Tiling into a string like "no-repeat". The result is used to + // generate a CSS value. + static std::string TilingToString(int tiling); + + // Returns true if the image is themeable. + static bool IsThemeableImage(int resource_id); + + // Returns the set of IDR_* resources that should be tinted. + // This method is not thread safe. + static const std::set<int>& GetTintableToolbarButtons(); + + // Returns the default tint for the given tint |id| TINT_* enum value. + // Returns an HSL value of {-1, -1, -1} if |id| is invalid. + static color_utils::HSL GetDefaultTint(int id); + + // Returns the default color for the given color |id| COLOR_* enum value. + // Returns SK_ColorRED if |id| is invalid. + static SkColor GetDefaultColor(int id); + + // Returns true and sets |result| to the requested default property, if |id| + // is valid. + static bool GetDefaultDisplayProperty(int id, int* result); + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(ThemeProperties); +}; + +#endif // CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_ diff --git a/chrome/browser/themes/theme_properties_unittest.cc b/chrome/browser/themes/theme_properties_unittest.cc new file mode 100644 index 0000000..46941ca --- /dev/null +++ b/chrome/browser/themes/theme_properties_unittest.cc @@ -0,0 +1,57 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/themes/theme_properties.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +typedef testing::Test ThemePropertiesTest; + +TEST_F(ThemePropertiesTest, AlignmentConversion) { + // Verify that we get out what we put in. + std::string top_left = "left top"; + int alignment = ThemeProperties::StringToAlignment(top_left); + EXPECT_EQ(ThemeProperties::ALIGN_TOP | ThemeProperties::ALIGN_LEFT, + alignment); + EXPECT_EQ(top_left, ThemeProperties::AlignmentToString(alignment)); + + // We get back a normalized version of what we put in. + alignment = ThemeProperties::StringToAlignment("top"); + EXPECT_EQ(ThemeProperties::ALIGN_TOP, alignment); + EXPECT_EQ("center top", ThemeProperties::AlignmentToString(alignment)); + + alignment = ThemeProperties::StringToAlignment("left"); + EXPECT_EQ(ThemeProperties::ALIGN_LEFT, alignment); + EXPECT_EQ("left center", ThemeProperties::AlignmentToString(alignment)); + + alignment = ThemeProperties::StringToAlignment("right"); + EXPECT_EQ(ThemeProperties::ALIGN_RIGHT, alignment); + EXPECT_EQ("right center", ThemeProperties::AlignmentToString(alignment)); + + alignment = ThemeProperties::StringToAlignment("righttopbottom"); + EXPECT_EQ(ThemeProperties::ALIGN_CENTER, alignment); + EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment)); +} + +TEST_F(ThemePropertiesTest, AlignmentConversionInput) { + // Verify that we output in an expected format. + int alignment = ThemeProperties::StringToAlignment("bottom right"); + EXPECT_EQ("right bottom", ThemeProperties::AlignmentToString(alignment)); + + // Verify that bad strings don't cause explosions. + alignment = ThemeProperties::StringToAlignment("new zealand"); + EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment)); + + // Verify that bad strings don't cause explosions. + alignment = ThemeProperties::StringToAlignment("new zealand top"); + EXPECT_EQ("center top", ThemeProperties::AlignmentToString(alignment)); + + // Verify that bad strings don't cause explosions. + alignment = ThemeProperties::StringToAlignment("new zealandtop"); + EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment)); +} + +}; // namespace diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc index 6b133fb8..6907a06 100644 --- a/chrome/browser/themes/theme_service.cc +++ b/chrome/browser/themes/theme_service.cc @@ -8,13 +8,13 @@ #include "base/memory/ref_counted_memory.h" #include "base/prefs/pref_service.h" #include "base/sequenced_task_runner.h" -#include "base/string_split.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/browser_theme_pack.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_syncable_service.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_notification_types.h" @@ -43,18 +43,7 @@ using content::UserMetricsAction; using extensions::Extension; using ui::ResourceBundle; -// Strings used in alignment properties. -const char* ThemeService::kAlignmentCenter = "center"; -const char* ThemeService::kAlignmentTop = "top"; -const char* ThemeService::kAlignmentBottom = "bottom"; -const char* ThemeService::kAlignmentLeft = "left"; -const char* ThemeService::kAlignmentRight = "right"; - -// Strings used in background tiling repetition properties. -const char* ThemeService::kTilingNoRepeat = "no-repeat"; -const char* ThemeService::kTilingRepeatX = "repeat-x"; -const char* ThemeService::kTilingRepeatY = "repeat-y"; -const char* ThemeService::kTilingRepeat = "repeat"; +typedef ThemeProperties Properties; // The default theme if we haven't installed a theme yet or if we've clicked // the "Use Classic" button. @@ -79,124 +68,6 @@ SkColor IncreaseLightness(SkColor color, double percent) { return color_utils::HSLToSkColor(result, SkColorGetA(color)); } -// Default colors. -#if defined(USE_AURA) -// Used for theme fallback colors. -const SkColor kDefaultColorFrame = SkColorSetRGB(109, 109, 109); -const SkColor kDefaultColorFrameInactive = SkColorSetRGB(176, 176, 176); -#else -const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); -const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); -#endif // USE_AURA -const SkColor kDefaultColorFrameIncognito = SkColorSetRGB(83, 106, 139); -const SkColor kDefaultColorFrameIncognitoInactive = - SkColorSetRGB(126, 139, 156); -#if defined(OS_MACOSX) -const SkColor kDefaultColorToolbar = SkColorSetRGB(230, 230, 230); -#else -const SkColor kDefaultColorToolbar = SkColorSetRGB(223, 223, 223); -#endif -const SkColor kDefaultColorToolbarSeparator = SkColorSetRGB(170, 170, 171); -const SkColor kDefaultColorTabText = SK_ColorBLACK; -#if defined(OS_MACOSX) -const SkColor kDefaultColorBackgroundTabText = SK_ColorBLACK; -#else -const SkColor kDefaultColorBackgroundTabText = SkColorSetRGB(64, 64, 64); -#endif -const SkColor kDefaultColorBookmarkText = SK_ColorBLACK; -#if defined(OS_WIN) -const SkColor kDefaultColorNTPBackground = - color_utils::GetSysSkColor(COLOR_WINDOW); -const SkColor kDefaultColorNTPText = - color_utils::GetSysSkColor(COLOR_WINDOWTEXT); -const SkColor kDefaultColorNTPLink = - color_utils::GetSysSkColor(COLOR_HOTLIGHT); -#else -// TODO(beng): source from theme provider. -const SkColor kDefaultColorNTPBackground = SK_ColorWHITE; -const SkColor kDefaultColorNTPText = SK_ColorBLACK; -const SkColor kDefaultColorNTPLink = SkColorSetRGB(6, 55, 116); -#endif -const SkColor kDefaultColorNTPHeader = SkColorSetRGB(150, 150, 150); -const SkColor kDefaultColorNTPSection = SkColorSetRGB(229, 229, 229); -const SkColor kDefaultColorNTPSectionText = SK_ColorBLACK; -const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(6, 55, 116); -const SkColor kDefaultColorControlBackground = SK_ColorWHITE; -const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); -#if defined(OS_MACOSX) -const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); -const SkColor kDefaultColorToolbarButtonStrokeInactive = - SkColorSetARGB(75, 99, 99, 99); -const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); -const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); -const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163); -#endif - -// Default tints. -const color_utils::HSL kDefaultTintButtons = { -1, -1, -1 }; -const color_utils::HSL kDefaultTintFrame = { -1, -1, -1 }; -const color_utils::HSL kDefaultTintFrameInactive = { -1, -1, 0.75f }; -const color_utils::HSL kDefaultTintFrameIncognito = { -1, 0.2f, 0.35f }; -const color_utils::HSL kDefaultTintFrameIncognitoInactive = { -1, 0.3f, 0.6f }; -const color_utils::HSL kDefaultTintBackgroundTab = { -1, 0.5, 0.75 }; - -// Default display properties. -const int kDefaultDisplayPropertyNTPAlignment = - ThemeService::ALIGN_BOTTOM; -const int kDefaultDisplayPropertyNTPTiling = - ThemeService::NO_REPEAT; -const int kDefaultDisplayPropertyNTPInverseLogo = 0; - -// The sum of kFrameBorderThickness and kNonClientRestoredExtraThickness from -// OpaqueBrowserFrameView. -const int kRestoredTabVerticalOffset = 15; - -// The image resources we will allow people to theme. -const int kThemeableImages[] = { - IDR_THEME_FRAME, - IDR_THEME_FRAME_INACTIVE, - IDR_THEME_FRAME_INCOGNITO, - IDR_THEME_FRAME_INCOGNITO_INACTIVE, - IDR_THEME_TOOLBAR, - IDR_THEME_TAB_BACKGROUND, - IDR_THEME_TAB_BACKGROUND_INCOGNITO, - IDR_THEME_TAB_BACKGROUND_V, - IDR_THEME_NTP_BACKGROUND, - IDR_THEME_FRAME_OVERLAY, - IDR_THEME_FRAME_OVERLAY_INACTIVE, - IDR_THEME_BUTTON_BACKGROUND, - IDR_THEME_NTP_ATTRIBUTION, - IDR_THEME_WINDOW_CONTROL_BACKGROUND -}; - -bool HasThemeableImage(int themeable_image_id) { - CR_DEFINE_STATIC_LOCAL(std::set<int>, themeable_images, ()); - if (themeable_images.empty()) { - themeable_images.insert( - kThemeableImages, kThemeableImages + arraysize(kThemeableImages)); - } - return themeable_images.count(themeable_image_id) > 0; -} - -// The image resources that will be tinted by the 'button' tint value. -// If you change this list, you must increment the version number in -// browser_theme_pack.cc, and you should assign persistent IDs to the -// data table at the start of said file or else tinted versions of -// these resources will not be created. -const int kToolbarButtonIDs[] = { - IDR_BACK, IDR_BACK_D, IDR_BACK_H, IDR_BACK_P, - IDR_FORWARD, IDR_FORWARD_D, IDR_FORWARD_H, IDR_FORWARD_P, - IDR_HOME, IDR_HOME_H, IDR_HOME_P, - IDR_RELOAD, IDR_RELOAD_H, IDR_RELOAD_P, - IDR_STOP, IDR_STOP_D, IDR_STOP_H, IDR_STOP_P, - IDR_LOCATIONBG_C, IDR_LOCATIONBG_L, IDR_LOCATIONBG_R, - IDR_BROWSER_ACTIONS_OVERFLOW, IDR_BROWSER_ACTIONS_OVERFLOW_H, - IDR_BROWSER_ACTIONS_OVERFLOW_P, - IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, - IDR_MENU_DROPARROW, - IDR_THROBBER, IDR_THROBBER_WAITING, IDR_THROBBER_LIGHT, -}; - // Writes the theme pack to disk on a separate thread. void WritePackToDiskCallback(BrowserThemePack* pack, const base::FilePath& path) { @@ -206,17 +77,10 @@ void WritePackToDiskCallback(BrowserThemePack* pack, } // namespace -bool ThemeService::IsThemeableImage(int resource_id) { - return HasThemeableImage(resource_id); -} - ThemeService::ThemeService() : rb_(ResourceBundle::GetSharedInstance()), profile_(NULL), number_of_infobars_(0) { - // Initialize the themeable image map so we can use it on other threads. - HasThemeableImage(0); - // Register the ManifestHandler for parsing 'theme' manifest key. extensions::ManifestHandler::Register( extension_manifest_keys::kTheme, @@ -281,26 +145,26 @@ SkColor ThemeService::GetColor(int id) const { // For backward compat with older themes, some newer colors are generated from // older ones if they are missing. switch (id) { - case COLOR_NTP_SECTION_HEADER_TEXT: - return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.30); - case COLOR_NTP_SECTION_HEADER_TEXT_HOVER: - return GetColor(COLOR_NTP_TEXT); - case COLOR_NTP_SECTION_HEADER_RULE: - return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.70); - case COLOR_NTP_SECTION_HEADER_RULE_LIGHT: - return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.86); - case COLOR_NTP_TEXT_LIGHT: - return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.40); + case Properties::COLOR_NTP_SECTION_HEADER_TEXT: + return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.30); + case Properties::COLOR_NTP_SECTION_HEADER_TEXT_HOVER: + return GetColor(Properties::COLOR_NTP_TEXT); + case Properties::COLOR_NTP_SECTION_HEADER_RULE: + return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.70); + case Properties::COLOR_NTP_SECTION_HEADER_RULE_LIGHT: + return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.86); + case Properties::COLOR_NTP_TEXT_LIGHT: + return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40); } - return GetDefaultColor(id); + return Properties::GetDefaultColor(id); } bool ThemeService::GetDisplayProperty(int id, int* result) const { if (theme_pack_.get()) return theme_pack_->GetDisplayProperty(id, result); - return GetDefaultDisplayProperty(id, result); + return Properties::GetDefaultDisplayProperty(id, result); } bool ThemeService::ShouldUseNativeFrame() const { @@ -314,7 +178,7 @@ bool ThemeService::ShouldUseNativeFrame() const { } bool ThemeService::HasCustomImage(int id) const { - if (!HasThemeableImage(id)) + if (!Properties::IsThemeableImage(id)) return false; if (theme_pack_) @@ -328,7 +192,7 @@ base::RefCountedMemory* ThemeService::GetRawData( ui::ScaleFactor scale_factor) const { // Check to see whether we should substitute some images. int ntp_alternate; - GetDisplayProperty(NTP_LOGO_ALTERNATE, &ntp_alternate); + GetDisplayProperty(Properties::NTP_LOGO_ALTERNATE, &ntp_alternate); if (id == IDR_PRODUCT_LOGO && ntp_alternate != 0) id = IDR_PRODUCT_LOGO_WHITE; @@ -404,182 +268,6 @@ std::string ThemeService::GetThemeID() const { return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); } -// static -std::string ThemeService::AlignmentToString(int alignment) { - // Convert from an AlignmentProperty back into a string. - std::string vertical_string(kAlignmentCenter); - std::string horizontal_string(kAlignmentCenter); - - if (alignment & ThemeService::ALIGN_TOP) - vertical_string = kAlignmentTop; - else if (alignment & ThemeService::ALIGN_BOTTOM) - vertical_string = kAlignmentBottom; - - if (alignment & ThemeService::ALIGN_LEFT) - horizontal_string = kAlignmentLeft; - else if (alignment & ThemeService::ALIGN_RIGHT) - horizontal_string = kAlignmentRight; - - return horizontal_string + " " + vertical_string; -} - -// static -int ThemeService::StringToAlignment(const std::string& alignment) { - std::vector<std::string> split; - base::SplitStringAlongWhitespace(alignment, &split); - - int alignment_mask = 0; - for (std::vector<std::string>::iterator component(split.begin()); - component != split.end(); ++component) { - if (LowerCaseEqualsASCII(*component, kAlignmentTop)) - alignment_mask |= ThemeService::ALIGN_TOP; - else if (LowerCaseEqualsASCII(*component, kAlignmentBottom)) - alignment_mask |= ThemeService::ALIGN_BOTTOM; - else if (LowerCaseEqualsASCII(*component, kAlignmentLeft)) - alignment_mask |= ThemeService::ALIGN_LEFT; - else if (LowerCaseEqualsASCII(*component, kAlignmentRight)) - alignment_mask |= ThemeService::ALIGN_RIGHT; - } - return alignment_mask; -} - -// static -std::string ThemeService::TilingToString(int tiling) { - // Convert from a TilingProperty back into a string. - if (tiling == ThemeService::REPEAT_X) - return kTilingRepeatX; - if (tiling == ThemeService::REPEAT_Y) - return kTilingRepeatY; - if (tiling == ThemeService::REPEAT) - return kTilingRepeat; - return kTilingNoRepeat; -} - -// static -int ThemeService::StringToTiling(const std::string& tiling) { - const char* component = tiling.c_str(); - - if (base::strcasecmp(component, kTilingRepeatX) == 0) - return ThemeService::REPEAT_X; - if (base::strcasecmp(component, kTilingRepeatY) == 0) - return ThemeService::REPEAT_Y; - if (base::strcasecmp(component, kTilingRepeat) == 0) - return ThemeService::REPEAT; - // NO_REPEAT is the default choice. - return ThemeService::NO_REPEAT; -} - -// static -color_utils::HSL ThemeService::GetDefaultTint(int id) { - switch (id) { - case TINT_FRAME: - return kDefaultTintFrame; - case TINT_FRAME_INACTIVE: - return kDefaultTintFrameInactive; - case TINT_FRAME_INCOGNITO: - return kDefaultTintFrameIncognito; - case TINT_FRAME_INCOGNITO_INACTIVE: - return kDefaultTintFrameIncognitoInactive; - case TINT_BUTTONS: - return kDefaultTintButtons; - case TINT_BACKGROUND_TAB: - return kDefaultTintBackgroundTab; - default: - color_utils::HSL result = {-1, -1, -1}; - return result; - } -} - -// static -SkColor ThemeService::GetDefaultColor(int id) { - switch (id) { - case COLOR_FRAME: - return kDefaultColorFrame; - case COLOR_FRAME_INACTIVE: - return kDefaultColorFrameInactive; - case COLOR_FRAME_INCOGNITO: - return kDefaultColorFrameIncognito; - case COLOR_FRAME_INCOGNITO_INACTIVE: - return kDefaultColorFrameIncognitoInactive; - case COLOR_TOOLBAR: - return kDefaultColorToolbar; - case COLOR_TOOLBAR_SEPARATOR: - return kDefaultColorToolbarSeparator; - case COLOR_TAB_TEXT: - return kDefaultColorTabText; - case COLOR_BACKGROUND_TAB_TEXT: - return kDefaultColorBackgroundTabText; - case COLOR_BOOKMARK_TEXT: - return kDefaultColorBookmarkText; - case COLOR_NTP_BACKGROUND: - return kDefaultColorNTPBackground; - case COLOR_NTP_TEXT: - return kDefaultColorNTPText; - case COLOR_NTP_LINK: - return kDefaultColorNTPLink; - case COLOR_NTP_LINK_UNDERLINE: - return TintForUnderline(kDefaultColorNTPLink); - case COLOR_NTP_HEADER: - return kDefaultColorNTPHeader; - case COLOR_NTP_SECTION: - return kDefaultColorNTPSection; - case COLOR_NTP_SECTION_TEXT: - return kDefaultColorNTPSectionText; - case COLOR_NTP_SECTION_LINK: - return kDefaultColorNTPSectionLink; - case COLOR_NTP_SECTION_LINK_UNDERLINE: - return TintForUnderline(kDefaultColorNTPSectionLink); - case COLOR_CONTROL_BACKGROUND: - return kDefaultColorControlBackground; - case COLOR_BUTTON_BACKGROUND: - return kDefaultColorButtonBackground; -#if defined(OS_MACOSX) - case COLOR_TOOLBAR_BUTTON_STROKE: - return kDefaultColorToolbarButtonStroke; - case COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE: - return kDefaultColorToolbarButtonStrokeInactive; - case COLOR_TOOLBAR_BEZEL: - return kDefaultColorToolbarBezel; - case COLOR_TOOLBAR_STROKE: - return kDefaultColorToolbarStroke; - case COLOR_TOOLBAR_STROKE_INACTIVE: - return kDefaultColorToolbarStrokeInactive; -#endif - default: - // Return a debugging red color. - return 0xffff0000; - } -} - -// static -bool ThemeService::GetDefaultDisplayProperty(int id, int* result) { - switch (id) { - case NTP_BACKGROUND_ALIGNMENT: - *result = kDefaultDisplayPropertyNTPAlignment; - return true; - case NTP_BACKGROUND_TILING: - *result = kDefaultDisplayPropertyNTPTiling; - return true; - case NTP_LOGO_ALTERNATE: - *result = kDefaultDisplayPropertyNTPInverseLogo; - return true; - } - - return false; -} - -// static -const std::set<int>& ThemeService::GetTintableToolbarButtons() { - CR_DEFINE_STATIC_LOCAL(std::set<int>, button_set, ()); - if (button_set.empty()) { - button_set = std::set<int>( - kToolbarButtonIDs, - kToolbarButtonIDs + arraysize(kToolbarButtonIDs)); - } - - return button_set; -} - color_utils::HSL ThemeService::GetTint(int id) const { DCHECK(CalledOnValidThread()); @@ -587,7 +275,7 @@ color_utils::HSL ThemeService::GetTint(int id) const { if (theme_pack_.get() && theme_pack_->GetTint(id, &hsl)) return hsl; - return GetDefaultTint(id); + return ThemeProperties::GetDefaultTint(id); } void ThemeService::ClearAllThemeData() { diff --git a/chrome/browser/themes/theme_service.h b/chrome/browser/themes/theme_service.h index 29b9778..073b063 100644 --- a/chrome/browser/themes/theme_service.h +++ b/chrome/browser/themes/theme_service.h @@ -54,102 +54,11 @@ class ThemeService : public base::NonThreadSafe, public ui::ThemeProvider { public: // Public constants used in ThemeService and its subclasses: - - // Strings used in alignment properties. - static const char* kAlignmentCenter; - static const char* kAlignmentTop; - static const char* kAlignmentBottom; - static const char* kAlignmentLeft; - static const char* kAlignmentRight; - - // Strings used in tiling properties. - static const char* kTilingNoRepeat; - static const char* kTilingRepeatX; - static const char* kTilingRepeatY; - static const char* kTilingRepeat; - static const char* kDefaultThemeID; - // Returns true if the image is themeable. Safe to call on any thread. - static bool IsThemeableImage(int resource_id); - ThemeService(); virtual ~ThemeService(); - enum { - COLOR_FRAME, - COLOR_FRAME_INACTIVE, - COLOR_FRAME_INCOGNITO, - COLOR_FRAME_INCOGNITO_INACTIVE, - COLOR_TOOLBAR, - COLOR_TOOLBAR_SEPARATOR, - COLOR_TAB_TEXT, - COLOR_BACKGROUND_TAB_TEXT, - COLOR_BOOKMARK_TEXT, - COLOR_NTP_BACKGROUND, - COLOR_NTP_TEXT, - COLOR_NTP_LINK, - COLOR_NTP_LINK_UNDERLINE, - COLOR_NTP_HEADER, - COLOR_NTP_SECTION, - COLOR_NTP_SECTION_TEXT, - COLOR_NTP_SECTION_LINK, - COLOR_NTP_SECTION_LINK_UNDERLINE, - COLOR_CONTROL_BACKGROUND, - COLOR_BUTTON_BACKGROUND, - - // These colors don't have constant default values. They are derived from - // the runtime value of other colors. - COLOR_NTP_SECTION_HEADER_TEXT, - COLOR_NTP_SECTION_HEADER_TEXT_HOVER, - COLOR_NTP_SECTION_HEADER_RULE, - COLOR_NTP_SECTION_HEADER_RULE_LIGHT, - COLOR_NTP_TEXT_LIGHT, - - TINT_BUTTONS, - TINT_FRAME, - TINT_FRAME_INACTIVE, - TINT_FRAME_INCOGNITO, - TINT_FRAME_INCOGNITO_INACTIVE, - TINT_BACKGROUND_TAB, - NTP_BACKGROUND_ALIGNMENT, - NTP_BACKGROUND_TILING, - NTP_LOGO_ALTERNATE -#if defined(OS_MACOSX) - , - COLOR_TOOLBAR_BEZEL = 1000, - COLOR_TOOLBAR_STROKE, - COLOR_TOOLBAR_STROKE_INACTIVE, - COLOR_TOOLBAR_BUTTON_STROKE, - COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, - GRADIENT_FRAME_INCOGNITO, - GRADIENT_FRAME_INCOGNITO_INACTIVE, - GRADIENT_TOOLBAR, - GRADIENT_TOOLBAR_INACTIVE, - GRADIENT_TOOLBAR_BUTTON, - GRADIENT_TOOLBAR_BUTTON_INACTIVE, - GRADIENT_TOOLBAR_BUTTON_PRESSED, - GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE -#endif // OS_MACOSX - }; - - // A bitfield mask for alignments. - enum Alignment { - ALIGN_CENTER = 0, - ALIGN_LEFT = 1 << 0, - ALIGN_TOP = 1 << 1, - ALIGN_RIGHT = 1 << 2, - ALIGN_BOTTOM = 1 << 3, - }; - - // Background tiling choices. - enum Tiling { - NO_REPEAT = 0, - REPEAT_X = 1, - REPEAT_Y = 2, - REPEAT = 3 - }; - virtual void Init(Profile* profile); // Returns a cross platform image for an id. @@ -214,34 +123,6 @@ class ThemeService : public base::NonThreadSafe, // destroyed, uninstalls all themes that aren't the currently selected. void OnInfobarDestroyed(); - // Convert a bitfield alignment into a string like "top left". Public so that - // it can be used to generate CSS values. Takes a bitmask of Alignment. - static std::string AlignmentToString(int alignment); - - // Parse alignments from something like "top left" into a bitmask of - // Alignment. - static int StringToAlignment(const std::string& alignment); - - // Convert a tiling value into a string like "no-repeat". Public - // so that it can be used to generate CSS values. Takes a Tiling. - static std::string TilingToString(int tiling); - - // Parse tiling values from something like "no-repeat" into a Tiling value. - static int StringToTiling(const std::string& tiling); - - // Returns the default tint for the given tint |id| TINT_* enum value. - static color_utils::HSL GetDefaultTint(int id); - - // Returns the default color for the given color |id| COLOR_* enum value. - static SkColor GetDefaultColor(int id); - - // Returns true and sets |result| to the requested default property, if |id| - // is valid. - static bool GetDefaultDisplayProperty(int id, int* result); - - // Returns the set of IDR_* resources that should be tinted. - static const std::set<int>& GetTintableToolbarButtons(); - // Remove preference values for themes that are no longer in use. void RemoveUnusedThemes(); diff --git a/chrome/browser/themes/theme_service_mac.mm b/chrome/browser/themes/theme_service_mac.mm index 0cbe655..abb441b 100644 --- a/chrome/browser/themes/theme_service_mac.mm +++ b/chrome/browser/themes/theme_service_mac.mm @@ -8,6 +8,7 @@ #include "base/logging.h" #include "chrome/browser/themes/browser_theme_pack.h" +#include "chrome/browser/themes/theme_properties.h" #include "skia/ext/skia_utils_mac.h" #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" #include "ui/base/resource/resource_bundle.h" @@ -18,6 +19,8 @@ NSString* const kBrowserThemeDidChangeNotification = @"BrowserThemeDidChangeNotification"; +typedef ThemeProperties Properties; + namespace { void HSLToHSB(const color_utils::HSL& hsl, CGFloat* h, CGFloat* s, CGFloat* b) { @@ -127,7 +130,7 @@ NSColor* ThemeService::GetNSColor(int id, bool allow_default) const { is_default = false; } else { is_default = true; - sk_color = GetDefaultColor(id); + sk_color = ThemeProperties::GetDefaultColor(id); } if (is_default && !allow_default) @@ -159,7 +162,7 @@ NSColor* ThemeService::GetNSColorTint(int id, bool allow_default) const { is_default = false; } else { is_default = true; - tint = GetDefaultTint(id); + tint = ThemeProperties::GetDefaultTint(id); } if (is_default && !allow_default) @@ -198,10 +201,10 @@ NSGradient* ThemeService::GetNSGradient(int id) const { // Note that we are not leaking when we assign a retained object to // |gradient|; in all cases we cache it before we return. switch (id) { - case GRADIENT_FRAME_INCOGNITO: - case GRADIENT_FRAME_INCOGNITO_INACTIVE: { + case Properties::GRADIENT_FRAME_INCOGNITO: + case Properties::GRADIENT_FRAME_INCOGNITO_INACTIVE: { // TODO(avi): can we simplify this? - BOOL active = id == GRADIENT_FRAME_INCOGNITO; + BOOL active = id == Properties::GRADIENT_FRAME_INCOGNITO; NSColor* base_color = [NSColor colorWithCalibratedRed:83/255.0 green:108.0/255.0 blue:140/255.0 @@ -226,11 +229,11 @@ NSGradient* ThemeService::GetNSGradient(int id) const { break; } - case GRADIENT_TOOLBAR: - case GRADIENT_TOOLBAR_INACTIVE: { + case Properties::GRADIENT_TOOLBAR: + case Properties::GRADIENT_TOOLBAR_INACTIVE: { NSColor* base_color = [NSColor colorWithCalibratedWhite:0.2 alpha:1.0]; - BOOL faded = (id == GRADIENT_TOOLBAR_INACTIVE ) || - (id == GRADIENT_TOOLBAR_BUTTON_INACTIVE); + BOOL faded = (id == Properties::GRADIENT_TOOLBAR_INACTIVE ) || + (id == Properties::GRADIENT_TOOLBAR_BUTTON_INACTIVE); NSColor* start_color = [base_color gtm_colorAdjustedFor:GTMColorationLightHighlight faded:faded]; @@ -253,18 +256,18 @@ NSGradient* ThemeService::GetNSGradient(int id) const { break; } - case GRADIENT_TOOLBAR_BUTTON: - case GRADIENT_TOOLBAR_BUTTON_INACTIVE: { + case Properties::GRADIENT_TOOLBAR_BUTTON: + case Properties::GRADIENT_TOOLBAR_BUTTON_INACTIVE: { NSColor* start_color = [NSColor colorWithCalibratedWhite:1.0 alpha:0.0]; NSColor* end_color = [NSColor colorWithCalibratedWhite:1.0 alpha:0.3]; gradient = [[NSGradient alloc] initWithStartingColor:start_color endingColor:end_color]; break; } - case GRADIENT_TOOLBAR_BUTTON_PRESSED: - case GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE: { + case Properties::GRADIENT_TOOLBAR_BUTTON_PRESSED: + case Properties::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE: { NSColor* base_color = [NSColor colorWithCalibratedWhite:0.5 alpha:1.0]; - BOOL faded = id == GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE; + BOOL faded = id == Properties::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE; NSColor* start_color = [base_color gtm_colorAdjustedFor:GTMColorationBaseShadow faded:faded]; diff --git a/chrome/browser/themes/theme_service_unittest.cc b/chrome/browser/themes/theme_service_unittest.cc index b88e832..78f6160 100644 --- a/chrome/browser/themes/theme_service_unittest.cc +++ b/chrome/browser/themes/theme_service_unittest.cc @@ -40,50 +40,6 @@ class ThemeServiceTest : public ExtensionServiceTestBase { } }; -TEST_F(ThemeServiceTest, AlignmentConversion) { - // Verify that we get out what we put in. - std::string top_left = "left top"; - int alignment = ThemeService::StringToAlignment(top_left); - EXPECT_EQ(ThemeService::ALIGN_TOP | ThemeService::ALIGN_LEFT, - alignment); - EXPECT_EQ(top_left, ThemeService::AlignmentToString(alignment)); - - // We get back a normalized version of what we put in. - alignment = ThemeService::StringToAlignment("top"); - EXPECT_EQ(ThemeService::ALIGN_TOP, alignment); - EXPECT_EQ("center top", ThemeService::AlignmentToString(alignment)); - - alignment = ThemeService::StringToAlignment("left"); - EXPECT_EQ(ThemeService::ALIGN_LEFT, alignment); - EXPECT_EQ("left center", ThemeService::AlignmentToString(alignment)); - - alignment = ThemeService::StringToAlignment("right"); - EXPECT_EQ(ThemeService::ALIGN_RIGHT, alignment); - EXPECT_EQ("right center", ThemeService::AlignmentToString(alignment)); - - alignment = ThemeService::StringToAlignment("righttopbottom"); - EXPECT_EQ(ThemeService::ALIGN_CENTER, alignment); - EXPECT_EQ("center center", ThemeService::AlignmentToString(alignment)); -} - -TEST_F(ThemeServiceTest, AlignmentConversionInput) { - // Verify that we output in an expected format. - int alignment = ThemeService::StringToAlignment("bottom right"); - EXPECT_EQ("right bottom", ThemeService::AlignmentToString(alignment)); - - // Verify that bad strings don't cause explosions. - alignment = ThemeService::StringToAlignment("new zealand"); - EXPECT_EQ("center center", ThemeService::AlignmentToString(alignment)); - - // Verify that bad strings don't cause explosions. - alignment = ThemeService::StringToAlignment("new zealand top"); - EXPECT_EQ("center top", ThemeService::AlignmentToString(alignment)); - - // Verify that bad strings don't cause explosions. - alignment = ThemeService::StringToAlignment("new zealandtop"); - EXPECT_EQ("center center", ThemeService::AlignmentToString(alignment)); -} - // Installs then uninstalls a theme and makes sure that the ThemeService // reverts to the default theme after the uninstall. TEST_F(ThemeServiceTest, ThemeInstallUninstall) { diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc index 00493e2..582ae88 100644 --- a/chrome/browser/ui/browser_instant_controller.cc +++ b/chrome/browser/ui/browser_instant_controller.cc @@ -8,6 +8,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/prefs/pref_registry_syncable.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" @@ -270,7 +271,7 @@ void BrowserInstantController::OnThemeChanged(ThemeService* theme_service) { // Set theme background color. SkColor background_color = - theme_service->GetColor(ThemeService::COLOR_NTP_BACKGROUND); + theme_service->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND); if (gfx::IsInvertedColorScheme()) background_color = color_utils::InvertColor(background_color); theme_info_.color_r = SkColorGetR(background_color); @@ -284,11 +285,11 @@ void BrowserInstantController::OnThemeChanged(ThemeService* theme_service) { // Set theme background image horizontal alignment. int alignment = 0; - theme_service->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, - &alignment); - if (alignment & ThemeService::ALIGN_LEFT) { + theme_service->GetDisplayProperty( + ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &alignment); + if (alignment & ThemeProperties::ALIGN_LEFT) { theme_info_.image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_LEFT; - } else if (alignment & ThemeService::ALIGN_RIGHT) { + } else if (alignment & ThemeProperties::ALIGN_RIGHT) { theme_info_.image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_RIGHT; } else { // ALIGN_CENTER theme_info_.image_horizontal_alignment = @@ -296,7 +297,7 @@ void BrowserInstantController::OnThemeChanged(ThemeService* theme_service) { } // Set theme background image vertical alignment. - if (alignment & ThemeService::ALIGN_TOP) { + if (alignment & ThemeProperties::ALIGN_TOP) { theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_TOP; #if !defined(OS_ANDROID) // A detached bookmark bar will draw the top part of a top-aligned theme @@ -304,7 +305,7 @@ void BrowserInstantController::OnThemeChanged(ThemeService* theme_service) { if (browser_->bookmark_bar_state() == BookmarkBar::DETACHED) theme_info_.image_top_offset = -chrome::kNTPBookmarkBarHeight; #endif // !defined(OS_ANDROID) - } else if (alignment & ThemeService::ALIGN_BOTTOM) { + } else if (alignment & ThemeProperties::ALIGN_BOTTOM) { theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_BOTTOM; } else { // ALIGN_CENTER theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; @@ -312,19 +313,19 @@ void BrowserInstantController::OnThemeChanged(ThemeService* theme_service) { // Set theme background image tiling. int tiling = 0; - theme_service->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, + theme_service->GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_TILING, &tiling); switch (tiling) { - case ThemeService::NO_REPEAT: + case ThemeProperties::NO_REPEAT: theme_info_.image_tiling = THEME_BKGRND_IMAGE_NO_REPEAT; break; - case ThemeService::REPEAT_X: + case ThemeProperties::REPEAT_X: theme_info_.image_tiling = THEME_BKGRND_IMAGE_REPEAT_X; break; - case ThemeService::REPEAT_Y: + case ThemeProperties::REPEAT_Y: theme_info_.image_tiling = THEME_BKGRND_IMAGE_REPEAT_Y; break; - case ThemeService::REPEAT: + case ThemeProperties::REPEAT: theme_info_.image_tiling = THEME_BKGRND_IMAGE_REPEAT; break; } diff --git a/chrome/browser/ui/chrome_style.cc b/chrome/browser/ui/chrome_style.cc index ef8ebbc..9036c56 100644 --- a/chrome/browser/ui/chrome_style.cc +++ b/chrome/browser/ui/chrome_style.cc @@ -4,7 +4,7 @@ #include "chrome/browser/ui/chrome_style.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "grit/ui_resources.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image.h" @@ -19,7 +19,8 @@ int GetCloseButtonSize() { } SkColor GetBackgroundColor() { - return ThemeService::GetDefaultColor(ThemeService::COLOR_CONTROL_BACKGROUND); + return ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_CONTROL_BACKGROUND); } SkColor GetLinkColor() { diff --git a/chrome/browser/ui/cocoa/background_gradient_view.mm b/chrome/browser/ui/cocoa/background_gradient_view.mm index db2a3ec..b9534f9 100644 --- a/chrome/browser/ui/cocoa/background_gradient_view.mm +++ b/chrome/browser/ui/cocoa/background_gradient_view.mm @@ -4,6 +4,7 @@ #include "chrome/browser/ui/cocoa/background_gradient_view.h" +#import "chrome/browser/themes/theme_properties.h" #import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/nsview_additions.h" #import "chrome/browser/ui/cocoa/themed_window.h" @@ -66,8 +67,8 @@ if (!themeProvider) return [NSColor blackColor]; return themeProvider->GetNSColor( - isActive ? ThemeService::COLOR_TOOLBAR_STROKE : - ThemeService::COLOR_TOOLBAR_STROKE_INACTIVE, true); + isActive ? ThemeProperties::COLOR_TOOLBAR_STROKE : + ThemeProperties::COLOR_TOOLBAR_STROKE_INACTIVE, true); } - (NSColor*)backgroundImageColor { diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm index d368c9e..a35f8b1 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm @@ -16,7 +16,8 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/profiles/profile.h" -#import "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" +#include "chrome/browser/themes/theme_service.h" #import "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/bookmarks/bookmark_utils.h" #include "chrome/browser/ui/browser.h" @@ -1314,7 +1315,7 @@ void RecordAppLaunch(Profile* profile, GURL url) { ui::ThemeProvider* themeProvider = [[[self view] window] themeProvider]; if (themeProvider) { NSColor* color = - themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, + themeProvider->GetNSColor(ThemeProperties::COLOR_BOOKMARK_TEXT, true); [cell setTextColor:color]; } @@ -1865,7 +1866,7 @@ void RecordAppLaunch(Profile* profile, GURL url) { if (!themeProvider) return; NSColor* color = - themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, + themeProvider->GetNSColor(ThemeProperties::COLOR_BOOKMARK_TEXT, true); for (BookmarkButton* button in buttons_.get()) { BookmarkButtonCell* cell = [button cell]; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm index 865a252..277bdc0 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm @@ -4,7 +4,7 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" @@ -103,7 +103,7 @@ const CGFloat kBorderRadius = 3.0; // Draw the rounded rectangle. NSColor* toolbarColor = - themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true); + themeProvider->GetNSColor(ThemeProperties::COLOR_TOOLBAR, true); CGFloat alpha = morph * [toolbarColor alphaComponent]; [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity. [border fill]; @@ -123,7 +123,7 @@ const CGFloat kBorderRadius = 3.0; // Draw the border of the rounded rectangle. NSColor* borderColor = themeProvider->GetNSColor( - ThemeService::COLOR_TOOLBAR_BUTTON_STROKE, true); + ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE, true); alpha = morph * [borderColor alphaComponent]; [[borderColor colorWithAlphaComponent:alpha] set]; // Set with opacity. [border stroke]; @@ -166,7 +166,8 @@ const CGFloat kBorderRadius = 3.0; CGContextBeginTransparencyLayer(cgContext, NULL); CGContextSetAlpha( cgContext, chrome::search::kBookmarkBarThemeBackgroundAlphaFactor); - [themeProvider->GetNSColor(ThemeService::COLOR_NTP_BACKGROUND, true) set]; + [themeProvider->GetNSColor(ThemeProperties::COLOR_NTP_BACKGROUND, true) + set]; NSRectFillUsingOperation(bounds, NSCompositeSourceOver); CGContextEndTransparencyLayer(cgContext); } @@ -179,8 +180,8 @@ const CGFloat kBorderRadius = 3.0; NSColor* strokeColor = nil; if (useThemeColor) { - strokeColor = - themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR_SEPARATOR, true); + strokeColor = themeProvider->GetNSColor( + ThemeProperties::COLOR_TOOLBAR_SEPARATOR, true); } else { strokeColor = gfx::SkColorToCalibratedNSColor( chrome::search::GetBookmarkBarNoThemeSeparatorColor()); diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view_unittest.mm index 4ed5ecf..25e73a3 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view_unittest.mm @@ -5,7 +5,7 @@ #import <Cocoa/Cocoa.h> #include "base/memory/scoped_nsobject.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" @@ -142,7 +142,7 @@ TEST_F(BookmarkBarToolbarViewTest, DisplayAsDetachedBarWithNoImage) { // Tests where we don't have a background image, only a color. NiceMock<MockThemeProvider> provider; - EXPECT_CALL(provider, GetColor(ThemeService::COLOR_NTP_BACKGROUND)) + EXPECT_CALL(provider, GetColor(ThemeProperties::COLOR_NTP_BACKGROUND)) .WillRepeatedly(Return(SK_ColorWHITE)); EXPECT_CALL(provider, HasCustomImage(IDR_THEME_NTP_BACKGROUND)) .WillRepeatedly(Return(false)); @@ -153,12 +153,12 @@ TEST_F(BookmarkBarToolbarViewTest, DisplayAsDetachedBarWithNoImage) { // Actions used in DisplayAsDetachedBarWithBgImage. ACTION(SetBackgroundTiling) { - *arg1 = ThemeService::NO_REPEAT; + *arg1 = ThemeProperties::NO_REPEAT; return true; } ACTION(SetAlignLeft) { - *arg1 = ThemeService::ALIGN_LEFT; + *arg1 = ThemeProperties::ALIGN_LEFT; return true; } @@ -170,17 +170,17 @@ TEST_F(BookmarkBarToolbarViewTest, DisplayAsDetachedBarWithBgImage) { NiceMock<MockThemeProvider> provider; // Advertise having an image. - EXPECT_CALL(provider, GetColor(ThemeService::COLOR_NTP_BACKGROUND)) + EXPECT_CALL(provider, GetColor(ThemeProperties::COLOR_NTP_BACKGROUND)) .WillRepeatedly(Return(SK_ColorRED)); EXPECT_CALL(provider, HasCustomImage(IDR_THEME_NTP_BACKGROUND)) .WillRepeatedly(Return(true)); // Return the correct tiling/alignment information. EXPECT_CALL(provider, - GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, _)) + GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_TILING, _)) .WillRepeatedly(SetBackgroundTiling()); EXPECT_CALL(provider, - GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, _)) + GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_ALIGNMENT, _)) .WillRepeatedly(SetAlignLeft()); // Create a dummy bitmap full of not-red to blit with. @@ -207,10 +207,10 @@ TEST_F(BookmarkBarToolbarViewTest, DisplayAsBottomDetachedBar) { NSColor* color = [NSColor redColor]; EXPECT_CALL(provider, HasCustomImage(IDR_THEME_NTP_BACKGROUND)) .WillRepeatedly(Return(true)); - EXPECT_CALL(provider, GetNSColor(ThemeService::COLOR_NTP_BACKGROUND, true)) + EXPECT_CALL(provider, GetNSColor(ThemeProperties::COLOR_NTP_BACKGROUND, true)) .WillRepeatedly(Return(color)); EXPECT_CALL(provider, - GetNSColor(ThemeService::COLOR_TOOLBAR_SEPARATOR, true)) + GetNSColor(ThemeProperties::COLOR_TOOLBAR_SEPARATOR, true)) .WillRepeatedly(Return(color)); [controller_.get() setThemeProvider:&provider]; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm index 17f08aa..36f41ee 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm @@ -6,6 +6,7 @@ #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" #include "chrome/browser/profiles/profile.h" +#import "chrome/browser/themes/theme_properties.h" #import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" @@ -85,7 +86,7 @@ using content::UserMetricsAction; return; NSColor* color = - themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, + themeProvider->GetNSColor(ThemeProperties::COLOR_BOOKMARK_TEXT, true); [noItemTextfield_ setTextColor:color]; } diff --git a/chrome/browser/ui/cocoa/bubble_view.mm b/chrome/browser/ui/cocoa/bubble_view.mm index 3c36e7c..4c3d8e0 100644 --- a/chrome/browser/ui/cocoa/bubble_view.mm +++ b/chrome/browser/ui/cocoa/bubble_view.mm @@ -4,10 +4,11 @@ #import "chrome/browser/ui/cocoa/bubble_view.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #import "chrome/browser/ui/cocoa/themed_window.h" #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" +#include "ui/base/theme_provider.h" // The roundedness of the edges of the bubble. This matches the value used on // Lion for window corners. @@ -91,7 +92,7 @@ const float kWindowEdge = 0.7f; bottomRightCornerRadius:bottomRightRadius]; if (themeProvider) - [themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true) set]; + [themeProvider->GetNSColor(ThemeProperties::COLOR_TOOLBAR, true) set]; [border fill]; [[NSColor colorWithDeviceWhite:kWindowEdge alpha:1.0f] set]; @@ -100,7 +101,7 @@ const float kWindowEdge = 0.7f; // Text NSColor* textColor = [NSColor blackColor]; if (themeProvider) - textColor = themeProvider->GetNSColor(ThemeService::COLOR_TAB_TEXT, + textColor = themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT, true); NSFont* textFont = [self font]; scoped_nsobject<NSShadow> textShadow([[NSShadow alloc] init]); diff --git a/chrome/browser/ui/cocoa/download/background_theme.mm b/chrome/browser/ui/cocoa/download/background_theme.mm index 1d596cc..9ee1d29 100644 --- a/chrome/browser/ui/cocoa/download/background_theme.mm +++ b/chrome/browser/ui/cocoa/download/background_theme.mm @@ -4,7 +4,7 @@ #include "chrome/browser/ui/cocoa/download/background_theme.h" -#import "chrome/browser/themes/theme_service.h" +#import "chrome/browser/themes/theme_properties.h" BackgroundTheme::BackgroundTheme(ui::ThemeProvider* provider) : provider_(provider) { @@ -67,7 +67,7 @@ NSColor* BackgroundTheme::GetNSColor(int id, bool allow_default) const { } NSColor* BackgroundTheme::GetNSColorTint(int id, bool allow_default) const { - if (id == ThemeService::TINT_BUTTONS) + if (id == ThemeProperties::TINT_BUTTONS) return borderColor_.get(); return provider_->GetNSColorTint(id, allow_default); @@ -75,11 +75,11 @@ NSColor* BackgroundTheme::GetNSColorTint(int id, bool allow_default) const { NSGradient* BackgroundTheme::GetNSGradient(int id) const { switch (id) { - case ThemeService::GRADIENT_TOOLBAR_BUTTON: - case ThemeService::GRADIENT_TOOLBAR_BUTTON_INACTIVE: + case ThemeProperties::GRADIENT_TOOLBAR_BUTTON: + case ThemeProperties::GRADIENT_TOOLBAR_BUTTON_INACTIVE: return buttonGradient_.get(); - case ThemeService::GRADIENT_TOOLBAR_BUTTON_PRESSED: - case ThemeService::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE: + case ThemeProperties::GRADIENT_TOOLBAR_BUTTON_PRESSED: + case ThemeProperties::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE: return buttonPressedGradient_.get(); default: return provider_->GetNSGradient(id); diff --git a/chrome/browser/ui/cocoa/download/download_item_cell.mm b/chrome/browser/ui/cocoa/download/download_item_cell.mm index 779291b..ee31de2 100644 --- a/chrome/browser/ui/cocoa/download/download_item_cell.mm +++ b/chrome/browser/ui/cocoa/download/download_item_cell.mm @@ -7,7 +7,7 @@ #include "base/sys_string_conversions.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_util.h" -#import "chrome/browser/themes/theme_service.h" +#import "chrome/browser/themes/theme_properties.h" #import "chrome/browser/ui/cocoa/download/background_theme.h" #import "chrome/browser/ui/cocoa/themed_window.h" #include "content/public/browser/download_item.h" @@ -413,7 +413,7 @@ using content::DownloadItem; [[[self controlView] window] themeProvider]; if ([self pressedWithDefaultThemeOnPart:part] || !themeProvider) return [NSColor alternateSelectedControlTextColor]; - return themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, true); + return themeProvider->GetNSColor(ThemeProperties::COLOR_BOOKMARK_TEXT, true); } - (void)drawSecondaryTitleInRect:(NSRect)innerFrame { @@ -476,8 +476,8 @@ using content::DownloadItem; if (![self isDefaultTheme]) { themeProvider = [self backgroundThemeWrappingProvider:themeProvider]; bgGradient = themeProvider->GetNSGradient( - active ? ThemeService::GRADIENT_TOOLBAR_BUTTON : - ThemeService::GRADIENT_TOOLBAR_BUTTON_INACTIVE); + active ? ThemeProperties::GRADIENT_TOOLBAR_BUTTON : + ThemeProperties::GRADIENT_TOOLBAR_BUTTON_INACTIVE); } NSRect buttonDrawRect, dropdownDrawRect; diff --git a/chrome/browser/ui/cocoa/download/download_item_controller.mm b/chrome/browser/ui/cocoa/download/download_item_controller.mm index 2d4fbd4..5bdd12e 100644 --- a/chrome/browser/ui/cocoa/download/download_item_controller.mm +++ b/chrome/browser/ui/cocoa/download/download_item_controller.mm @@ -15,6 +15,7 @@ #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_shelf_context_menu.h" #include "chrome/browser/download/download_util.h" +#import "chrome/browser/themes/theme_properties.h" #import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/download/download_item_button.h" #import "chrome/browser/ui/cocoa/download/download_item_cell.h" @@ -295,7 +296,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { return; NSColor* color = - themeProvider->GetNSColor(ThemeService::COLOR_TAB_TEXT, true); + themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT, true); [dangerousDownloadLabel_ setTextColor:color]; } diff --git a/chrome/browser/ui/cocoa/download/download_shelf_view.mm b/chrome/browser/ui/cocoa/download/download_shelf_view.mm index 4f09f81..b3084c5 100644 --- a/chrome/browser/ui/cocoa/download/download_shelf_view.mm +++ b/chrome/browser/ui/cocoa/download/download_shelf_view.mm @@ -5,6 +5,7 @@ #import "chrome/browser/ui/cocoa/download/download_shelf_view.h" #include "base/memory/scoped_nsobject.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/nsview_additions.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" @@ -35,8 +36,8 @@ BOOL isActive = [[self window] isMainWindow]; ui::ThemeProvider* themeProvider = [[self window] themeProvider]; return themeProvider ? themeProvider->GetNSColor( - isActive ? ThemeService::COLOR_TOOLBAR_STROKE : - ThemeService::COLOR_TOOLBAR_STROKE_INACTIVE, true) : + isActive ? ThemeProperties::COLOR_TOOLBAR_STROKE : + ThemeProperties::COLOR_TOOLBAR_STROKE_INACTIVE, true) : [NSColor blackColor]; } @@ -63,7 +64,7 @@ static_cast<ThemeService*>([[self window] themeProvider]); if (themeProvider) { int resourceName = themeProvider->UsingDefaultTheme() ? - ThemeService::COLOR_TOOLBAR_BEZEL : ThemeService::COLOR_TOOLBAR; + ThemeProperties::COLOR_TOOLBAR_BEZEL : ThemeProperties::COLOR_TOOLBAR; NSColor* highlightColor = themeProvider->GetNSColor(resourceName, true); if (highlightColor) { [highlightColor set]; diff --git a/chrome/browser/ui/cocoa/download/download_show_all_cell.mm b/chrome/browser/ui/cocoa/download/download_show_all_cell.mm index 626529e..d7f6d6b 100644 --- a/chrome/browser/ui/cocoa/download/download_show_all_cell.mm +++ b/chrome/browser/ui/cocoa/download/download_show_all_cell.mm @@ -4,6 +4,7 @@ #import "chrome/browser/ui/cocoa/download/download_show_all_cell.h" +#import "chrome/browser/themes/theme_properties.h" #import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/download/background_theme.h" #import "chrome/browser/ui/cocoa/themed_window.h" @@ -95,7 +96,7 @@ const CGFloat kOuterStrokeWidth = 1; [[[self controlView] window] themeProvider]; if (!themeProvider || [self pressedWithDefaultTheme]) return [NSColor alternateSelectedControlTextColor]; - return themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, true); + return themeProvider->GetNSColor(ThemeProperties::COLOR_BOOKMARK_TEXT, true); } - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { @@ -123,8 +124,8 @@ const CGFloat kOuterStrokeWidth = 1; if (!isDefaultTheme) { themeProvider = [self backgroundThemeWrappingProvider:themeProvider]; bgGradient = themeProvider->GetNSGradient( - active ? ThemeService::GRADIENT_TOOLBAR_BUTTON : - ThemeService::GRADIENT_TOOLBAR_BUTTON_INACTIVE); + active ? ThemeProperties::GRADIENT_TOOLBAR_BUTTON : + ThemeProperties::GRADIENT_TOOLBAR_BUTTON_INACTIVE); } NSBezierPath* buttonInnerPath = diff --git a/chrome/browser/ui/cocoa/framed_browser_window.mm b/chrome/browser/ui/cocoa/framed_browser_window.mm index 45257817..a868fa0 100644 --- a/chrome/browser/ui/cocoa/framed_browser_window.mm +++ b/chrome/browser/ui/cocoa/framed_browser_window.mm @@ -12,6 +12,7 @@ #import "chrome/browser/ui/cocoa/nsview_additions.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" #import "chrome/browser/ui/cocoa/themed_window.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #include "grit/theme_resources.h" @@ -431,8 +432,8 @@ const CGFloat kWindowGradientHeight = 24.0; NSGradient* gradient = nil; if (!themeImageColor && incognito) gradient = themeProvider->GetNSGradient( - active ? ThemeService::GRADIENT_FRAME_INCOGNITO : - ThemeService::GRADIENT_FRAME_INCOGNITO_INACTIVE); + active ? ThemeProperties::GRADIENT_FRAME_INCOGNITO : + ThemeProperties::GRADIENT_FRAME_INCOGNITO_INACTIVE); BOOL themed = NO; if (themeImageColor) { @@ -520,10 +521,10 @@ const CGFloat kWindowGradientHeight = 24.0; NSColor* titleColor = nil; if (popup && active) { titleColor = themeProvider->GetNSColor( - ThemeService::COLOR_TAB_TEXT, false); + ThemeProperties::COLOR_TAB_TEXT, false); } else if (popup && !active) { titleColor = themeProvider->GetNSColor( - ThemeService::COLOR_BACKGROUND_TAB_TEXT, false); + ThemeProperties::COLOR_BACKGROUND_TAB_TEXT, false); } if (titleColor) diff --git a/chrome/browser/ui/cocoa/gradient_button_cell.mm b/chrome/browser/ui/cocoa/gradient_button_cell.mm index 78dd2d8..e2e96cb 100644 --- a/chrome/browser/ui/cocoa/gradient_button_cell.mm +++ b/chrome/browser/ui/cocoa/gradient_button_cell.mm @@ -8,6 +8,7 @@ #include "base/logging.h" #import "base/memory/scoped_nsobject.h" +#import "chrome/browser/themes/theme_properties.h" #import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/nsview_additions.h" #import "chrome/browser/ui/cocoa/themed_window.h" @@ -396,8 +397,8 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4; } else { clickedGradient = themeProvider ? themeProvider->GetNSGradient( active ? - ThemeService::GRADIENT_TOOLBAR_BUTTON_PRESSED : - ThemeService::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE) : + ThemeProperties::GRADIENT_TOOLBAR_BUTTON_PRESSED : + ThemeProperties::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE) : nil; } [clickedGradient drawInBezierPath:innerPath angle:90.0]; @@ -440,8 +441,8 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4; alpha:0.3 * outerStrokeAlphaMult_]; } else { strokeColor = themeProvider ? themeProvider->GetNSColor( - active ? ThemeService::COLOR_TOOLBAR_BUTTON_STROKE : - ThemeService::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + active ? ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE : + ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, true) : [NSColor colorWithCalibratedWhite:0.0 alpha:0.3 * outerStrokeAlphaMult_]; } @@ -555,8 +556,8 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4; NSRect borderRect, contentRect; NSDivideRect(cellFrame, &borderRect, &contentRect, lineWidth, NSMaxXEdge); NSColor* stroke = themeProvider ? themeProvider->GetNSColor( - active ? ThemeService::COLOR_TOOLBAR_BUTTON_STROKE : - ThemeService::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + active ? ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE : + ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, true) : [NSColor blackColor]; [[stroke colorWithAlphaComponent:0.2] set]; @@ -597,13 +598,13 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4; ThemeService* themeProvider = static_cast<ThemeService*>( [[controlView window] themeProvider]); NSColor* color = themeProvider ? - themeProvider->GetNSColorTint(ThemeService::TINT_BUTTONS, true) : + themeProvider->GetNSColorTint(ThemeProperties::TINT_BUTTONS, true) : [NSColor blackColor]; if (isTemplate && themeProvider && themeProvider->UsingDefaultTheme()) { scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); [shadow.get() setShadowColor:themeProvider->GetNSColor( - ThemeService::COLOR_TOOLBAR_BEZEL, true)]; + ThemeProperties::COLOR_TOOLBAR_BEZEL, true)]; [shadow.get() setShadowOffset:NSMakeSize(0.0, -lineWidth)]; [shadow setShadowBlurRadius:lineWidth]; [shadow set]; diff --git a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm index 3fc28cc9..5854feb 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm @@ -6,12 +6,13 @@ #include "base/memory/scoped_nsobject.h" #include "chrome/browser/infobars/infobar.h" -#import "chrome/browser/themes/theme_service.h" +#import "chrome/browser/themes/theme_properties.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" #import "chrome/browser/ui/cocoa/themed_window.h" #include "skia/ext/skia_utils_mac.h" +#include "ui/base/theme_provider.h" namespace { @@ -39,8 +40,8 @@ const CGFloat kTipWidth = 23; BOOL active = [[self window] isMainWindow]; return themeProvider->GetNSColor( - active ? ThemeService::COLOR_TOOLBAR_STROKE : - ThemeService::COLOR_TOOLBAR_STROKE_INACTIVE, + active ? ThemeProperties::COLOR_TOOLBAR_STROKE : + ThemeProperties::COLOR_TOOLBAR_STROKE_INACTIVE, true); } diff --git a/chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.mm b/chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.mm index 7dd5f9d..d447d51 100644 --- a/chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.mm +++ b/chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.mm @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/mac/scoped_nsautorelease_pool.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/hover_image_button.h" #import "chrome/browser/ui/cocoa/nsview_additions.h" @@ -216,8 +217,8 @@ static NSEvent* MakeMouseEvent(NSEventType type, NSRectFillUsingOperation([self bounds], NSCompositeSourceOver); titleColor = [[self window] isMainWindow] - ? theme->GetNSColor(ThemeService::COLOR_TAB_TEXT, true) - : theme->GetNSColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT, true); + ? theme->GetNSColor(ThemeProperties::COLOR_TAB_TEXT, true) + : theme->GetNSColor(ThemeProperties::COLOR_BACKGROUND_TAB_TEXT, true); } else { // Default theme or no theme. BOOL isActive = [[self window] isMainWindow]; diff --git a/chrome/browser/ui/cocoa/styled_text_field_cell.mm b/chrome/browser/ui/cocoa/styled_text_field_cell.mm index 024be77..4cf3f70 100644 --- a/chrome/browser/ui/cocoa/styled_text_field_cell.mm +++ b/chrome/browser/ui/cocoa/styled_text_field_cell.mm @@ -5,6 +5,7 @@ #import "chrome/browser/ui/cocoa/styled_text_field_cell.h" #include "base/logging.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/nsview_additions.h" #import "chrome/browser/ui/cocoa/themed_window.h" @@ -98,8 +99,8 @@ // Draw the outer stroke (over the background). BOOL active = [[controlView window] isMainWindow]; NSColor* strokeColor = themeProvider->GetNSColor( - active ? ThemeService::COLOR_TOOLBAR_BUTTON_STROKE : - ThemeService::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + active ? ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE : + ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, true); rect_path_utils::FrameRectWithInset(roundedCornerFlags, frame, 0.0, 0.0, radius, lineWidth, strokeColor); @@ -134,7 +135,7 @@ themeProvider->UsingDefaultTheme()) { NSColor* bezelColor = themeProvider->GetNSColor( - ThemeService::COLOR_TOOLBAR_BEZEL, true); + ThemeProperties::COLOR_TOOLBAR_BEZEL, true); [[bezelColor colorWithAlphaComponent:0.5 / lineWidth] set]; NSRect bezelRect = NSMakeRect(cellFrame.origin.x, NSMaxY(cellFrame) - lineWidth, diff --git a/chrome/browser/ui/cocoa/tabs/tab_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_controller.mm index f672497..8b3dd2c 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_controller.mm @@ -8,6 +8,7 @@ #include "base/mac/bundle_locations.h" #include "base/mac/mac_util.h" +#import "chrome/browser/themes/theme_properties.h" #import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/menu_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" @@ -356,12 +357,12 @@ class MenuDelegate : public ui::SimpleMenuModel::Delegate { ui::ThemeProvider* theme = [[[self view] window] themeProvider]; if (theme && ![self selected]) { titleColor = - theme->GetNSColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT, + theme->GetNSColor(ThemeProperties::COLOR_BACKGROUND_TAB_TEXT, true); } // Default to the selected text color unless told otherwise. if (theme && !titleColor) { - titleColor = theme->GetNSColor(ThemeService::COLOR_TAB_TEXT, + titleColor = theme->GetNSColor(ThemeProperties::COLOR_TAB_TEXT, true); } [titleView_ setTextColor:titleColor ? titleColor : [NSColor textColor]]; diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc index c170c74..032993d 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc @@ -19,6 +19,7 @@ #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" #include "chrome/browser/ui/bookmarks/bookmark_utils.h" #include "chrome/browser/ui/browser.h" @@ -196,7 +197,7 @@ void BookmarkBarGtk::Init() { paint_box_ = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(ntp_padding_box_), paint_box_); GdkColor paint_box_color = - theme_service_->GetGdkColor(ThemeService::COLOR_TOOLBAR); + theme_service_->GetGdkColor(ThemeProperties::COLOR_TOOLBAR); gtk_widget_modify_bg(paint_box_, GTK_STATE_NORMAL, &paint_box_color); gtk_widget_add_events(paint_box_, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK); @@ -636,7 +637,7 @@ void BookmarkBarGtk::UpdateDetachedState(BookmarkBar::State old_state) { gtk_event_box_set_visible_window(GTK_EVENT_BOX(paint_box_), TRUE); GdkColor stroke_color = theme_service_->UsingNativeTheme() ? theme_service_->GetBorderColor() : - theme_service_->GetGdkColor(ThemeService::COLOR_NTP_HEADER); + theme_service_->GetGdkColor(ThemeProperties::COLOR_NTP_HEADER); gtk_util::ActAsRoundedWindow(paint_box_, stroke_color, kNTPRoundedness, gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); @@ -974,13 +975,13 @@ void BookmarkBarGtk::Observe(int type, UpdateEventBoxPaintability(); GdkColor paint_box_color = - theme_service_->GetGdkColor(ThemeService::COLOR_TOOLBAR); + theme_service_->GetGdkColor(ThemeProperties::COLOR_TOOLBAR); gtk_widget_modify_bg(paint_box_, GTK_STATE_NORMAL, &paint_box_color); if (bookmark_bar_state_ == BookmarkBar::DETACHED) { GdkColor stroke_color = theme_service_->UsingNativeTheme() ? theme_service_->GetBorderColor() : - theme_service_->GetGdkColor(ThemeService::COLOR_NTP_HEADER); + theme_service_->GetGdkColor(ThemeProperties::COLOR_NTP_HEADER); gtk_util::SetRoundedWindowBorderColor(paint_box_, stroke_color); } diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.cc index d4f10d8..ac66a4b 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h" #include "base/observer_list.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/bookmarks/bookmark_bar_instructions_delegate.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" @@ -69,7 +70,7 @@ void BookmarkBarInstructionsGtk::OnButtonClick(GtkWidget* button) { void BookmarkBarInstructionsGtk::UpdateColors() { GdkColor bookmark_color = theme_service_->GetGdkColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT); if (theme_service_->UsingNativeTheme()) { gtk_util::SetLabelColor(instructions_label_, NULL); gtk_chrome_link_button_set_normal_color( @@ -80,9 +81,9 @@ void BookmarkBarInstructionsGtk::UpdateColors() { // When using a non-standard, non-gtk theme, we make the link color match // the bookmark text color. Otherwise, standard link blue can look very // bad for some dark themes. - if (theme_service_->GetColor(ThemeService::COLOR_BOOKMARK_TEXT) == - ThemeService::GetDefaultColor( - ThemeService::COLOR_BOOKMARK_TEXT)) { + if (theme_service_->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT) == + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_BOOKMARK_TEXT)) { gtk_chrome_link_button_set_normal_color( GTK_CHROME_LINK_BUTTON(instructions_link_), NULL); } else { diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc index ebb3159..3796706 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc @@ -12,6 +12,7 @@ #include "chrome/browser/bookmarks/bookmark_node_data.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" #include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" @@ -195,7 +196,7 @@ GtkWidget* GetDragRepresentation(GdkPixbuf* pixbuf, gtk_util::AddWindowAlphaChannel(window)) { DragRepresentationData* data = new DragRepresentationData( pixbuf, title, - provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT)); + provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); g_signal_connect(window, "expose-event", G_CALLBACK(OnDragIconExpose), data); g_object_ref(window); @@ -208,7 +209,7 @@ GtkWidget* GetDragRepresentation(GdkPixbuf* pixbuf, } else { if (!provider->UsingNativeTheme()) { GdkColor color = provider->GetGdkColor( - ThemeService::COLOR_TOOLBAR); + ThemeProperties::COLOR_TOOLBAR); gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color); } gtk_widget_realize(window); @@ -284,7 +285,7 @@ void SetButtonTextColors(GtkWidget* label, GtkThemeService* provider) { gtk_util::SetLabelColor(label, NULL); } else { GdkColor color = provider->GetGdkColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color); gtk_widget_modify_fg(label, GTK_STATE_INSENSITIVE, &color); diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc index 0c71dc0..4a07469 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.cc +++ b/chrome/browser/ui/gtk/browser_titlebar.cc @@ -24,6 +24,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/gtk/accelerators_gtk.h" @@ -549,7 +550,7 @@ void BrowserTitlebar::GetButtonResources(const std::string& button_name, void BrowserTitlebar::UpdateButtonBackground(CustomDrawButton* button) { SkColor color = theme_service_->GetColor( - ThemeService::COLOR_BUTTON_BACKGROUND); + ThemeProperties::COLOR_BUTTON_BACKGROUND); SkBitmap background = theme_service_->GetImageNamed( IDR_THEME_WINDOW_CONTROL_BACKGROUND).AsBitmap(); @@ -745,10 +746,10 @@ void BrowserTitlebar::UpdateTextColor() { GdkColor frame_color; if (window_has_focus_) { frame_color = theme_service_->GetGdkColor( - ThemeService::COLOR_FRAME); + ThemeProperties::COLOR_FRAME); } else { frame_color = theme_service_->GetGdkColor( - ThemeService::COLOR_FRAME_INACTIVE); + ThemeProperties::COLOR_FRAME_INACTIVE); } GdkColor text_color = PickLuminosityContrastingColor( &frame_color, &ui::kGdkWhite, &ui::kGdkBlack); diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc index 06d35c4..0a2d4d3 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc @@ -19,6 +19,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" @@ -513,7 +514,7 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, window_->tabstrip()->GetTabStripOriginForWidget(widget); // Fill the entire region with the toolbar color. GdkColor color = theme_service_->GetGdkColor( - ThemeService::COLOR_TOOLBAR); + ThemeProperties::COLOR_TOOLBAR); gdk_cairo_set_source_color(cr, &color); cairo_fill(cr); diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index 50f8548..8759381 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -33,7 +33,7 @@ #include "chrome/browser/prefs/pref_registry_syncable.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" #include "chrome/browser/ui/bookmarks/bookmark_utils.h" @@ -1721,15 +1721,15 @@ void BrowserWindowGtk::SetBackgroundColor() { GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile); int frame_color_id; if (UsingCustomPopupFrame()) { - frame_color_id = ThemeService::COLOR_TOOLBAR; + frame_color_id = ThemeProperties::COLOR_TOOLBAR; } else if (DrawFrameAsActive()) { frame_color_id = browser()->profile()->IsOffTheRecord() - ? ThemeService::COLOR_FRAME_INCOGNITO - : ThemeService::COLOR_FRAME; + ? ThemeProperties::COLOR_FRAME_INCOGNITO + : ThemeProperties::COLOR_FRAME; } else { frame_color_id = browser()->profile()->IsOffTheRecord() - ? ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE - : ThemeService::COLOR_FRAME_INACTIVE; + ? ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE + : ThemeProperties::COLOR_FRAME_INACTIVE; } SkColor frame_color = theme_provider->GetColor(frame_color_id); diff --git a/chrome/browser/ui/gtk/download/download_item_gtk.cc b/chrome/browser/ui/gtk/download/download_item_gtk.cc index 1b1b2c2..888dcd4 100644 --- a/chrome/browser/ui/gtk/download/download_item_gtk.cc +++ b/chrome/browser/ui/gtk/download/download_item_gtk.cc @@ -15,6 +15,7 @@ #include "chrome/browser/download/chrome_download_manager_delegate.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_util.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/gtk/custom_drag.h" #include "chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h" @@ -512,7 +513,7 @@ void DownloadItemGtk::UpdateNameLabel() { } GdkColor color = theme_service_->GetGdkColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT); gtk_util::SetLabelColor( name_label_, theme_service_->UsingNativeTheme() ? NULL : &color); @@ -552,7 +553,7 @@ void DownloadItemGtk::UpdateStatusLabel(const std::string& status_text) { GdkColor text_color; if (!theme_service_->UsingNativeTheme()) { SkColor color = theme_service_->GetColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT); if (color_utils::RelativeLuminance(color) > 0.5) { color = SkColorSetRGB( static_cast<int>(kDownloadItemLuminanceMod * @@ -588,7 +589,7 @@ void DownloadItemGtk::UpdateDangerWarning() { gtk_util::SetLabelColor(dangerous_label_, NULL); } else { GdkColor color = theme_service_->GetGdkColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT); gtk_util::SetLabelColor(dangerous_label_, &color); } diff --git a/chrome/browser/ui/gtk/download/download_shelf_gtk.cc b/chrome/browser/ui/gtk/download/download_shelf_gtk.cc index d26688a..d5a2aa5 100644 --- a/chrome/browser/ui/gtk/download/download_shelf_gtk.cc +++ b/chrome/browser/ui/gtk/download/download_shelf_gtk.cc @@ -9,6 +9,7 @@ #include "base/bind.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_util.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" @@ -245,7 +246,7 @@ void DownloadShelfGtk::Observe(int type, const content::NotificationDetails& details) { if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { GdkColor color = theme_service_->GetGdkColor( - ThemeService::COLOR_TOOLBAR); + ThemeProperties::COLOR_TOOLBAR); gtk_widget_modify_bg(padding_bg_, GTK_STATE_NORMAL, &color); color = theme_service_->GetBorderColor(); @@ -255,18 +256,18 @@ void DownloadShelfGtk::Observe(int type, // the bookmark text color. Otherwise, standard link blue can look very // bad for some dark themes. bool use_default_color = theme_service_->GetColor( - ThemeService::COLOR_BOOKMARK_TEXT) == - ThemeService::GetDefaultColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT) == + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_BOOKMARK_TEXT); GdkColor bookmark_color = theme_service_->GetGdkColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT); gtk_chrome_link_button_set_normal_color( GTK_CHROME_LINK_BUTTON(link_button_), use_default_color ? NULL : &bookmark_color); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetBackground( - theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), + theme_service_->GetColor(ThemeProperties::COLOR_TAB_TEXT), rb.GetImageNamed(IDR_CLOSE_BAR).AsBitmap(), rb.GetImageNamed(IDR_CLOSE_BAR_MASK).AsBitmap()); } diff --git a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc index 754be61..582ede6 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.cc +++ b/chrome/browser/ui/gtk/find_bar_gtk.cc @@ -16,6 +16,7 @@ #include "base/strings/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_bar_state.h" @@ -546,7 +547,7 @@ void FindBarGtk::Observe(int type, // This is necessary to make the close button dark enough. ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetBackground( - theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), + theme_service_->GetColor(ThemeProperties::COLOR_TAB_TEXT), rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap(), rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap()); } diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc index aeb6ec0..e752330 100644 --- a/chrome/browser/ui/gtk/gtk_theme_service.cc +++ b/chrome/browser/ui/gtk/gtk_theme_service.cc @@ -16,6 +16,7 @@ #include "base/prefs/pref_service.h" #include "base/stl_util.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_iterator.h" @@ -40,6 +41,7 @@ #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_signal_registrar.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/gtk_util.h" @@ -123,7 +125,8 @@ bool IsOverridableImage(int id) { images.insert(kAutocompleteImages, kAutocompleteImages + arraysize(kAutocompleteImages)); - const std::set<int>& buttons = ThemeService::GetTintableToolbarButtons(); + const std::set<int>& buttons = + ThemeProperties::GetTintableToolbarButtons(); images.insert(buttons.begin(), buttons.end()); } @@ -431,8 +434,8 @@ GdkColor GtkThemeService::GetBorderColor() const { text = style->text[GTK_STATE_NORMAL]; bg = style->bg[GTK_STATE_NORMAL]; } else { - text = GetGdkColor(COLOR_BOOKMARK_TEXT); - bg = GetGdkColor(COLOR_TOOLBAR); + text = GetGdkColor(ThemeProperties::COLOR_BOOKMARK_TEXT); + bg = GetGdkColor(ThemeProperties::COLOR_TOOLBAR); } // Creates a weighted average between the text and base color where @@ -702,19 +705,19 @@ void GtkThemeService::LoadGtkValues() { GtkStyle* frame_style = gtk_rc_get_style(fake_frame_); GtkStyle* window_style = gtk_rc_get_style(fake_window_); - SetThemeColorFromGtk(ThemeService::COLOR_CONTROL_BACKGROUND, + SetThemeColorFromGtk(ThemeProperties::COLOR_CONTROL_BACKGROUND, &window_style->bg[GTK_STATE_NORMAL]); GdkColor toolbar_color = window_style->bg[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(ThemeService::COLOR_TOOLBAR, &toolbar_color); + SetThemeColorFromGtk(ThemeProperties::COLOR_TOOLBAR, &toolbar_color); GdkColor button_color = window_style->bg[GTK_STATE_SELECTED]; - SetThemeTintFromGtk(ThemeService::TINT_BUTTONS, &button_color); + SetThemeTintFromGtk(ThemeProperties::TINT_BUTTONS, &button_color); GtkStyle* label_style = gtk_rc_get_style(fake_label_.get()); GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(ThemeService::COLOR_TAB_TEXT, &label_color); - SetThemeColorFromGtk(ThemeService::COLOR_BOOKMARK_TEXT, &label_color); + SetThemeColorFromGtk(ThemeProperties::COLOR_TAB_TEXT, &label_color); + SetThemeColorFromGtk(ThemeProperties::COLOR_BOOKMARK_TEXT, &label_color); // Build the various icon tints. GetNormalButtonTintHSL(&button_tint_); @@ -727,7 +730,8 @@ void GtkThemeService::LoadGtkValues() { // background tab color, with the lightness and saturation moved in the // opposite direction. (We don't touch the hue, since there should be subtle // hints of the color in the text.) - color_utils::HSL inactive_tab_text_hsl = tints_[TINT_BACKGROUND_TAB]; + color_utils::HSL inactive_tab_text_hsl = + tints_[ThemeProperties::TINT_BACKGROUND_TAB]; if (inactive_tab_text_hsl.l < 0.5) inactive_tab_text_hsl.l = kDarkInactiveLuminance; else @@ -738,7 +742,7 @@ void GtkThemeService::LoadGtkValues() { else inactive_tab_text_hsl.s = kLightInactiveSaturation; - colors_[ThemeService::COLOR_BACKGROUND_TAB_TEXT] = + colors_[ThemeProperties::COLOR_BACKGROUND_TAB_TEXT] = color_utils::HSLToSkColor(inactive_tab_text_hsl, 255); // We pick the text and background colors for the NTP out of the colors for a @@ -749,9 +753,9 @@ void GtkThemeService::LoadGtkValues() { GtkStyle* entry_style = gtk_rc_get_style(fake_entry_.get()); GdkColor ntp_background = entry_style->base[GTK_STATE_NORMAL]; GdkColor ntp_foreground = entry_style->text[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(ThemeService::COLOR_NTP_BACKGROUND, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_BACKGROUND, &ntp_background); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_TEXT, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_TEXT, &ntp_foreground); // The NTP header is the color that surrounds the current active thumbnail on @@ -759,11 +763,11 @@ void GtkThemeService::LoadGtkValues() { // awesome if they were separated so we could use GetBorderColor() for the // border around the "Recent Links" section, but matching the frame color is // more important. - SetThemeColorFromGtk(ThemeService::COLOR_NTP_HEADER, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_HEADER, &frame_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_SECTION, &toolbar_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_TEXT, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_SECTION_TEXT, &label_color); // Override the link color if the theme provides it. @@ -777,13 +781,13 @@ void GtkThemeService::LoadGtkValues() { is_default_link_color = true; } - SetThemeColorFromGtk(ThemeService::COLOR_NTP_LINK, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_LINK, link_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_LINK_UNDERLINE, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_LINK_UNDERLINE, link_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_LINK, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_SECTION_LINK, link_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE, link_color); if (!is_default_link_color) @@ -832,36 +836,38 @@ GdkColor GtkThemeService::BuildFrameColors(GtkStyle* frame_style) { &frame_style->bg[GTK_STATE_SELECTED], theme_frame, kDefaultFrameShift, - ThemeService::COLOR_FRAME, - ThemeService::TINT_FRAME); + ThemeProperties::COLOR_FRAME, + ThemeProperties::TINT_FRAME); if (theme_frame) gdk_color_free(theme_frame); - SetThemeTintFromGtk(ThemeService::TINT_BACKGROUND_TAB, &frame_color); + SetThemeTintFromGtk(ThemeProperties::TINT_BACKGROUND_TAB, &frame_color); BuildAndSetFrameColor( &frame_style->bg[GTK_STATE_INSENSITIVE], theme_inactive_frame, kDefaultFrameShift, - ThemeService::COLOR_FRAME_INACTIVE, - ThemeService::TINT_FRAME_INACTIVE); + ThemeProperties::COLOR_FRAME_INACTIVE, + ThemeProperties::TINT_FRAME_INACTIVE); if (theme_inactive_frame) gdk_color_free(theme_inactive_frame); BuildAndSetFrameColor( &frame_color, theme_incognito_frame, - GetDefaultTint(ThemeService::TINT_FRAME_INCOGNITO), - ThemeService::COLOR_FRAME_INCOGNITO, - ThemeService::TINT_FRAME_INCOGNITO); + ThemeProperties::GetDefaultTint( + ThemeProperties::TINT_FRAME_INCOGNITO), + ThemeProperties::COLOR_FRAME_INCOGNITO, + ThemeProperties::TINT_FRAME_INCOGNITO); if (theme_incognito_frame) gdk_color_free(theme_incognito_frame); BuildAndSetFrameColor( &frame_color, theme_incognito_inactive_frame, - GetDefaultTint(ThemeService::TINT_FRAME_INCOGNITO_INACTIVE), - ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE, - ThemeService::TINT_FRAME_INCOGNITO_INACTIVE); + ThemeProperties::GetDefaultTint( + ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE), + ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE, + ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE); if (theme_incognito_inactive_frame) gdk_color_free(theme_incognito_inactive_frame); @@ -901,7 +907,7 @@ void GtkThemeService::SetThemeColorFromGtk(int id, const GdkColor* color) { } void GtkThemeService::SetThemeTintFromGtk(int id, const GdkColor* color) { - color_utils::HSL default_tint = GetDefaultTint(id); + color_utils::HSL default_tint = ThemeProperties::GetDefaultTint(id); color_utils::HSL hsl; color_utils::SkColorToHSL(gfx::GdkColorToSkColor(*color), &hsl); @@ -958,17 +964,17 @@ SkBitmap GtkThemeService::GenerateGtkThemeBitmap(int id) const { case IDR_THEME_TAB_BACKGROUND_INCOGNITO: return GenerateTabImage(IDR_THEME_FRAME_INCOGNITO); case IDR_THEME_FRAME: - return GenerateFrameImage(ThemeService::COLOR_FRAME, + return GenerateFrameImage(ThemeProperties::COLOR_FRAME, "frame-gradient-color"); case IDR_THEME_FRAME_INACTIVE: - return GenerateFrameImage(ThemeService::COLOR_FRAME_INACTIVE, + return GenerateFrameImage(ThemeProperties::COLOR_FRAME_INACTIVE, "inactive-frame-gradient-color"); case IDR_THEME_FRAME_INCOGNITO: - return GenerateFrameImage(ThemeService::COLOR_FRAME_INCOGNITO, + return GenerateFrameImage(ThemeProperties::COLOR_FRAME_INCOGNITO, "incognito-frame-gradient-color"); case IDR_THEME_FRAME_INCOGNITO_INACTIVE: { return GenerateFrameImage( - ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE, + ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE, "incognito-inactive-frame-gradient-color"); } // Icons that sit inside the omnibox shouldn't receive TINT_BUTTONS and @@ -1045,7 +1051,7 @@ SkBitmap GtkThemeService::GenerateFrameImage( SkBitmap GtkThemeService::GenerateTabImage(int base_id) const { SkBitmap base_image = GetImageNamed(base_id).AsBitmap(); SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( - base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB)); + base_image, GetTint(ThemeProperties::TINT_BACKGROUND_TAB)); return SkBitmapOperations::CreateTiledBitmap( bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); } @@ -1122,7 +1128,7 @@ gboolean GtkThemeService::OnSeparatorExpose(GtkWidget* widget, gdk_cairo_rectangle(cr, &event->area); cairo_clip(cr); - GdkColor bottom_color = GetGdkColor(ThemeService::COLOR_TOOLBAR); + GdkColor bottom_color = GetGdkColor(ThemeProperties::COLOR_TOOLBAR); double bottom_color_rgb[] = { static_cast<double>(bottom_color.red / 257) / 255.0, static_cast<double>(bottom_color.green / 257) / 255.0, diff --git a/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc b/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc index 05ae685..8bc1ea4 100644 --- a/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc +++ b/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc @@ -6,6 +6,7 @@ #include "base/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" @@ -36,9 +37,9 @@ TEST_F(GtkThemeServiceTest, DefaultValues) { BuildProvider(); // Test that we get the default theme colors back when in normal mode. - for (int i = ThemeService::COLOR_FRAME; - i <= ThemeService::COLOR_BUTTON_BACKGROUND; ++i) { - EXPECT_EQ(provider_->GetColor(i), ThemeService::GetDefaultColor(i)) + for (int i = ThemeProperties::COLOR_FRAME; + i <= ThemeProperties::COLOR_BUTTON_BACKGROUND; ++i) { + EXPECT_EQ(provider_->GetColor(i), ThemeProperties::GetDefaultColor(i)) << "Wrong default color for " << i; } } @@ -55,6 +56,6 @@ TEST_F(GtkThemeServiceTest, UsingGtkValues) { GtkWidget* fake_label = provider_->fake_label(); GtkStyle* label_style = gtk_rc_get_style(fake_label); GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; - EXPECT_EQ(provider_->GetColor(ThemeService::COLOR_TAB_TEXT), + EXPECT_EQ(provider_->GetColor(ThemeProperties::COLOR_TAB_TEXT), gfx::GdkColorToSkColor(label_color)); } diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc index b2ad168..d60aacb 100644 --- a/chrome/browser/ui/gtk/gtk_util.cc +++ b/chrome/browser/ui/gtk/gtk_util.cc @@ -23,6 +23,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_iterator.h" #include "chrome/browser/ui/browser_list_impl.h" @@ -725,7 +726,7 @@ void DrawThemedToolbarBackground(GtkWidget* widget, GtkThemeService* theme_service) { // Fill the entire region with the toolbar color. GdkColor color = theme_service->GetGdkColor( - ThemeService::COLOR_TOOLBAR); + ThemeProperties::COLOR_TOOLBAR); gdk_cairo_set_source_color(cr, &color); cairo_fill(cr); diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc index a45920f..3ea2f2a 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc @@ -8,6 +8,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" @@ -200,7 +201,7 @@ void InfoBarGtk::ShowMenuWithModel(GtkWidget* sender, void InfoBarGtk::GetTopColor(InfoBarDelegate::Type type, double* r, double* g, double* b) { SkColor color = theme_service_->UsingNativeTheme() ? - theme_service_->GetColor(ThemeService::COLOR_TOOLBAR) : + theme_service_->GetColor(ThemeProperties::COLOR_TOOLBAR) : GetInfoBarTopColor(type); *r = SkColorGetR(color) / 255.0; *g = SkColorGetG(color) / 255.0; @@ -210,7 +211,7 @@ void InfoBarGtk::GetTopColor(InfoBarDelegate::Type type, void InfoBarGtk::GetBottomColor(InfoBarDelegate::Type type, double* r, double* g, double* b) { SkColor color = theme_service_->UsingNativeTheme() ? - theme_service_->GetColor(ThemeService::COLOR_TOOLBAR) : + theme_service_->GetColor(ThemeProperties::COLOR_TOOLBAR) : GetInfoBarBottomColor(type); *r = SkColorGetR(color) / 255.0; *g = SkColorGetG(color) / 255.0; diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc index ae3f620..08661fe 100644 --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc @@ -37,6 +37,7 @@ #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_command_controller.h" #include "chrome/browser/ui/browser_commands.h" @@ -1047,7 +1048,7 @@ void LocationBarViewGtk::Observe(int type, gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, NULL); GdkColor border_color = theme_service_->GetGdkColor( - ThemeService::COLOR_FRAME); + ThemeProperties::COLOR_FRAME); gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_, border_color); gtk_util::UndoForceFontSize(security_info_label_); diff --git a/chrome/browser/ui/gtk/panels/panel_titlebar_gtk.cc b/chrome/browser/ui/gtk/panels/panel_titlebar_gtk.cc index dad8056..3b72404 100644 --- a/chrome/browser/ui/gtk/panels/panel_titlebar_gtk.cc +++ b/chrome/browser/ui/gtk/panels/panel_titlebar_gtk.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/gtk/panels/panel_titlebar_gtk.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/gtk/custom_button.h" #include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" @@ -110,8 +111,8 @@ SkColor PanelTitlebarGtk::GetTextColor() const { return kTitleTextDefaultColor; return theme_service_->GetColor(panel_gtk_->paint_state() == PanelGtk::PAINT_AS_ACTIVE ? - ThemeService::COLOR_TAB_TEXT : - ThemeService::COLOR_BACKGROUND_TAB_TEXT); + ThemeProperties::COLOR_TAB_TEXT : + ThemeProperties::COLOR_BACKGROUND_TAB_TEXT); } void PanelTitlebarGtk::BuildButtons() { diff --git a/chrome/browser/ui/gtk/status_bubble_gtk.cc b/chrome/browser/ui/gtk/status_bubble_gtk.cc index 6bd1d43..782b587 100644 --- a/chrome/browser/ui/gtk/status_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/status_bubble_gtk.cc @@ -11,6 +11,7 @@ #include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/rounded_window.h" @@ -297,11 +298,11 @@ void StatusBubbleGtk::UserChangedTheme() { // toolbar" that I can find. Maybe in later iterations of the theme system, // there will be a better color to pick. GdkColor bookmark_text = - theme_service_->GetGdkColor(ThemeService::COLOR_BOOKMARK_TEXT); + theme_service_->GetGdkColor(ThemeProperties::COLOR_BOOKMARK_TEXT); gtk_widget_modify_fg(label_.get(), GTK_STATE_NORMAL, &bookmark_text); GdkColor toolbar_color = - theme_service_->GetGdkColor(ThemeService::COLOR_TOOLBAR); + theme_service_->GetGdkColor(ThemeProperties::COLOR_TOOLBAR); gtk_widget_modify_bg(container_.get(), GTK_STATE_NORMAL, &toolbar_color); } diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc index f52a3f4..330fce2 100644 --- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc @@ -13,6 +13,7 @@ #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" @@ -356,9 +357,9 @@ void TabRendererGtk::Observe(int type, const content::NotificationDetails& details) { DCHECK(chrome::NOTIFICATION_BROWSER_THEME_CHANGED); selected_title_color_ = - theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); + theme_service_->GetColor(ThemeProperties::COLOR_TAB_TEXT); unselected_title_color_ = - theme_service_->GetColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT); + theme_service_->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB_TEXT); } void TabRendererGtk::UpdateData(WebContents* contents, @@ -814,7 +815,7 @@ void TabRendererGtk::Layout() { // If the close button color has changed, generate a new one. if (theme_service_) { SkColor tab_text_color = - theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); + theme_service_->GetColor(ThemeProperties::COLOR_TAB_TEXT); if (!close_button_color_ || tab_text_color != close_button_color_) { close_button_color_ = tab_text_color; ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc index 81d2394..a1cf213 100644 --- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc @@ -19,6 +19,7 @@ #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_navigator.h" @@ -2271,7 +2272,7 @@ CustomDrawButton* TabStripGtk::MakeNewTabButton() { void TabStripGtk::SetNewTabButtonBackground() { SkColor color = theme_service_->GetColor( - ThemeService::COLOR_BUTTON_BACKGROUND); + ThemeProperties::COLOR_BUTTON_BACKGROUND); SkBitmap background = theme_service_->GetImageNamed( IDR_THEME_WINDOW_CONTROL_BACKGROUND).AsBitmap(); SkBitmap mask = theme_service_->GetImageNamed( diff --git a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc index b91aafe..55bbf80 100644 --- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc +++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc @@ -11,7 +11,7 @@ #include "base/logging.h" #include "base/nix/mime_util_xdg.h" #include "base/stl_util.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h" #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" @@ -250,17 +250,17 @@ void GdkColorHSLShift(const color_utils::HSL& shift, GdkColor* frame_color) { // Copied Default blah sections from ThemeService. color_utils::HSL GetDefaultTint(int id) { switch (id) { - case ThemeService::TINT_FRAME: + case ThemeProperties::TINT_FRAME: return kDefaultTintFrame; - case ThemeService::TINT_FRAME_INACTIVE: + case ThemeProperties::TINT_FRAME_INACTIVE: return kDefaultTintFrameInactive; - case ThemeService::TINT_FRAME_INCOGNITO: + case ThemeProperties::TINT_FRAME_INCOGNITO: return kDefaultTintFrameIncognito; - case ThemeService::TINT_FRAME_INCOGNITO_INACTIVE: + case ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE: return kDefaultTintFrameIncognitoInactive; - case ThemeService::TINT_BUTTONS: + case ThemeProperties::TINT_BUTTONS: return kDefaultTintButtons; - case ThemeService::TINT_BACKGROUND_TAB: + case ThemeProperties::TINT_BACKGROUND_TAB: return kDefaultTintBackgroundTab; default: color_utils::HSL result = {-1, -1, -1}; @@ -458,19 +458,19 @@ void Gtk2UI::LoadGtkValues() { GtkStyle* frame_style = gtk_rc_get_style(fake_frame_); GtkStyle* window_style = gtk_rc_get_style(fake_window_); - SetThemeColorFromGtk(ThemeService::COLOR_CONTROL_BACKGROUND, + SetThemeColorFromGtk(ThemeProperties::COLOR_CONTROL_BACKGROUND, &window_style->bg[GTK_STATE_NORMAL]); GdkColor toolbar_color = window_style->bg[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(ThemeService::COLOR_TOOLBAR, &toolbar_color); + SetThemeColorFromGtk(ThemeProperties::COLOR_TOOLBAR, &toolbar_color); GdkColor button_color = window_style->bg[GTK_STATE_SELECTED]; - SetThemeTintFromGtk(ThemeService::TINT_BUTTONS, &button_color); + SetThemeTintFromGtk(ThemeProperties::TINT_BUTTONS, &button_color); GtkStyle* label_style = gtk_rc_get_style(fake_label_.get()); GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(ThemeService::COLOR_TAB_TEXT, &label_color); - SetThemeColorFromGtk(ThemeService::COLOR_BOOKMARK_TEXT, &label_color); + SetThemeColorFromGtk(ThemeProperties::COLOR_TAB_TEXT, &label_color); + SetThemeColorFromGtk(ThemeProperties::COLOR_BOOKMARK_TEXT, &label_color); // Build the various icon tints. GetNormalButtonTintHSL(&button_tint_); @@ -484,7 +484,7 @@ void Gtk2UI::LoadGtkValues() { // opposite direction. (We don't touch the hue, since there should be subtle // hints of the color in the text.) color_utils::HSL inactive_tab_text_hsl = - tints_[ThemeService::TINT_BACKGROUND_TAB]; + tints_[ThemeProperties::TINT_BACKGROUND_TAB]; if (inactive_tab_text_hsl.l < 0.5) inactive_tab_text_hsl.l = kDarkInactiveLuminance; else @@ -495,7 +495,7 @@ void Gtk2UI::LoadGtkValues() { else inactive_tab_text_hsl.s = kLightInactiveSaturation; - colors_[ThemeService::COLOR_BACKGROUND_TAB_TEXT] = + colors_[ThemeProperties::COLOR_BACKGROUND_TAB_TEXT] = color_utils::HSLToSkColor(inactive_tab_text_hsl, 255); // We pick the text and background colors for the NTP out of the colors for a @@ -506,9 +506,9 @@ void Gtk2UI::LoadGtkValues() { GtkStyle* entry_style = gtk_rc_get_style(fake_entry_.get()); GdkColor ntp_background = entry_style->base[GTK_STATE_NORMAL]; GdkColor ntp_foreground = entry_style->text[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(ThemeService::COLOR_NTP_BACKGROUND, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_BACKGROUND, &ntp_background); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_TEXT, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_TEXT, &ntp_foreground); // The NTP header is the color that surrounds the current active thumbnail on @@ -516,11 +516,11 @@ void Gtk2UI::LoadGtkValues() { // awesome if they were separated so we could use GetBorderColor() for the // border around the "Recent Links" section, but matching the frame color is // more important. - SetThemeColorFromGtk(ThemeService::COLOR_NTP_HEADER, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_HEADER, &frame_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_SECTION, &toolbar_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_TEXT, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_SECTION_TEXT, &label_color); // Override the link color if the theme provides it. @@ -534,13 +534,13 @@ void Gtk2UI::LoadGtkValues() { is_default_link_color = true; } - SetThemeColorFromGtk(ThemeService::COLOR_NTP_LINK, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_LINK, link_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_LINK_UNDERLINE, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_LINK_UNDERLINE, link_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_LINK, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_SECTION_LINK, link_color); - SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE, + SetThemeColorFromGtk(ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE, link_color); if (!is_default_link_color) @@ -586,36 +586,36 @@ GdkColor Gtk2UI::BuildFrameColors(GtkStyle* frame_style) { &frame_style->bg[GTK_STATE_SELECTED], theme_frame, kDefaultFrameShift, - ThemeService::COLOR_FRAME, - ThemeService::TINT_FRAME); + ThemeProperties::COLOR_FRAME, + ThemeProperties::TINT_FRAME); if (theme_frame) gdk_color_free(theme_frame); - SetThemeTintFromGtk(ThemeService::TINT_BACKGROUND_TAB, &frame_color); + SetThemeTintFromGtk(ThemeProperties::TINT_BACKGROUND_TAB, &frame_color); BuildAndSetFrameColor( &frame_style->bg[GTK_STATE_INSENSITIVE], theme_inactive_frame, kDefaultFrameShift, - ThemeService::COLOR_FRAME_INACTIVE, - ThemeService::TINT_FRAME_INACTIVE); + ThemeProperties::COLOR_FRAME_INACTIVE, + ThemeProperties::TINT_FRAME_INACTIVE); if (theme_inactive_frame) gdk_color_free(theme_inactive_frame); BuildAndSetFrameColor( &frame_color, theme_incognito_frame, - GetDefaultTint(ThemeService::TINT_FRAME_INCOGNITO), - ThemeService::COLOR_FRAME_INCOGNITO, - ThemeService::TINT_FRAME_INCOGNITO); + GetDefaultTint(ThemeProperties::TINT_FRAME_INCOGNITO), + ThemeProperties::COLOR_FRAME_INCOGNITO, + ThemeProperties::TINT_FRAME_INCOGNITO); if (theme_incognito_frame) gdk_color_free(theme_incognito_frame); BuildAndSetFrameColor( &frame_color, theme_incognito_inactive_frame, - GetDefaultTint(ThemeService::TINT_FRAME_INCOGNITO_INACTIVE), - ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE, - ThemeService::TINT_FRAME_INCOGNITO_INACTIVE); + GetDefaultTint(ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE), + ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE, + ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE); if (theme_incognito_inactive_frame) gdk_color_free(theme_incognito_inactive_frame); @@ -677,17 +677,17 @@ SkBitmap Gtk2UI::GenerateGtkThemeBitmap(int id) const { case IDR_THEME_TAB_BACKGROUND_INCOGNITO: return GenerateTabImage(IDR_THEME_FRAME_INCOGNITO); case IDR_THEME_FRAME: - return GenerateFrameImage(ThemeService::COLOR_FRAME, + return GenerateFrameImage(ThemeProperties::COLOR_FRAME, "frame-gradient-color"); case IDR_THEME_FRAME_INACTIVE: - return GenerateFrameImage(ThemeService::COLOR_FRAME_INACTIVE, + return GenerateFrameImage(ThemeProperties::COLOR_FRAME_INACTIVE, "inactive-frame-gradient-color"); case IDR_THEME_FRAME_INCOGNITO: - return GenerateFrameImage(ThemeService::COLOR_FRAME_INCOGNITO, + return GenerateFrameImage(ThemeProperties::COLOR_FRAME_INCOGNITO, "incognito-frame-gradient-color"); case IDR_THEME_FRAME_INCOGNITO_INACTIVE: { return GenerateFrameImage( - ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE, + ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE, "incognito-inactive-frame-gradient-color"); } // Icons that sit inside the omnibox shouldn't receive TINT_BUTTONS and @@ -792,7 +792,7 @@ SkBitmap Gtk2UI::GenerateFrameImage( SkBitmap Gtk2UI::GenerateTabImage(int base_id) const { const SkBitmap* base_image = GetThemeImageNamed(base_id)->ToSkBitmap(); SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( - *base_image, GetDefaultTint(ThemeService::TINT_BACKGROUND_TAB)); + *base_image, GetDefaultTint(ThemeProperties::TINT_BACKGROUND_TAB)); return SkBitmapOperations::CreateTiledBitmap( bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); } diff --git a/chrome/browser/ui/ntp_background_util.cc b/chrome/browser/ui/ntp_background_util.cc index 4e30af4..853b23d 100644 --- a/chrome/browser/ui/ntp_background_util.cc +++ b/chrome/browser/ui/ntp_background_util.cc @@ -7,8 +7,9 @@ #include <cmath> #include "base/logging.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "grit/theme_resources.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/rect.h" @@ -24,33 +25,33 @@ void PaintThemeBackground( int width = area.width() + ntp_background->width(); int height = area.height() + ntp_background->height(); - if (alignment & ThemeService::ALIGN_BOTTOM) { + if (alignment & ThemeProperties::ALIGN_BOTTOM) { y_pos += area.height() + tab_contents_height - ntp_background->height(); - } else if (alignment & ThemeService::ALIGN_TOP) { + } else if (alignment & ThemeProperties::ALIGN_TOP) { // no op } else { // ALIGN_CENTER y_pos += std::floor(area.height() + tab_contents_height / 2.0 - ntp_background->height() / 2.0 + 0.5); } - if (alignment & ThemeService::ALIGN_RIGHT) { + if (alignment & ThemeProperties::ALIGN_RIGHT) { x_pos += area.width() - ntp_background->width(); - } else if (alignment & ThemeService::ALIGN_LEFT) { + } else if (alignment & ThemeProperties::ALIGN_LEFT) { // no op } else { // ALIGN_CENTER x_pos += std::floor(area.width() / 2.0 - ntp_background->width() / 2.0 + 0.5); } - if (tiling != ThemeService::REPEAT && - tiling != ThemeService::REPEAT_X) { + if (tiling != ThemeProperties::REPEAT && + tiling != ThemeProperties::REPEAT_X) { width = ntp_background->width(); } else if (x_pos > 0) { x_pos = x_pos % ntp_background->width() - ntp_background->width(); } - if (tiling != ThemeService::REPEAT && - tiling != ThemeService::REPEAT_Y) { + if (tiling != ThemeProperties::REPEAT && + tiling != ThemeProperties::REPEAT_Y) { height = ntp_background->height(); } else if (y_pos > 0) { y_pos = y_pos % ntp_background->height() - ntp_background->height(); @@ -70,13 +71,13 @@ void NtpBackgroundUtil::PaintBackgroundDetachedMode(ui::ThemeProvider* tp, const gfx::Rect& area, int tab_contents_height) { // Draw the background to match the new tab page. - canvas->FillRect(area, tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND)); + canvas->FillRect(area, tp->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND)); if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { - int tiling = ThemeService::NO_REPEAT; - tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, &tiling); + int tiling = ThemeProperties::NO_REPEAT; + tp->GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_TILING, &tiling); int alignment; - if (tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, + if (tp->GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &alignment)) { gfx::ImageSkia* ntp_background = tp->GetImageSkiaNamed(IDR_THEME_NTP_BACKGROUND); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc index a9570be..e06db1f 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc @@ -8,10 +8,11 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/bookmarks/bookmark_bar_instructions_delegate.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/theme_provider.h" #include "ui/views/controls/label.h" #include "ui/views/controls/link.h" @@ -112,7 +113,7 @@ void BookmarkBarInstructionsView::UpdateColors() { return; updated_colors_ = true; SkColor text_color = - theme_provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); + theme_provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); instructions_->SetEnabledColor(text_color); if (import_link_) import_link_->SetEnabledColor(text_color); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 93bf11e..ac2ed9f3 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -24,7 +24,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" #include "chrome/browser/ui/bookmarks/bookmark_utils.h" @@ -60,6 +60,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/text/text_elider.h" +#include "ui/base/theme_provider.h" #include "ui/base/window_open_disposition.h" #include "ui/gfx/canvas.h" #include "ui/views/button_drag_utils.h" @@ -341,7 +342,7 @@ class BookmarkBarView::ButtonSeparatorView : public views::View { canvas, kSeparatorStartX, height(), 1, DetachableToolbarView::kEdgeDividerColor, DetachableToolbarView::kMiddleDividerColor, - GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR)); + GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR)); } virtual gfx::Size GetPreferredSize() OVERRIDE { @@ -1237,7 +1238,7 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node, // We don't always have a theme provider (ui tests, for example). if (GetThemeProvider()) { button->SetEnabledColor(GetThemeProvider()->GetColor( - ThemeService::COLOR_BOOKMARK_TEXT)); + ThemeProperties::COLOR_BOOKMARK_TEXT)); } button->ClearMaxTextSize(); @@ -1532,7 +1533,7 @@ void BookmarkBarView::UpdateColors() { if (!theme_provider) return; SkColor text_color = - theme_provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); + theme_provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); for (int i = 0; i < GetBookmarkButtonCount(); ++i) GetBookmarkButton(i)->SetEnabledColor(text_color); other_bookmarked_button()->SetEnabledColor(text_color); diff --git a/chrome/browser/ui/views/constrained_window_views.cc b/chrome/browser/ui/views/constrained_window_views.cc index b3f6abc..671a310 100644 --- a/chrome/browser/ui/views/constrained_window_views.cc +++ b/chrome/browser/ui/views/constrained_window_views.cc @@ -11,7 +11,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/toolbar/toolbar_model.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/theme_image_mapper.h" @@ -438,8 +438,8 @@ gfx::Rect ConstrainedWindowFrameView::IconBounds() const { void ConstrainedWindowFrameView::PaintFrameBorder(gfx::Canvas* canvas) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - frame_background_->set_frame_color(ThemeService::GetDefaultColor( - ThemeService::COLOR_FRAME)); + frame_background_->set_frame_color(ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_FRAME)); chrome::HostDesktopType desktop_type = chrome::GetHostDesktopTypeForNativeView(GetWidget()->GetNativeView()); gfx::ImageSkia* theme_frame = rb.GetImageSkiaNamed( diff --git a/chrome/browser/ui/views/detachable_toolbar_view.cc b/chrome/browser/ui/views/detachable_toolbar_view.cc index 0c9afa9..05c0177 100644 --- a/chrome/browser/ui/views/detachable_toolbar_view.cc +++ b/chrome/browser/ui/views/detachable_toolbar_view.cc @@ -4,10 +4,11 @@ #include "chrome/browser/ui/views/detachable_toolbar_view.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "grit/theme_resources.h" #include "third_party/skia/include/core/SkShader.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/skia_util.h" @@ -29,7 +30,7 @@ void DetachableToolbarView::PaintBackgroundAttachedMode( chrome::HostDesktopType host_desktop_type) { ui::ThemeProvider* tp = view->GetThemeProvider(); canvas->FillRect(view->GetLocalBounds(), - tp->GetColor(ThemeService::COLOR_TOOLBAR)); + tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR), background_origin.x(), background_origin.y(), 0, 0, view->width(), view->height()); @@ -74,7 +75,8 @@ void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, int thickness = views::NonClientFrameView::kClientEdgeThickness; int y = view->IsDetached() ? 0 : (view->height() - thickness); canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), - ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); } // static @@ -85,7 +87,7 @@ void DetachableToolbarView::PaintContentAreaBackground( double roundness) { SkPaint paint; paint.setAntiAlias(true); - paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); + paint.setColor(theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR)); canvas->sk_canvas()->drawRoundRect( rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint); @@ -97,7 +99,7 @@ void DetachableToolbarView::PaintContentAreaBorder( const SkRect& rect, double roundness) { SkPaint border_paint; border_paint.setColor( - theme_provider->GetColor(ThemeService::COLOR_NTP_HEADER)); + theme_provider->GetColor(ThemeProperties::COLOR_NTP_HEADER)); border_paint.setStyle(SkPaint::kStroke_Style); border_paint.setAlpha(96); border_paint.setAntiAlias(true); diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc index a99c7cb..accf174 100644 --- a/chrome/browser/ui/views/download/download_item_view.cc +++ b/chrome/browser/ui/views/download/download_item_view.cc @@ -21,7 +21,7 @@ #include "chrome/browser/download/chrome_download_manager_delegate.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_util.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" #include "chrome/browser/ui/views/download/download_shelf_view.h" #include "content/public/browser/download_danger_type.h" @@ -34,6 +34,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/text/text_elider.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/image/image.h" @@ -638,7 +639,7 @@ void DownloadItemView::OnPaint(gfx::Canvas* canvas) { int y = box_y_ + kVerticalPadding + font_.GetHeight() + kVerticalTextPadding; SkColor file_name_color = GetThemeProvider()->GetColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT); // If text is light-on-dark, lightening it alone will do nothing. // Therefore we mute luminance a wee bit before drawing in this case. if (color_utils::RelativeLuminance(file_name_color) > 0.5) @@ -760,7 +761,7 @@ void DownloadItemView::OnPaint(gfx::Canvas* canvas) { int mirrored_x = GetMirroredXWithWidthInView( download_util::kSmallProgressIconSize, kTextWidth); SkColor file_name_color = GetThemeProvider()->GetColor( - ThemeService::COLOR_BOOKMARK_TEXT); + ThemeProperties::COLOR_BOOKMARK_TEXT); int y = box_y_ + (status_text_.empty() ? ((box_height_ - font_.GetHeight()) / 2) : kVerticalPadding); @@ -862,7 +863,7 @@ void DownloadItemView::LoadIconIfItemPathChanged() { void DownloadItemView::UpdateColorsFromTheme() { if (dangerous_download_label_ && GetThemeProvider()) { dangerous_download_label_->SetEnabledColor( - GetThemeProvider()->GetColor(ThemeService::COLOR_BOOKMARK_TEXT)); + GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); } } diff --git a/chrome/browser/ui/views/download/download_shelf_view.cc b/chrome/browser/ui/views/download/download_shelf_view.cc index de06723..a4912af 100644 --- a/chrome/browser/ui/views/download/download_shelf_view.cc +++ b/chrome/browser/ui/views/download/download_shelf_view.cc @@ -11,7 +11,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_util.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/view_ids.h" @@ -26,6 +26,7 @@ #include "ui/base/animation/slide_animation.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/views/background.h" #include "ui/views/controls/button/image_button.h" @@ -363,12 +364,12 @@ void DownloadShelfView::UpdateColorsFromTheme() { if (show_all_view_ && close_button_ && GetThemeProvider()) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); set_background(views::Background::CreateSolidBackground( - GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR))); + GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR))); show_all_view_->SetBackgroundColor(background()->get_color()); show_all_view_->SetEnabledColor( - GetThemeProvider()->GetColor(ThemeService::COLOR_BOOKMARK_TEXT)); + GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); close_button_->SetBackground( - GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), + GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), rb.GetImageSkiaNamed(IDR_CLOSE_BAR), rb.GetImageSkiaNamed(IDR_CLOSE_BAR_MASK)); } diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc index 007168b..6bb6ece 100644 --- a/chrome/browser/ui/views/external_tab_container_win.cc +++ b/chrome/browser/ui/views/external_tab_container_win.cc @@ -28,7 +28,7 @@ #include "chrome/browser/pepper_broker_infobar_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/repost_form_warning_controller.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" #include "chrome/browser/ui/browser.h" @@ -1034,7 +1034,8 @@ bool ExternalTabContainerWin::InitNavigationInfo( } SkColor ExternalTabContainerWin::GetInfoBarSeparatorColor() const { - return ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR); + return ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_TOOLBAR_SEPARATOR); } void ExternalTabContainerWin::InfoBarContainerStateChanged(bool is_animating) { diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc index 9074963..10e9d03 100644 --- a/chrome/browser/ui/views/find_bar_view.cc +++ b/chrome/browser/ui/views/find_bar_view.cc @@ -10,7 +10,7 @@ #include "base/strings/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_bar_state.h" #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" @@ -26,6 +26,7 @@ #include "ui/base/events/event.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/label.h" @@ -502,7 +503,7 @@ void FindBarView::OnThemeChanged() { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); if (GetThemeProvider()) { close_button_->SetBackground( - GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), + GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), rb.GetImageSkiaNamed(IDR_TAB_CLOSE), rb.GetImageSkiaNamed(IDR_TAB_CLOSE_MASK)); } diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc index 2b330d8..11639c4 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc @@ -8,7 +8,7 @@ #include "ash/wm/frame_painter.h" #include "ash/wm/workspace/frame_maximize_button.h" #include "base/command_line.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/avatar_menu_button.h" #include "chrome/browser/ui/views/frame/browser_frame.h" @@ -440,7 +440,7 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { int bottom_edge_height = h - split_point; canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), - tp->GetColor(ThemeService::COLOR_TOOLBAR)); + tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); // Paint the main toolbar image. Since this image is also used to draw the // tab background, we must use the tab strip offset to compute the image @@ -485,13 +485,15 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { toolbar_bounds.bottom() - kClientEdgeThickness, w - (2 * kClientEdgeThickness), kClientEdgeThickness), - ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); } void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(), width(), kClientEdgeThickness), - ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); } int BrowserNonClientFrameViewAsh::GetThemeFrameImageId() const { diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 737268a..678671a 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -30,7 +30,7 @@ #include "chrome/browser/sessions/tab_restore_service.h" #include "chrome/browser/sessions/tab_restore_service_factory.h" #include "chrome/browser/speech/tts_controller.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" #include "chrome/browser/ui/bookmarks/bookmark_utils.h" @@ -105,6 +105,7 @@ #include "ui/base/hit_test.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/sys_color_change_listener.h" @@ -1862,7 +1863,8 @@ void BrowserView::GetAccessiblePanes( SkColor BrowserView::GetInfoBarSeparatorColor() const { // NOTE: Keep this in sync with ToolbarView::OnPaint()! return (IsTabStripVisible() || !frame_->ShouldUseNativeFrame()) ? - ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR) : + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_TOOLBAR_SEPARATOR) : SK_ColorBLACK; } @@ -1960,7 +1962,7 @@ void BrowserView::Init() { new InstantPreviewControllerViews(browser(), contents_)); SkColor bg_color = GetWidget()->GetThemeProvider()-> - GetColor(ThemeService::COLOR_TOOLBAR); + GetColor(ThemeProperties::COLOR_TOOLBAR); devtools_container_ = new views::WebView(browser_->profile()); devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc index bda5866..e6f2982 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc @@ -10,7 +10,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/views/avatar_menu_button.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/hwnd_util.h" @@ -340,7 +340,8 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { toolbar_bounds.bottom() - kClientEdgeThickness, w - (2 * kClientEdgeThickness), kClientEdgeThickness), - ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); } void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { @@ -379,7 +380,7 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { // where not covered by the toolbar image. NOTE: We do this after drawing the // images because the images are meant to alpha-blend atop the frame whereas // these rects are meant to be fully opaque, without anything overlaid. - SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); + SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, client_area_top, kClientEdgeThickness, client_area_bottom + kClientEdgeThickness - client_area_top), diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index 55df8ed..6638a88 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -11,7 +11,7 @@ #include "base/compiler_specific.h" #include "base/prefs/pref_service.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/views/avatar_menu_button.h" #include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_view.h" @@ -527,7 +527,7 @@ views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( tp->GetImageSkiaNamed(pushed_image_id)); if (browser_view()->IsBrowserTypeNormal()) { button->SetBackground( - tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND), + tp->GetColor(ThemeProperties::COLOR_BUTTON_BACKGROUND), tp->GetImageSkiaNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND), tp->GetImageSkiaNamed(mask_image_id)); } @@ -714,7 +714,7 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { // Paint the bottom rect. canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), - tp->GetColor(ThemeService::COLOR_TOOLBAR)); + tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); // Tile the toolbar image starting at the frame edge on the left and where the // horizontal tabstrip is (or would be) on the top. @@ -786,7 +786,8 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { toolbar_bounds.bottom() - kClientEdgeThickness, w - (2 * kClientEdgeThickness), kClientEdgeThickness), - ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); + ThemeProperties::GetDefaultColor( + ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); } void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { @@ -795,7 +796,7 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { int image_top = client_area_top; gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); - SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); + SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); if (browser_view()->IsToolbarVisible()) { // The client edge images always start below the toolbar corner images. The @@ -877,20 +878,21 @@ SkColor OpaqueBrowserFrameView::GetFrameColor() const { if (browser_view()->IsBrowserTypeNormal()) { if (ShouldPaintAsActive()) { return GetThemeProvider()->GetColor(is_incognito ? - ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME); + ThemeProperties::COLOR_FRAME_INCOGNITO : + ThemeProperties::COLOR_FRAME); } return GetThemeProvider()->GetColor(is_incognito ? - ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE : - ThemeService::COLOR_FRAME_INACTIVE); + ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE : + ThemeProperties::COLOR_FRAME_INACTIVE); } // Never theme app and popup windows. if (ShouldPaintAsActive()) { - return ThemeService::GetDefaultColor(is_incognito ? - ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME); + return ThemeProperties::GetDefaultColor(is_incognito ? + ThemeProperties::COLOR_FRAME_INCOGNITO : ThemeProperties::COLOR_FRAME); } - return ThemeService::GetDefaultColor(is_incognito ? - ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE : - ThemeService::COLOR_FRAME_INACTIVE); + return ThemeProperties::GetDefaultColor(is_incognito ? + ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE : + ThemeProperties::COLOR_FRAME_INACTIVE); } gfx::ImageSkia* OpaqueBrowserFrameView::GetFrameImage() const { diff --git a/chrome/browser/ui/views/panels/panel_frame_view.cc b/chrome/browser/ui/views/panels/panel_frame_view.cc index e0f32b2..02a6dfa 100644 --- a/chrome/browser/ui/views/panels/panel_frame_view.cc +++ b/chrome/browser/ui/views/panels/panel_frame_view.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/views/panels/panel_frame_view.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/panels/panel.h" @@ -686,7 +687,8 @@ SkColor PanelFrameView::GetDefaultTitleColor( SkColor PanelFrameView::GetThemedTitleColor( PaintState paint_state) const { return GetThemeProvider()->GetColor(paint_state == PAINT_AS_ACTIVE ? - ThemeService::COLOR_TAB_TEXT : ThemeService::COLOR_BACKGROUND_TAB_TEXT); + ThemeProperties::COLOR_TAB_TEXT : + ThemeProperties::COLOR_BACKGROUND_TAB_TEXT); } const gfx::ImageSkia* PanelFrameView::GetFrameBackground( diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc index e57f686..2bcb976 100644 --- a/chrome/browser/ui/views/status_bubble_views.cc +++ b/chrome/browser/ui/views/status_bubble_views.cc @@ -11,7 +11,7 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -23,6 +23,7 @@ #include "ui/base/animation/linear_animation.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/text/text_elider.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/point.h" #include "ui/gfx/screen.h" @@ -347,7 +348,8 @@ void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) { SkPaint paint; paint.setStyle(SkPaint::kFill_Style); paint.setAntiAlias(true); - SkColor toolbar_color = theme_service_->GetColor(ThemeService::COLOR_TOOLBAR); + SkColor toolbar_color = theme_service_->GetColor( + ThemeProperties::COLOR_TOOLBAR); paint.setColor(toolbar_color); gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); @@ -442,7 +444,7 @@ void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) { std::max(0, text_height)); body_bounds.set_x(GetMirroredXForRect(body_bounds)); SkColor text_color = - theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); + theme_service_->GetColor(ThemeProperties::COLOR_TAB_TEXT); // DrawStringInt doesn't handle alpha, so we'll do the blending ourselves. text_color = SkColorSetARGB( diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index d3c7995..dcfeef1 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -10,7 +10,7 @@ #include "base/debug/alias.h" #include "base/utf_string_conversions.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tab_contents/core_tab_helper.h" #include "chrome/browser/ui/tabs/tab_resources.h" @@ -1068,8 +1068,8 @@ void Tab::PaintTab(gfx::Canvas* canvas) { SkColor title_color = GetThemeProvider()-> GetColor(IsSelected() ? - ThemeService::COLOR_TAB_TEXT : - ThemeService::COLOR_BACKGROUND_TAB_TEXT); + ThemeProperties::COLOR_TAB_TEXT : + ThemeProperties::COLOR_BACKGROUND_TAB_TEXT); if (!data().mini || width() > kMiniTabRendererAsNormalTabWidth) PaintTitle(canvas, title_color); diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc index ff2eecf2..c644f7a 100644 --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc @@ -24,6 +24,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" @@ -123,7 +124,7 @@ std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, bool bar_attached) { int alignment; theme_provider->GetDisplayProperty( - ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); + ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &alignment); // TODO(glen): This is a quick workaround to hide the notused.png image when // no image is provided - we don't have time right now to figure out why @@ -134,21 +135,21 @@ std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, } if (bar_attached) - return ThemeService::AlignmentToString(alignment); + return ThemeProperties::AlignmentToString(alignment); - if (alignment & ThemeService::ALIGN_TOP) { + if (alignment & ThemeProperties::ALIGN_TOP) { // The bar is detached, so we must offset the background by the bar size // if it's a top-aligned bar. int offset = chrome::kNTPBookmarkBarHeight; - if (alignment & ThemeService::ALIGN_LEFT) + if (alignment & ThemeProperties::ALIGN_LEFT) return "left " + base::IntToString(-offset) + "px"; - else if (alignment & ThemeService::ALIGN_RIGHT) + else if (alignment & ThemeProperties::ALIGN_RIGHT) return "right " + base::IntToString(-offset) + "px"; return "center " + base::IntToString(-offset) + "px"; } - return ThemeService::AlignmentToString(alignment); + return ThemeProperties::AlignmentToString(alignment); } // How the background image on the new tab page should be tiled (see tiling @@ -157,8 +158,8 @@ std::string GetNewTabBackgroundTilingCSS( const ui::ThemeProvider* theme_provider) { int repeat_mode; theme_provider->GetDisplayProperty( - ThemeService::NTP_BACKGROUND_TILING, &repeat_mode); - return ThemeService::TilingToString(repeat_mode); + ThemeProperties::NTP_BACKGROUND_TILING, &repeat_mode); + return ThemeProperties::TilingToString(repeat_mode); } } // namespace @@ -422,9 +423,10 @@ void NTPResourceCache::CreateNewTabHTML() { int alignment; ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); - tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); + tp->GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_ALIGNMENT, + &alignment); load_time_data.SetString("themegravity", - (alignment & ThemeService::ALIGN_RIGHT) ? "right" : ""); + (alignment & ThemeProperties::ALIGN_RIGHT) ? "right" : ""); // Disable the promo if this is the first run, otherwise set the promo string // for display if there is a valid outstanding promo. @@ -471,7 +473,7 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() { // Get our theme colors SkColor color_background = - GetThemeColor(tp, ThemeService::COLOR_NTP_BACKGROUND); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_BACKGROUND); // Generate the replacements. std::vector<std::string> subst; @@ -504,33 +506,33 @@ void NTPResourceCache::CreateNewTabCSS() { // Get our theme colors SkColor color_background = - GetThemeColor(tp, ThemeService::COLOR_NTP_BACKGROUND); - SkColor color_text = GetThemeColor(tp, ThemeService::COLOR_NTP_TEXT); - SkColor color_link = GetThemeColor(tp, ThemeService::COLOR_NTP_LINK); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_BACKGROUND); + SkColor color_text = GetThemeColor(tp, ThemeProperties::COLOR_NTP_TEXT); + SkColor color_link = GetThemeColor(tp, ThemeProperties::COLOR_NTP_LINK); SkColor color_link_underline = - GetThemeColor(tp, ThemeService::COLOR_NTP_LINK_UNDERLINE); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_LINK_UNDERLINE); SkColor color_section = - GetThemeColor(tp, ThemeService::COLOR_NTP_SECTION); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_SECTION); SkColor color_section_text = - GetThemeColor(tp, ThemeService::COLOR_NTP_SECTION_TEXT); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_SECTION_TEXT); SkColor color_section_link = - GetThemeColor(tp, ThemeService::COLOR_NTP_SECTION_LINK); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_SECTION_LINK); SkColor color_section_link_underline = - GetThemeColor(tp, ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE); SkColor color_section_header_text = - GetThemeColor(tp, ThemeService::COLOR_NTP_SECTION_HEADER_TEXT); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_SECTION_HEADER_TEXT); SkColor color_section_header_text_hover = - GetThemeColor(tp, ThemeService::COLOR_NTP_SECTION_HEADER_TEXT_HOVER); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_SECTION_HEADER_TEXT_HOVER); SkColor color_section_header_rule = - GetThemeColor(tp, ThemeService::COLOR_NTP_SECTION_HEADER_RULE); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_SECTION_HEADER_RULE); SkColor color_section_header_rule_light = - GetThemeColor(tp, ThemeService::COLOR_NTP_SECTION_HEADER_RULE_LIGHT); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_SECTION_HEADER_RULE_LIGHT); SkColor color_text_light = - GetThemeColor(tp, ThemeService::COLOR_NTP_TEXT_LIGHT); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_TEXT_LIGHT); SkColor color_header = - GetThemeColor(tp, ThemeService::COLOR_NTP_HEADER); + GetThemeColor(tp, ThemeProperties::COLOR_NTP_HEADER); // Generate a lighter color for the header gradients. color_utils::HSL header_lighter; color_utils::SkColorToHSL(color_header, &header_lighter); diff --git a/chrome/browser/ui/webui/theme_source.cc b/chrome/browser/ui/webui/theme_source.cc index 022e7a5..304e24c 100644 --- a/chrome/browser/ui/webui/theme_source.cc +++ b/chrome/browser/ui/webui/theme_source.cc @@ -9,6 +9,7 @@ #include "base/strings/string_number_conversions.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/resources_util.h" +#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" @@ -18,7 +19,6 @@ #include "googleurl/src/gurl.h" #include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/base/theme_provider.h" #include "ui/webui/web_ui_util.h" using content::BrowserThread; @@ -110,7 +110,7 @@ MessageLoop* ThemeSource::MessageLoopForRequestPath( // If it's not a themeable image, we don't need to go to the UI thread. int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); - if (!ThemeService::IsThemeableImage(resource_id)) + if (!ThemeProperties::IsThemeableImage(resource_id)) return NULL; return content::URLDataSource::MessageLoopForRequestPath(path); @@ -129,7 +129,7 @@ void ThemeSource::SendThemeBitmap( const content::URLDataSource::GotDataCallback& callback, int resource_id, ui::ScaleFactor scale_factor) { - if (ThemeService::IsThemeableImage(resource_id)) { + if (ThemeProperties::IsThemeableImage(resource_id)) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); DCHECK(tp); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 2045c98..0598a99 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2120,6 +2120,8 @@ 'browser/task_profiler/task_profiler_data_serializer.h', 'browser/themes/browser_theme_pack.cc', 'browser/themes/browser_theme_pack.h', + 'browser/themes/theme_properties.cc', + 'browser/themes/theme_properties.h', 'browser/themes/theme_service.cc', 'browser/themes/theme_service_factory.cc', 'browser/themes/theme_service_factory.h', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index eb9a48b..8a23acd 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -1196,6 +1196,7 @@ 'browser/task_manager/task_manager_unittest.cc', 'browser/task_profiler/task_profiler_data_serializer_unittest.cc', 'browser/themes/browser_theme_pack_unittest.cc', + 'browser/themes/theme_properties_unittest.cc', 'browser/themes/theme_service_unittest.cc', 'browser/themes/theme_syncable_service_unittest.cc', 'browser/thumbnails/simple_thumbnail_crop_unittest.cc', |