OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 using content::BrowserThread; | 43 using content::BrowserThread; |
44 using extensions::Extension; | 44 using extensions::Extension; |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 // Version number of the current theme pack. We just throw out and rebuild | 48 // Version number of the current theme pack. We just throw out and rebuild |
49 // theme packs that aren't int-equal to this. Increment this number if you | 49 // theme packs that aren't int-equal to this. Increment this number if you |
50 // change default theme assets or if you need themes to recreate their generated | 50 // change default theme assets or if you need themes to recreate their generated |
51 // images (which are cached). | 51 // images (which are cached). |
52 const int kThemePackVersion = 43; | 52 const int kThemePackVersion = 42; |
53 | 53 |
54 // IDs that are in the DataPack won't clash with the positive integer | 54 // IDs that are in the DataPack won't clash with the positive integer |
55 // uint16_t. kHeaderID should always have the maximum value because we want the | 55 // uint16_t. kHeaderID should always have the maximum value because we want the |
56 // "header" to be written last. That way we can detect whether the pack was | 56 // "header" to be written last. That way we can detect whether the pack was |
57 // successfully written and ignore and regenerate if it was only partially | 57 // successfully written and ignore and regenerate if it was only partially |
58 // written (i.e. chrome crashed on a different thread while writing the pack). | 58 // written (i.e. chrome crashed on a different thread while writing the pack). |
59 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int. | 59 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int. |
60 const int kHeaderID = kMaxID - 1; | 60 const int kHeaderID = kMaxID - 1; |
61 const int kTintsID = kMaxID - 2; | 61 const int kTintsID = kMaxID - 2; |
62 const int kColorsID = kMaxID - 3; | 62 const int kColorsID = kMaxID - 3; |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 | 784 |
785 return false; | 785 return false; |
786 } | 786 } |
787 | 787 |
788 bool BrowserThemePack::GetColor(int id, SkColor* color) const { | 788 bool BrowserThemePack::GetColor(int id, SkColor* color) const { |
789 if (colors_) { | 789 if (colors_) { |
790 for (size_t i = 0; i < kColorTableLength; ++i) { | 790 for (size_t i = 0; i < kColorTableLength; ++i) { |
791 if (colors_[i].id == id) { | 791 if (colors_[i].id == id) { |
792 *color = colors_[i].color; | 792 *color = colors_[i].color; |
793 // The theme provider is intentionally made to ignore alpha for toolbar | 793 // The theme provider is intentionally made to ignore alpha for toolbar |
794 // color, as we don't want to allow transparent toolbars. Same for the | 794 // color, as we don't want to allow transparent toolbars. |
795 // ntp background color. | 795 if (id == ThemeProperties::COLOR_TOOLBAR) |
796 if (id == ThemeProperties::COLOR_TOOLBAR || | |
797 id == ThemeProperties::COLOR_NTP_BACKGROUND) { | |
798 *color = SkColorSetA(*color, SK_AlphaOPAQUE); | 796 *color = SkColorSetA(*color, SK_AlphaOPAQUE); |
799 } | |
800 return true; | 797 return true; |
801 } | 798 } |
802 } | 799 } |
803 } | 800 } |
804 | 801 |
805 return false; | 802 return false; |
806 } | 803 } |
807 | 804 |
808 bool BrowserThemePack::GetDisplayProperty(int id, int* result) const { | 805 bool BrowserThemePack::GetDisplayProperty(int id, int* result) const { |
809 if (display_properties_) { | 806 if (display_properties_) { |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 false, | 1541 false, |
1545 &bitmap_data)) { | 1542 &bitmap_data)) { |
1546 NOTREACHED() << "Unable to encode theme image for prs_id=" | 1543 NOTREACHED() << "Unable to encode theme image for prs_id=" |
1547 << prs_id << " for scale_factor=" << scale_factors_[i]; | 1544 << prs_id << " for scale_factor=" << scale_factors_[i]; |
1548 break; | 1545 break; |
1549 } | 1546 } |
1550 image_memory_[scaled_raw_id] = | 1547 image_memory_[scaled_raw_id] = |
1551 base::RefCountedBytes::TakeVector(&bitmap_data); | 1548 base::RefCountedBytes::TakeVector(&bitmap_data); |
1552 } | 1549 } |
1553 } | 1550 } |
OLD | NEW |