Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/themes/browser_theme_pack.h" | 5 #include "chrome/browser/themes/browser_theme_pack.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "ui/base/resource/data_pack.h" | 22 #include "ui/base/resource/data_pack.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/gfx/codec/png_codec.h" | 24 #include "ui/gfx/codec/png_codec.h" |
| 25 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 26 #include "ui/gfx/skbitmap_operations.h" | 26 #include "ui/gfx/skbitmap_operations.h" |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Version number of the current theme pack. We just throw out and rebuild | 30 // Version number of the current theme pack. We just throw out and rebuild |
| 31 // theme packs that aren't int-equal to this. | 31 // theme packs that aren't int-equal to this. |
| 32 const int kThemePackVersion = 17; | 32 const int kThemePackVersion = 17; |
|
tony
2011/08/29 21:24:39
Please bump the kThemePackVersion to 18.
marcvs
2011/08/30 07:58:55
Done.
| |
| 33 | 33 |
| 34 // IDs that are in the DataPack won't clash with the positive integer | 34 // IDs that are in the DataPack won't clash with the positive integer |
| 35 // uint16. kHeaderID should always have the maximum value because we want the | 35 // uint16. kHeaderID should always have the maximum value because we want the |
| 36 // "header" to be written last. That way we can detect whether the pack was | 36 // "header" to be written last. That way we can detect whether the pack was |
| 37 // successfully written and ignore and regenerate if it was only partially | 37 // successfully written and ignore and regenerate if it was only partially |
| 38 // written (i.e. chrome crashed on a different thread while writing the pack). | 38 // written (i.e. chrome crashed on a different thread while writing the pack). |
| 39 const int kHeaderID = std::numeric_limits<uint16>::max() - 1; | 39 const int kHeaderID = std::numeric_limits<uint16>::max() - 1; |
| 40 const int kTintsID = std::numeric_limits<uint16>::max() - 2; | 40 const int kTintsID = std::numeric_limits<uint16>::max() - 2; |
| 41 const int kColorsID = std::numeric_limits<uint16>::max() - 3; | 41 const int kColorsID = std::numeric_limits<uint16>::max() - 3; |
| 42 const int kDisplayPropertiesID = std::numeric_limits<uint16>::max() - 4; | 42 const int kDisplayPropertiesID = std::numeric_limits<uint16>::max() - 4; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 resources[kSourceImagesID] = base::StringPiece( | 442 resources[kSourceImagesID] = base::StringPiece( |
| 443 reinterpret_cast<const char*>(source_images_), | 443 reinterpret_cast<const char*>(source_images_), |
| 444 source_count * sizeof(*source_images_)); | 444 source_count * sizeof(*source_images_)); |
| 445 | 445 |
| 446 AddRawImagesTo(image_memory_, &resources); | 446 AddRawImagesTo(image_memory_, &resources); |
| 447 | 447 |
| 448 RawImages reencoded_images; | 448 RawImages reencoded_images; |
| 449 RepackImages(prepared_images_, &reencoded_images); | 449 RepackImages(prepared_images_, &reencoded_images); |
| 450 AddRawImagesTo(reencoded_images, &resources); | 450 AddRawImagesTo(reencoded_images, &resources); |
| 451 | 451 |
| 452 return ui::DataPack::WritePack(path, resources); | 452 return ui::DataPack::WritePack(path, resources, ui::DataPack::BINARY); |
| 453 } | 453 } |
| 454 | 454 |
| 455 bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const { | 455 bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const { |
| 456 if (tints_) { | 456 if (tints_) { |
| 457 for (int i = 0; i < kTintArraySize; ++i) { | 457 for (int i = 0; i < kTintArraySize; ++i) { |
| 458 if (tints_[i].id == id) { | 458 if (tints_[i].id == id) { |
| 459 hsl->h = tints_[i].h; | 459 hsl->h = tints_[i].h; |
| 460 hsl->s = tints_[i].s; | 460 hsl->s = tints_[i].s; |
| 461 hsl->l = tints_[i].l; | 461 hsl->l = tints_[i].l; |
| 462 return true; | 462 return true; |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 hsl.h = tints_[i].h; | 1059 hsl.h = tints_[i].h; |
| 1060 hsl.s = tints_[i].s; | 1060 hsl.s = tints_[i].s; |
| 1061 hsl.l = tints_[i].l; | 1061 hsl.l = tints_[i].l; |
| 1062 return hsl; | 1062 return hsl; |
| 1063 } | 1063 } |
| 1064 } | 1064 } |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 return ThemeService::GetDefaultTint(id); | 1067 return ThemeService::GetDefaultTint(id); |
| 1068 } | 1068 } |
| OLD | NEW |