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

Side by Side Diff: chrome/common/resource_bundle.cc

Issue 67024: Adds some ifdefs so that test_shell can be compiled on linux... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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
« no previous file with comments | « chrome/common/resource_bundle.h ('k') | chrome/common/resource_bundle_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/common/resource_bundle.h" 5 #include "chrome/common/resource_bundle.h"
6 6
7 #include "base/gfx/png_decoder.h" 7 #include "base/gfx/png_decoder.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "net/base/file_stream.h" 10 #include "net/base/file_stream.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 void ResourceBundle::FreeImages() { 46 void ResourceBundle::FreeImages() {
47 for (SkImageMap::iterator i = skia_images_.begin(); 47 for (SkImageMap::iterator i = skia_images_.begin();
48 i != skia_images_.end(); i++) { 48 i != skia_images_.end(); i++) {
49 delete i->second; 49 delete i->second;
50 } 50 }
51 skia_images_.clear(); 51 skia_images_.clear();
52 } 52 }
53 53
54 void ResourceBundle::SetThemeExtension(const Extension& e) { 54 void ResourceBundle::SetThemeExtension(const Extension& e) {
55 #if !defined(LINUX2)
55 theme_extension_.reset(new Extension(e)); 56 theme_extension_.reset(new Extension(e));
57 #endif
56 } 58 }
57 59
58 /* static */ 60 /* static */
59 SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) { 61 SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) {
60 std::vector<unsigned char> raw_data, png_data; 62 std::vector<unsigned char> raw_data, png_data;
61 bool success = false; 63 bool success = false;
62 // First check to see if we have a registered theme extension and whether 64 // First check to see if we have a registered theme extension and whether
63 // it can handle this resource. 65 // it can handle this resource.
64 // TODO(erikkay): It would be nice to use something less brittle than 66 // TODO(erikkay): It would be nice to use something less brittle than
65 // resource_id here. 67 // resource_id here.
68 #if !defined(LINUX2)
66 if (g_shared_instance_->theme_extension_.get()) { 69 if (g_shared_instance_->theme_extension_.get()) {
67 FilePath path = 70 FilePath path =
68 g_shared_instance_->theme_extension_->GetThemeResourcePath(resource_id); 71 g_shared_instance_->theme_extension_->GetThemeResourcePath(resource_id);
69 if (!path.empty()) { 72 if (!path.empty()) {
70 net::FileStream file; 73 net::FileStream file;
71 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; 74 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
72 if (file.Open(path, flags) == net::OK) { 75 if (file.Open(path, flags) == net::OK) {
73 int64 avail = file.Available(); 76 int64 avail = file.Available();
74 if (avail > 0 && avail < INT_MAX) { 77 if (avail > 0 && avail < INT_MAX) {
75 size_t size = static_cast<size_t>(avail); 78 size_t size = static_cast<size_t>(avail);
76 raw_data.resize(size); 79 raw_data.resize(size);
77 char* data = reinterpret_cast<char*>(&(raw_data.front())); 80 char* data = reinterpret_cast<char*>(&(raw_data.front()));
78 if (file.ReadUntilComplete(data, size) == avail) { 81 if (file.ReadUntilComplete(data, size) == avail) {
79 success= true; 82 success= true;
80 } else { 83 } else {
81 raw_data.resize(0); 84 raw_data.resize(0);
82 } 85 }
83 } 86 }
84 } 87 }
85 } 88 }
86 } 89 }
90 #endif
87 if (!success) 91 if (!success)
88 success = LoadResourceBytes(data_handle, resource_id, &raw_data); 92 success = LoadResourceBytes(data_handle, resource_id, &raw_data);
89 if (!success) 93 if (!success)
90 return NULL; 94 return NULL;
91 95
92 // Decode the PNG. 96 // Decode the PNG.
93 int image_width; 97 int image_width;
94 int image_height; 98 int image_height;
95 if (!PNGDecoder::Decode(&raw_data.front(), raw_data.size(), 99 if (!PNGDecoder::Decode(&raw_data.front(), raw_data.size(),
96 PNGDecoder::FORMAT_BGRA, 100 PNGDecoder::FORMAT_BGRA,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 case MediumFont: 200 case MediumFont:
197 return *medium_font_; 201 return *medium_font_;
198 case MediumBoldFont: 202 case MediumBoldFont:
199 return *medium_bold_font_; 203 return *medium_bold_font_;
200 case LargeFont: 204 case LargeFont:
201 return *large_font_; 205 return *large_font_;
202 default: 206 default:
203 return *base_font_; 207 return *base_font_;
204 } 208 }
205 } 209 }
OLDNEW
« no previous file with comments | « chrome/common/resource_bundle.h ('k') | chrome/common/resource_bundle_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698