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

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

Issue 481433005: Extensions: Move id_util functions to crx_file component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert last patchset. function returns Extension* and can't use an assert. Created 6 years, 4 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 | Annotate | Revision Log
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 <limits> 7 #include <limits>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/themes/theme_properties.h" 19 #include "chrome/browser/themes/theme_properties.h"
20 #include "chrome/common/extensions/manifest_handlers/theme_handler.h" 20 #include "chrome/common/extensions/manifest_handlers/theme_handler.h"
21 #include "components/crx_file/id_util.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "extensions/common/id_util.h"
23 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
24 #include "third_party/skia/include/core/SkCanvas.h" 24 #include "third_party/skia/include/core/SkCanvas.h"
25 #include "ui/base/resource/data_pack.h" 25 #include "ui/base/resource/data_pack.h"
26 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
28 #include "ui/gfx/codec/png_codec.h" 28 #include "ui/gfx/codec/png_codec.h"
29 #include "ui/gfx/image/canvas_image_source.h" 29 #include "ui/gfx/image/canvas_image_source.h"
30 #include "ui/gfx/image/image.h" 30 #include "ui/gfx/image/image.h"
31 #include "ui/gfx/image/image_skia.h" 31 #include "ui/gfx/image/image_skia.h"
32 #include "ui/gfx/image/image_skia_operations.h" 32 #include "ui/gfx/image/image_skia_operations.h"
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 return NULL; 717 return NULL;
718 pack->header_ = reinterpret_cast<BrowserThemePackHeader*>(const_cast<char*>( 718 pack->header_ = reinterpret_cast<BrowserThemePackHeader*>(const_cast<char*>(
719 pointer.data())); 719 pointer.data()));
720 720
721 if (pack->header_->version != kThemePackVersion) { 721 if (pack->header_->version != kThemePackVersion) {
722 DLOG(ERROR) << "BuildFromDataPack failure! Version mismatch!"; 722 DLOG(ERROR) << "BuildFromDataPack failure! Version mismatch!";
723 return NULL; 723 return NULL;
724 } 724 }
725 // TODO(erg): Check endianess once DataPack works on the other endian. 725 // TODO(erg): Check endianess once DataPack works on the other endian.
726 std::string theme_id(reinterpret_cast<char*>(pack->header_->theme_id), 726 std::string theme_id(reinterpret_cast<char*>(pack->header_->theme_id),
727 extensions::id_util::kIdSize); 727 crx_file::id_util::kIdSize);
728 std::string truncated_id = 728 std::string truncated_id = expected_id.substr(0, crx_file::id_util::kIdSize);
729 expected_id.substr(0, extensions::id_util::kIdSize);
730 if (theme_id != truncated_id) { 729 if (theme_id != truncated_id) {
731 DLOG(ERROR) << "Wrong id: " << theme_id << " vs " << expected_id; 730 DLOG(ERROR) << "Wrong id: " << theme_id << " vs " << expected_id;
732 return NULL; 731 return NULL;
733 } 732 }
734 733
735 if (!pack->data_pack_->GetStringPiece(kTintsID, &pointer)) 734 if (!pack->data_pack_->GetStringPiece(kTintsID, &pointer))
736 return NULL; 735 return NULL;
737 pack->tints_ = reinterpret_cast<TintEntry*>(const_cast<char*>( 736 pack->tints_ = reinterpret_cast<TintEntry*>(const_cast<char*>(
738 pointer.data())); 737 pointer.data()));
739 738
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 // Linux check 945 // Linux check
947 COMPILE_ASSERT(__BYTE_ORDER == __LITTLE_ENDIAN, 946 COMPILE_ASSERT(__BYTE_ORDER == __LITTLE_ENDIAN,
948 datapack_assumes_little_endian); 947 datapack_assumes_little_endian);
949 #elif defined(__BIG_ENDIAN__) 948 #elif defined(__BIG_ENDIAN__)
950 // Mac check 949 // Mac check
951 #error DataPack assumes little endian 950 #error DataPack assumes little endian
952 #endif 951 #endif
953 header_->little_endian = 1; 952 header_->little_endian = 1;
954 953
955 const std::string& id = extension->id(); 954 const std::string& id = extension->id();
956 memcpy(header_->theme_id, id.c_str(), extensions::id_util::kIdSize); 955 memcpy(header_->theme_id, id.c_str(), crx_file::id_util::kIdSize);
957 } 956 }
958 957
959 void BrowserThemePack::BuildTintsFromJSON( 958 void BrowserThemePack::BuildTintsFromJSON(
960 const base::DictionaryValue* tints_value) { 959 const base::DictionaryValue* tints_value) {
961 tints_ = new TintEntry[kTintTableLength]; 960 tints_ = new TintEntry[kTintTableLength];
962 for (size_t i = 0; i < kTintTableLength; ++i) { 961 for (size_t i = 0; i < kTintTableLength; ++i) {
963 tints_[i].id = -1; 962 tints_[i].id = -1;
964 tints_[i].h = -1; 963 tints_[i].h = -1;
965 tints_[i].s = -1; 964 tints_[i].s = -1;
966 tints_[i].l = -1; 965 tints_[i].l = -1;
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 false, 1612 false,
1614 &bitmap_data)) { 1613 &bitmap_data)) {
1615 NOTREACHED() << "Unable to encode theme image for prs_id=" 1614 NOTREACHED() << "Unable to encode theme image for prs_id="
1616 << prs_id << " for scale_factor=" << scale_factors_[i]; 1615 << prs_id << " for scale_factor=" << scale_factors_[i];
1617 break; 1616 break;
1618 } 1617 }
1619 image_memory_[scaled_raw_id] = 1618 image_memory_[scaled_raw_id] =
1620 base::RefCountedBytes::TakeVector(&bitmap_data); 1619 base::RefCountedBytes::TakeVector(&bitmap_data);
1621 } 1620 }
1622 } 1621 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698