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

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

Issue 2209363002: Remove material design resource pak infrastructure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove another mac test file Created 4 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
« no previous file with comments | « ui/base/resource/data_pack.cc ('k') | ui/base/resource/resource_bundle.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 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 5 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Same as above but using only a region (offset + size) of the file. 172 // Same as above but using only a region (offset + size) of the file.
173 void AddDataPackFromFileRegion(base::File file, 173 void AddDataPackFromFileRegion(base::File file,
174 const base::MemoryMappedFile::Region& region, 174 const base::MemoryMappedFile::Region& region,
175 ScaleFactor scale_factor); 175 ScaleFactor scale_factor);
176 176
177 // Same as AddDataPackFromPath but does not log an error if the pack fails to 177 // Same as AddDataPackFromPath but does not log an error if the pack fails to
178 // load. 178 // load.
179 void AddOptionalDataPackFromPath(const base::FilePath& path, 179 void AddOptionalDataPackFromPath(const base::FilePath& path,
180 ScaleFactor scale_factor); 180 ScaleFactor scale_factor);
181 181
182 // The same as AddDataPackFromPath() and AddOptionalDataPackFromPath(),
183 // except the data pack is flagged as containing only material design assets.
184 // TODO(tdanderson): These methods are temporary and should be removed after
185 // the transition to material design in the browser UI.
186 void AddMaterialDesignDataPackFromPath(const base::FilePath& path,
187 ScaleFactor scale_factor);
188 void AddOptionalMaterialDesignDataPackFromPath(const base::FilePath& path,
189 ScaleFactor scale_factor);
190
191 // Changes the locale for an already-initialized ResourceBundle, returning the 182 // Changes the locale for an already-initialized ResourceBundle, returning the
192 // name of the newly-loaded locale. Future calls to get strings will return 183 // name of the newly-loaded locale. Future calls to get strings will return
193 // the strings for this new locale. This has no effect on existing or future 184 // the strings for this new locale. This has no effect on existing or future
194 // image resources. |locale_resources_data_| is protected by a lock for the 185 // image resources. |locale_resources_data_| is protected by a lock for the
195 // duration of the swap, as GetLocalizedString() may be concurrently invoked 186 // duration of the swap, as GetLocalizedString() may be concurrently invoked
196 // on another thread. 187 // on another thread.
197 std::string ReloadLocaleResources(const std::string& pref_locale); 188 std::string ReloadLocaleResources(const std::string& pref_locale);
198 189
199 // Gets image with the specified resource_id from the current module data. 190 // Gets image with the specified resource_id from the current module data.
200 // Returns a pointer to a shared instance of gfx::ImageSkia. This shared 191 // Returns a pointer to a shared instance of gfx::ImageSkia. This shared
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // string if no locale data files are found and |test_file_exists| is true. 273 // string if no locale data files are found and |test_file_exists| is true.
283 // Used on Android to load the local file in the browser process and pass it 274 // Used on Android to load the local file in the browser process and pass it
284 // to the sandboxed renderer process. 275 // to the sandboxed renderer process.
285 base::FilePath GetLocaleFilePath(const std::string& app_locale, 276 base::FilePath GetLocaleFilePath(const std::string& app_locale,
286 bool test_file_exists); 277 bool test_file_exists);
287 278
288 // Returns the maximum scale factor currently loaded. 279 // Returns the maximum scale factor currently loaded.
289 // Returns SCALE_FACTOR_100P if no resource is loaded. 280 // Returns SCALE_FACTOR_100P if no resource is loaded.
290 ScaleFactor GetMaxScaleFactor() const; 281 ScaleFactor GetMaxScaleFactor() const;
291 282
292 #if defined(OS_MACOSX)
293 // Loads Material Design data packs and makes them the first items in
294 // |data_packs_|.
295 void LoadMaterialDesignResources();
296 #endif
297
298 // Returns true if |scale_factor| is supported by this platform. 283 // Returns true if |scale_factor| is supported by this platform.
299 static bool IsScaleFactorSupported(ScaleFactor scale_factor); 284 static bool IsScaleFactorSupported(ScaleFactor scale_factor);
300 285
301 private: 286 private:
302 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetPathForLocalePack); 287 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetPathForLocalePack);
303 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetImageNamed); 288 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetImageNamed);
304 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetNativeImageNamed); 289 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetNativeImageNamed);
305 FRIEND_TEST_ALL_PREFIXES(ResourceBundleImageTest,
306 CountMaterialDesignDataPacksInResourceBundle);
307 FRIEND_TEST_ALL_PREFIXES(ResourceBundleMacImageTest,
308 CheckImageFromMaterialDesign);
309 FRIEND_TEST_ALL_PREFIXES(ChromeBrowserMainMacBrowserTest,
310 MDResourceAccess);
311 290
312 friend class ResourceBundleMacImageTest; 291 friend class ResourceBundleMacImageTest;
313 friend class ResourceBundleImageTest; 292 friend class ResourceBundleImageTest;
314 friend class ResourceBundleTest; 293 friend class ResourceBundleTest;
315 friend class ChromeBrowserMainMacBrowserTest; 294 friend class ChromeBrowserMainMacBrowserTest;
316 295
317 class ResourceBundleImageSource; 296 class ResourceBundleImageSource;
318 friend class ResourceBundleImageSource; 297 friend class ResourceBundleImageSource;
319 298
320 struct FontKey; 299 struct FontKey;
321 300
322 typedef base::hash_map<int, base::string16> IdToStringMap; 301 typedef base::hash_map<int, base::string16> IdToStringMap;
323 302
324 // Ctor/dtor are private, since we're a singleton. 303 // Ctor/dtor are private, since we're a singleton.
325 explicit ResourceBundle(Delegate* delegate); 304 explicit ResourceBundle(Delegate* delegate);
326 ~ResourceBundle(); 305 ~ResourceBundle();
327 306
328 // Shared initialization. 307 // Shared initialization.
329 static void InitSharedInstance(Delegate* delegate); 308 static void InitSharedInstance(Delegate* delegate);
330 309
331 // Free skia_images_. 310 // Free skia_images_.
332 void FreeImages(); 311 void FreeImages();
333 312
334 // Load the main resources. 313 // Load the main resources.
335 void LoadCommonResources(); 314 void LoadCommonResources();
336 315
337 // Loads the resource paks chrome_{100,200}_percent.pak. Also loads the 316 // Loads the resource paks chrome_{100,200}_percent.pak.
338 // resource paks chrome_material_{100,200}_percent.pak contaning top
339 // chrome material design assets if the runtime flag is enabled.
340 void LoadChromeResources(); 317 void LoadChromeResources();
341 318
342 // Implementation for the public methods which add a DataPack from a path. If 319 // Implementation for the public methods which add a DataPack from a path. If
343 // |optional| is false, an error is logged on failure to load. Sets the 320 // |optional| is false, an error is logged on failure to load.
344 // member |has_only_material_design_assets_| on the created DataPack to the
345 // value of |has_only_material_assets|.
346 void AddDataPackFromPathInternal(const base::FilePath& path, 321 void AddDataPackFromPathInternal(const base::FilePath& path,
347 ScaleFactor scale_factor, 322 ScaleFactor scale_factor,
348 bool optional, 323 bool optional);
349 bool has_only_material_assets);
350 324
351 // Inserts |data_pack| to |data_pack_| and updates |max_scale_factor_| 325 // Inserts |data_pack| to |data_pack_| and updates |max_scale_factor_|
352 // accordingly. 326 // accordingly.
353 void AddDataPack(DataPack* data_pack); 327 void AddDataPack(DataPack* data_pack);
354 328
355 // Try to load the locale specific strings from an external data module. 329 // Try to load the locale specific strings from an external data module.
356 // Returns the locale that is loaded. 330 // Returns the locale that is loaded.
357 std::string LoadLocaleResources(const std::string& pref_locale); 331 std::string LoadLocaleResources(const std::string& pref_locale);
358 332
359 // Load test resources in given paths. If either path is empty an empty 333 // Load test resources in given paths. If either path is empty an empty
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 431
458 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); 432 DISALLOW_COPY_AND_ASSIGN(ResourceBundle);
459 }; 433 };
460 434
461 } // namespace ui 435 } // namespace ui
462 436
463 // TODO(beng): Someday, maybe, get rid of this. 437 // TODO(beng): Someday, maybe, get rid of this.
464 using ui::ResourceBundle; 438 using ui::ResourceBundle;
465 439
466 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 440 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
OLDNEW
« no previous file with comments | « ui/base/resource/data_pack.cc ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698