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

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

Issue 5992006: Move data pack from base to app (it's just part of the resource bundle system... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/data_pack.h"
7 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
8 #include "base/data_pack.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/thread_restrictions.h" 11 #include "base/thread_restrictions.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_thread.h" 14 #include "chrome/browser/browser_thread.h"
15 #include "chrome/browser/themes/browser_theme_provider.h" 15 #include "chrome/browser/themes/browser_theme_provider.h"
16 #include "gfx/codec/png_codec.h" 16 #include "gfx/codec/png_codec.h"
17 #include "gfx/skbitmap_operations.h" 17 #include "gfx/skbitmap_operations.h"
18 #include "grit/app_resources.h" 18 #include "grit/app_resources.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 363
364 // The BrowserThemePack is now in a consistent state. 364 // The BrowserThemePack is now in a consistent state.
365 return pack; 365 return pack;
366 } 366 }
367 367
368 // static 368 // static
369 scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromDataPack( 369 scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromDataPack(
370 FilePath path, const std::string& expected_id) { 370 FilePath path, const std::string& expected_id) {
371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
372 scoped_refptr<BrowserThemePack> pack(new BrowserThemePack); 372 scoped_refptr<BrowserThemePack> pack(new BrowserThemePack);
373 pack->data_pack_.reset(new base::DataPack); 373 pack->data_pack_.reset(new app::DataPack);
374 374
375 if (!pack->data_pack_->Load(path)) { 375 if (!pack->data_pack_->Load(path)) {
376 LOG(ERROR) << "Failed to load theme data pack."; 376 LOG(ERROR) << "Failed to load theme data pack.";
377 return NULL; 377 return NULL;
378 } 378 }
379 379
380 base::StringPiece pointer; 380 base::StringPiece pointer;
381 if (!pack->data_pack_->GetStringPiece(kHeaderID, &pointer)) 381 if (!pack->data_pack_->GetStringPiece(kHeaderID, &pointer))
382 return NULL; 382 return NULL;
383 pack->header_ = reinterpret_cast<BrowserThemePackHeader*>(const_cast<char*>( 383 pack->header_ = reinterpret_cast<BrowserThemePackHeader*>(const_cast<char*>(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 resources[kSourceImagesID] = base::StringPiece( 441 resources[kSourceImagesID] = base::StringPiece(
442 reinterpret_cast<const char*>(source_images_), 442 reinterpret_cast<const char*>(source_images_),
443 source_count * sizeof(*source_images_)); 443 source_count * sizeof(*source_images_));
444 444
445 AddRawImagesTo(image_memory_, &resources); 445 AddRawImagesTo(image_memory_, &resources);
446 446
447 RawImages reencoded_images; 447 RawImages reencoded_images;
448 RepackImages(prepared_images_, &reencoded_images); 448 RepackImages(prepared_images_, &reencoded_images);
449 AddRawImagesTo(reencoded_images, &resources); 449 AddRawImagesTo(reencoded_images, &resources);
450 450
451 return base::DataPack::WritePack(path, resources); 451 return app::DataPack::WritePack(path, resources);
452 } 452 }
453 453
454 bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const { 454 bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const {
455 if (tints_) { 455 if (tints_) {
456 for (int i = 0; i < kTintArraySize; ++i) { 456 for (int i = 0; i < kTintArraySize; ++i) {
457 if (tints_[i].id == id) { 457 if (tints_[i].id == id) {
458 hsl->h = tints_[i].h; 458 hsl->h = tints_[i].h;
459 hsl->s = tints_[i].s; 459 hsl->s = tints_[i].s;
460 hsl->l = tints_[i].l; 460 hsl->l = tints_[i].l;
461 return true; 461 return true;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 colors_(NULL), 576 colors_(NULL),
577 display_properties_(NULL), 577 display_properties_(NULL),
578 source_images_(NULL) { 578 source_images_(NULL) {
579 } 579 }
580 580
581 void BrowserThemePack::BuildHeader(const Extension* extension) { 581 void BrowserThemePack::BuildHeader(const Extension* extension) {
582 header_ = new BrowserThemePackHeader; 582 header_ = new BrowserThemePackHeader;
583 header_->version = kThemePackVersion; 583 header_->version = kThemePackVersion;
584 584
585 // TODO(erg): Need to make this endian safe on other computers. Prerequisite 585 // TODO(erg): Need to make this endian safe on other computers. Prerequisite
586 // is that base::DataPack removes this same check. 586 // is that app::DataPack removes this same check.
587 #if defined(__BYTE_ORDER) 587 #if defined(__BYTE_ORDER)
588 // Linux check 588 // Linux check
589 COMPILE_ASSERT(__BYTE_ORDER == __LITTLE_ENDIAN, 589 COMPILE_ASSERT(__BYTE_ORDER == __LITTLE_ENDIAN,
590 datapack_assumes_little_endian); 590 datapack_assumes_little_endian);
591 #elif defined(__BIG_ENDIAN__) 591 #elif defined(__BIG_ENDIAN__)
592 // Mac check 592 // Mac check
593 #error DataPack assumes little endian 593 #error DataPack assumes little endian
594 #endif 594 #endif
595 header_->little_endian = 1; 595 header_->little_endian = 1;
596 596
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 hsl.h = tints_[i].h; 1041 hsl.h = tints_[i].h;
1042 hsl.s = tints_[i].s; 1042 hsl.s = tints_[i].s;
1043 hsl.l = tints_[i].l; 1043 hsl.l = tints_[i].l;
1044 return hsl; 1044 return hsl;
1045 } 1045 }
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 return BrowserThemeProvider::GetDefaultTint(id); 1049 return BrowserThemeProvider::GetDefaultTint(id);
1050 } 1050 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.h ('k') | chrome/tools/mac_helpers/infoplist_strings_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698