Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Side by Side Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 1545223002: Switch to standard integer types in chrome/browser/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h>
8
7 #include <limits> 9 #include <limits>
8 10
9 #include "base/files/file.h" 11 #include "base/files/file.h"
12 #include "base/macros.h"
10 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
11 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h" 15 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/sequenced_worker_pool.h" 19 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/thread_restrictions.h" 20 #include "base/threading/thread_restrictions.h"
18 #include "base/values.h" 21 #include "base/values.h"
22 #include "build/build_config.h"
19 #include "chrome/browser/themes/theme_properties.h" 23 #include "chrome/browser/themes/theme_properties.h"
20 #include "chrome/common/extensions/manifest_handlers/theme_handler.h" 24 #include "chrome/common/extensions/manifest_handlers/theme_handler.h"
21 #include "components/crx_file/id_util.h" 25 #include "components/crx_file/id_util.h"
22 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
23 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
24 #include "third_party/skia/include/core/SkCanvas.h" 28 #include "third_party/skia/include/core/SkCanvas.h"
25 #include "ui/base/resource/data_pack.h" 29 #include "ui/base/resource/data_pack.h"
26 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/canvas.h" 31 #include "ui/gfx/canvas.h"
28 #include "ui/gfx/codec/png_codec.h" 32 #include "ui/gfx/codec/png_codec.h"
(...skipping 10 matching lines...) Expand all
39 using extensions::Extension; 43 using extensions::Extension;
40 44
41 namespace { 45 namespace {
42 46
43 // Version number of the current theme pack. We just throw out and rebuild 47 // Version number of the current theme pack. We just throw out and rebuild
44 // theme packs that aren't int-equal to this. Increment this number if you 48 // theme packs that aren't int-equal to this. Increment this number if you
45 // change default theme assets. 49 // change default theme assets.
46 const int kThemePackVersion = 36; 50 const int kThemePackVersion = 36;
47 51
48 // IDs that are in the DataPack won't clash with the positive integer 52 // IDs that are in the DataPack won't clash with the positive integer
49 // uint16. kHeaderID should always have the maximum value because we want the 53 // uint16_t. kHeaderID should always have the maximum value because we want the
50 // "header" to be written last. That way we can detect whether the pack was 54 // "header" to be written last. That way we can detect whether the pack was
51 // successfully written and ignore and regenerate if it was only partially 55 // successfully written and ignore and regenerate if it was only partially
52 // written (i.e. chrome crashed on a different thread while writing the pack). 56 // written (i.e. chrome crashed on a different thread while writing the pack).
53 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int. 57 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int.
54 const int kHeaderID = kMaxID - 1; 58 const int kHeaderID = kMaxID - 1;
55 const int kTintsID = kMaxID - 2; 59 const int kTintsID = kMaxID - 2;
56 const int kColorsID = kMaxID - 3; 60 const int kColorsID = kMaxID - 3;
57 const int kDisplayPropertiesID = kMaxID - 4; 61 const int kDisplayPropertiesID = kMaxID - 4;
58 const int kSourceImagesID = kMaxID - 5; 62 const int kSourceImagesID = kMaxID - 5;
59 const int kScaleFactorsID = kMaxID - 6; 63 const int kScaleFactorsID = kMaxID - 6;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 #else 445 #else
442 return true; 446 return true;
443 #endif 447 #endif
444 } 448 }
445 449
446 // Returns a piece of memory with the contents of the file |path|. 450 // Returns a piece of memory with the contents of the file |path|.
447 base::RefCountedMemory* ReadFileData(const base::FilePath& path) { 451 base::RefCountedMemory* ReadFileData(const base::FilePath& path) {
448 if (!path.empty()) { 452 if (!path.empty()) {
449 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); 453 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ);
450 if (file.IsValid()) { 454 if (file.IsValid()) {
451 int64 length = file.GetLength(); 455 int64_t length = file.GetLength();
452 if (length > 0 && length < INT_MAX) { 456 if (length > 0 && length < INT_MAX) {
453 int size = static_cast<int>(length); 457 int size = static_cast<int>(length);
454 std::vector<unsigned char> raw_data; 458 std::vector<unsigned char> raw_data;
455 raw_data.resize(size); 459 raw_data.resize(size);
456 char* data = reinterpret_cast<char*>(&(raw_data.front())); 460 char* data = reinterpret_cast<char*>(&(raw_data.front()));
457 if (file.ReadAtCurrentPos(data, size) == length) 461 if (file.ReadAtCurrentPos(data, size) == length)
458 return base::RefCountedBytes::TakeVector(&raw_data); 462 return base::RefCountedBytes::TakeVector(&raw_data);
459 } 463 }
460 } 464 }
461 } 465 }
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 false, 1637 false,
1634 &bitmap_data)) { 1638 &bitmap_data)) {
1635 NOTREACHED() << "Unable to encode theme image for prs_id=" 1639 NOTREACHED() << "Unable to encode theme image for prs_id="
1636 << prs_id << " for scale_factor=" << scale_factors_[i]; 1640 << prs_id << " for scale_factor=" << scale_factors_[i];
1637 break; 1641 break;
1638 } 1642 }
1639 image_memory_[scaled_raw_id] = 1643 image_memory_[scaled_raw_id] =
1640 base::RefCountedBytes::TakeVector(&bitmap_data); 1644 base::RefCountedBytes::TakeVector(&bitmap_data);
1641 } 1645 }
1642 } 1646 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.h ('k') | chrome/browser/themes/browser_theme_pack_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698