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

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

Issue 7033022: Adding support for loading custom locale resources using a command line flag (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixing alignment Created 9 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 | « base/base_switches.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/file_path.h"
7 #include "base/logging.h" 10 #include "base/logging.h"
8 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
9 #include "base/string16.h" 12 #include "base/string16.h"
10 #include "base/string_piece.h" 13 #include "base/string_piece.h"
11 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
12 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/resource/data_pack.h" 16 #include "ui/base/resource/data_pack.h"
14 #include "ui/gfx/font.h" 17 #include "ui/gfx/font.h"
15 18
16 namespace ui { 19 namespace ui {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 LoadResourcesDataPak(large_icon_resources_file_path); 108 LoadResourcesDataPak(large_icon_resources_file_path);
106 CHECK(large_icon_resources_data_) << 109 CHECK(large_icon_resources_data_) <<
107 "failed to load theme_resources_large.pak"; 110 "failed to load theme_resources_large.pak";
108 } 111 }
109 } 112 }
110 113
111 std::string ResourceBundle::LoadLocaleResources( 114 std::string ResourceBundle::LoadLocaleResources(
112 const std::string& pref_locale) { 115 const std::string& pref_locale) {
113 DCHECK(!locale_resources_data_) << "locale.pak already loaded"; 116 DCHECK(!locale_resources_data_) << "locale.pak already loaded";
114 std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); 117 std::string app_locale = l10n_util::GetApplicationLocale(pref_locale);
115 FilePath locale_file_path = GetLocaleFilePath(app_locale); 118 FilePath locale_file_path;
119 CommandLine *command_line = CommandLine::ForCurrentProcess();
120 if (command_line->HasSwitch(switches::kLocalePak)) {
121 locale_file_path =
122 command_line->GetSwitchValuePath(switches::kLocalePak);
123 } else {
124 locale_file_path = GetLocaleFilePath(app_locale);
125 }
116 if (locale_file_path.empty()) { 126 if (locale_file_path.empty()) {
117 // It's possible that there is no locale.pak. 127 // It's possible that there is no locale.pak.
118 NOTREACHED(); 128 NOTREACHED();
119 return std::string(); 129 return std::string();
120 } 130 }
121 locale_resources_data_ = LoadResourcesDataPak(locale_file_path); 131 locale_resources_data_ = LoadResourcesDataPak(locale_file_path);
122 CHECK(locale_resources_data_) << "failed to load locale.pak"; 132 CHECK(locale_resources_data_) << "failed to load locale.pak";
123 return app_locale; 133 return app_locale;
124 } 134 }
125 135
126 void ResourceBundle::LoadTestResources(const FilePath& path) { 136 void ResourceBundle::LoadTestResources(const FilePath& path) {
127 DCHECK(!resources_data_) << "resource already loaded"; 137 DCHECK(!resources_data_) << "resource already loaded";
128 138
129 // Use the given resource pak for both common and localized resources. 139 // Use the given resource pak for both common and localized resources.
130 resources_data_ = LoadResourcesDataPak(path); 140 resources_data_ = LoadResourcesDataPak(path);
131 locale_resources_data_ = LoadResourcesDataPak(path); 141 locale_resources_data_ = LoadResourcesDataPak(path);
132 } 142 }
133 143
134 } // namespace ui 144 } // namespace ui
OLDNEW
« no previous file with comments | « base/base_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698