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

Side by Side Diff: ui/base/resource/resource_bundle.cc

Issue 10151025: Add scale factor tag to data packs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 7 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 | « ui/base/resource/resource_bundle.h ('k') | ui/base/resource/resource_bundle_android.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) 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 "ui/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Must call InitSharedInstance before this function. 82 // Must call InitSharedInstance before this function.
83 CHECK(g_shared_instance_ != NULL); 83 CHECK(g_shared_instance_ != NULL);
84 return *g_shared_instance_; 84 return *g_shared_instance_;
85 } 85 }
86 86
87 // static 87 // static
88 bool ResourceBundle::LocaleDataPakExists(const std::string& locale) { 88 bool ResourceBundle::LocaleDataPakExists(const std::string& locale) {
89 return !GetLocaleFilePath(locale).empty(); 89 return !GetLocaleFilePath(locale).empty();
90 } 90 }
91 91
92 void ResourceBundle::AddDataPack(const FilePath& path) { 92 void ResourceBundle::AddDataPack(const FilePath& path, float scale_factor) {
93 scoped_ptr<DataPack> data_pack(new DataPack()); 93 scoped_ptr<DataPack> data_pack(
94 new DataPack(ResourceHandle::kScaleFactor100x));
94 if (data_pack->Load(path)) { 95 if (data_pack->Load(path)) {
95 data_packs_.push_back(data_pack.release()); 96 data_packs_.push_back(data_pack.release());
96 } else { 97 } else {
97 LOG(ERROR) << "Failed to load " << path.value() 98 LOG(ERROR) << "Failed to load " << path.value()
98 << "\nSome features may not be available."; 99 << "\nSome features may not be available.";
99 } 100 }
100 } 101 }
101 102
102 #if !defined(OS_MACOSX) 103 #if !defined(OS_MACOSX)
103 // static 104 // static
(...skipping 30 matching lines...) Expand all
134 locale_file_path = GetLocaleFilePath(app_locale); 135 locale_file_path = GetLocaleFilePath(app_locale);
135 } 136 }
136 } 137 }
137 138
138 if (locale_file_path.empty()) { 139 if (locale_file_path.empty()) {
139 // It's possible that there is no locale.pak. 140 // It's possible that there is no locale.pak.
140 NOTREACHED(); 141 NOTREACHED();
141 return std::string(); 142 return std::string();
142 } 143 }
143 144
144 scoped_ptr<DataPack> data_pack(new DataPack()); 145 scoped_ptr<DataPack> data_pack(
146 new DataPack(ResourceHandle::kScaleFactor100x));
145 if (!data_pack->Load(locale_file_path)) { 147 if (!data_pack->Load(locale_file_path)) {
146 UMA_HISTOGRAM_ENUMERATION("ResourceBundle.LoadLocaleResourcesError", 148 UMA_HISTOGRAM_ENUMERATION("ResourceBundle.LoadLocaleResourcesError",
147 logging::GetLastSystemErrorCode(), 16000); 149 logging::GetLastSystemErrorCode(), 16000);
148 NOTREACHED() << "failed to load locale.pak"; 150 NOTREACHED() << "failed to load locale.pak";
149 return std::string(); 151 return std::string();
150 } 152 }
151 153
152 locale_resources_data_.reset(data_pack.release()); 154 locale_resources_data_.reset(data_pack.release());
153 return app_locale; 155 return app_locale;
154 } 156 }
155 157
156 void ResourceBundle::LoadTestResources(const FilePath& path) { 158 void ResourceBundle::LoadTestResources(const FilePath& path) {
157 // Use the given resource pak for both common and localized resources. 159 // Use the given resource pak for both common and localized resources.
158 scoped_ptr<DataPack> data_pack(new DataPack()); 160 scoped_ptr<DataPack> data_pack(
161 new DataPack(ResourceHandle::kScaleFactor100x));
159 if (data_pack->Load(path)) 162 if (data_pack->Load(path))
160 data_packs_.push_back(data_pack.release()); 163 data_packs_.push_back(data_pack.release());
161 164
162 data_pack.reset(new DataPack()); 165 data_pack.reset(new DataPack(ResourceHandle::kScaleFactor100x));
163 if (data_pack->Load(path)) 166 if (data_pack->Load(path))
164 locale_resources_data_.reset(data_pack.release()); 167 locale_resources_data_.reset(data_pack.release());
165 } 168 }
166 169
167 void ResourceBundle::UnloadLocaleResources() { 170 void ResourceBundle::UnloadLocaleResources() {
168 locale_resources_data_.reset(); 171 locale_resources_data_.reset();
169 } 172 }
170 173
171 string16 ResourceBundle::GetLocalizedString(int message_id) { 174 string16 ResourceBundle::GetLocalizedString(int message_id) {
172 // Ensure that ReloadLocaleResources() doesn't drop the resources while 175 // Ensure that ReloadLocaleResources() doesn't drop the resources while
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 SkBitmap* bitmap = new SkBitmap(); 406 SkBitmap* bitmap = new SkBitmap();
404 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32); 407 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32);
405 bitmap->allocPixels(); 408 bitmap->allocPixels();
406 bitmap->eraseARGB(255, 255, 0, 0); 409 bitmap->eraseARGB(255, 255, 0, 0);
407 empty_image = new gfx::Image(bitmap); 410 empty_image = new gfx::Image(bitmap);
408 } 411 }
409 return empty_image; 412 return empty_image;
410 } 413 }
411 414
412 } // namespace ui 415 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle.h ('k') | ui/base/resource/resource_bundle_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698