| 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 = 18; |
| 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 kMaxID = 0x0000FFFF; // Max unsigned 16-bit int. | 39 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int. |
| 40 const int kHeaderID = kMaxID - 1; | 40 const int kHeaderID = kMaxID - 1; |
| 41 const int kTintsID = kMaxID - 2; | 41 const int kTintsID = kMaxID - 2; |
| 42 const int kColorsID = kMaxID - 3; | 42 const int kColorsID = kMaxID - 3; |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 resources[kSourceImagesID] = base::StringPiece( | 443 resources[kSourceImagesID] = base::StringPiece( |
| 444 reinterpret_cast<const char*>(source_images_), | 444 reinterpret_cast<const char*>(source_images_), |
| 445 source_count * sizeof(*source_images_)); | 445 source_count * sizeof(*source_images_)); |
| 446 | 446 |
| 447 AddRawImagesTo(image_memory_, &resources); | 447 AddRawImagesTo(image_memory_, &resources); |
| 448 | 448 |
| 449 RawImages reencoded_images; | 449 RawImages reencoded_images; |
| 450 RepackImages(prepared_images_, &reencoded_images); | 450 RepackImages(prepared_images_, &reencoded_images); |
| 451 AddRawImagesTo(reencoded_images, &resources); | 451 AddRawImagesTo(reencoded_images, &resources); |
| 452 | 452 |
| 453 return ui::DataPack::WritePack(path, resources); | 453 return ui::DataPack::WritePack(path, resources, ui::DataPack::BINARY); |
| 454 } | 454 } |
| 455 | 455 |
| 456 bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const { | 456 bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const { |
| 457 if (tints_) { | 457 if (tints_) { |
| 458 for (int i = 0; i < kTintArraySize; ++i) { | 458 for (int i = 0; i < kTintArraySize; ++i) { |
| 459 if (tints_[i].id == id) { | 459 if (tints_[i].id == id) { |
| 460 hsl->h = tints_[i].h; | 460 hsl->h = tints_[i].h; |
| 461 hsl->s = tints_[i].s; | 461 hsl->s = tints_[i].s; |
| 462 hsl->l = tints_[i].l; | 462 hsl->l = tints_[i].l; |
| 463 return true; | 463 return true; |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 hsl.h = tints_[i].h; | 1060 hsl.h = tints_[i].h; |
| 1061 hsl.s = tints_[i].s; | 1061 hsl.s = tints_[i].s; |
| 1062 hsl.l = tints_[i].l; | 1062 hsl.l = tints_[i].l; |
| 1063 return hsl; | 1063 return hsl; |
| 1064 } | 1064 } |
| 1065 } | 1065 } |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 return ThemeService::GetDefaultTint(id); | 1068 return ThemeService::GetDefaultTint(id); |
| 1069 } | 1069 } |
| OLD | NEW |