| 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 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 5 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // such as theme graphics. Every resource is loaded only once. | 43 // such as theme graphics. Every resource is loaded only once. |
| 44 class UI_BASE_EXPORT ResourceBundle { | 44 class UI_BASE_EXPORT ResourceBundle { |
| 45 public: | 45 public: |
| 46 // Legacy font size deltas. Consider these to be magic numbers. New code | 46 // Legacy font size deltas. Consider these to be magic numbers. New code |
| 47 // should declare their own size delta constant using an identifier that | 47 // should declare their own size delta constant using an identifier that |
| 48 // imparts some semantic meaning. | 48 // imparts some semantic meaning. |
| 49 static const int kSmallFontDelta = -1; | 49 static const int kSmallFontDelta = -1; |
| 50 static const int kMediumFontDelta = 3; | 50 static const int kMediumFontDelta = 3; |
| 51 static const int kLargeFontDelta = 8; | 51 static const int kLargeFontDelta = 8; |
| 52 | 52 |
| 53 static constexpr const char* CUSTOM_GZIP_HEADER = "\xff\x1f\x8b"; | |
| 54 | |
| 55 // Legacy font style mappings. TODO(tapted): Phase these out in favour of | 53 // Legacy font style mappings. TODO(tapted): Phase these out in favour of |
| 56 // client code providing their own constant with the desired font size delta. | 54 // client code providing their own constant with the desired font size delta. |
| 57 enum FontStyle { | 55 enum FontStyle { |
| 58 SmallFont, | 56 SmallFont, |
| 59 SmallBoldFont, | 57 SmallBoldFont, |
| 60 BaseFont, | 58 BaseFont, |
| 61 BoldFont, | 59 BoldFont, |
| 62 MediumFont, | 60 MediumFont, |
| 63 MediumBoldFont, | 61 MediumBoldFont, |
| 64 LargeFont, | 62 LargeFont, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // Loads the raw bytes of a data resource nearest the scale factor | 221 // Loads the raw bytes of a data resource nearest the scale factor |
| 224 // |scale_factor| into |bytes|, without doing any processing or | 222 // |scale_factor| into |bytes|, without doing any processing or |
| 225 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE | 223 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE |
| 226 // for scale independent image resources (such as wallpaper). | 224 // for scale independent image resources (such as wallpaper). |
| 227 // Returns NULL if we fail to read the resource. | 225 // Returns NULL if we fail to read the resource. |
| 228 base::RefCountedMemory* LoadDataResourceBytesForScale( | 226 base::RefCountedMemory* LoadDataResourceBytesForScale( |
| 229 int resource_id, | 227 int resource_id, |
| 230 ScaleFactor scale_factor) const; | 228 ScaleFactor scale_factor) const; |
| 231 | 229 |
| 232 // Return the contents of a scale independent resource in a | 230 // Return the contents of a scale independent resource in a |
| 233 // StringPiece given the resource id. | 231 // StringPiece given the resource id |
| 234 base::StringPiece GetRawDataResource(int resource_id) const; | 232 base::StringPiece GetRawDataResource(int resource_id) const; |
| 235 | 233 |
| 236 // Return the contents of a resource in a StringPiece given the resource id | 234 // Return the contents of a resource in a StringPiece given the resource id |
| 237 // nearest the scale factor |scale_factor|. | 235 // nearest the scale factor |scale_factor|. |
| 238 // Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources | 236 // Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources |
| 239 // (such as wallpaper). | 237 // (such as wallpaper). |
| 240 base::StringPiece GetRawDataResourceForScale(int resource_id, | 238 base::StringPiece GetRawDataResourceForScale(int resource_id, |
| 241 ScaleFactor scale_factor) const; | 239 ScaleFactor scale_factor) const; |
| 242 | 240 |
| 243 // Get a localized string given a message id. Returns an empty | 241 // Get a localized string given a message id. Returns an empty |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 375 |
| 378 // Fills the |bitmap| given the |resource_id| and |scale_factor|. | 376 // Fills the |bitmap| given the |resource_id| and |scale_factor|. |
| 379 // Returns false if the resource does not exist. This may fall back to | 377 // Returns false if the resource does not exist. This may fall back to |
| 380 // the data pack with SCALE_FACTOR_NONE, and when this happens, | 378 // the data pack with SCALE_FACTOR_NONE, and when this happens, |
| 381 // |scale_factor| will be set to SCALE_FACTOR_100P. | 379 // |scale_factor| will be set to SCALE_FACTOR_100P. |
| 382 bool LoadBitmap(int resource_id, | 380 bool LoadBitmap(int resource_id, |
| 383 ScaleFactor* scale_factor, | 381 ScaleFactor* scale_factor, |
| 384 SkBitmap* bitmap, | 382 SkBitmap* bitmap, |
| 385 bool* fell_back_to_1x) const; | 383 bool* fell_back_to_1x) const; |
| 386 | 384 |
| 387 // Loads the raw bytes of a data resource nearest the scale factor | |
| 388 // |scale_factor| into |bytes|, without doing any processing or | |
| 389 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE | |
| 390 // for scale independent image resources (such as wallpaper). | |
| 391 // Returns NULL if we fail to read the resource. | |
| 392 base::StringPiece GetRawDataResourceForScaleImpl( | |
| 393 int resource_id, | |
| 394 ScaleFactor scale_factor) const; | |
| 395 | |
| 396 // Returns true if missing scaled resources should be visually indicated when | 385 // Returns true if missing scaled resources should be visually indicated when |
| 397 // drawing the fallback (e.g., by tinting the image). | 386 // drawing the fallback (e.g., by tinting the image). |
| 398 static bool ShouldHighlightMissingScaledResources(); | 387 static bool ShouldHighlightMissingScaledResources(); |
| 399 | 388 |
| 400 // Returns true if the data in |buf| is a PNG that has the special marker | 389 // Returns true if the data in |buf| is a PNG that has the special marker |
| 401 // added by GRIT that indicates that the image is actually 1x data. | 390 // added by GRIT that indicates that the image is actually 1x data. |
| 402 static bool PNGContainsFallbackMarker(const unsigned char* buf, size_t size); | 391 static bool PNGContainsFallbackMarker(const unsigned char* buf, size_t size); |
| 403 | 392 |
| 404 // A wrapper for PNGCodec::Decode that returns information about custom | 393 // A wrapper for PNGCodec::Decode that returns information about custom |
| 405 // chunks. For security reasons we can't alter PNGCodec to return this | 394 // chunks. For security reasons we can't alter PNGCodec to return this |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 443 |
| 455 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 444 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
| 456 }; | 445 }; |
| 457 | 446 |
| 458 } // namespace ui | 447 } // namespace ui |
| 459 | 448 |
| 460 // TODO(beng): Someday, maybe, get rid of this. | 449 // TODO(beng): Someday, maybe, get rid of this. |
| 461 using ui::ResourceBundle; | 450 using ui::ResourceBundle; |
| 462 | 451 |
| 463 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 452 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| OLD | NEW |