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

Side by Side Diff: chrome/browser/task_manager/task_manager_resource_providers.cc

Issue 5989012: Revert 70281 - Revert 70271 - Remove wstring from l10n_util. Part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 12 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
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/task_manager/task_manager_resource_providers.h" 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 TaskManagerTabContentsResource::~TaskManagerTabContentsResource() { 165 TaskManagerTabContentsResource::~TaskManagerTabContentsResource() {
166 } 166 }
167 167
168 TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const { 168 TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const {
169 return tab_contents_->HostsExtension() ? EXTENSION : RENDERER; 169 return tab_contents_->HostsExtension() ? EXTENSION : RENDERER;
170 } 170 }
171 171
172 std::wstring TaskManagerTabContentsResource::GetTitle() const { 172 std::wstring TaskManagerTabContentsResource::GetTitle() const {
173 // Fall back on the URL if there's no title. 173 // Fall back on the URL if there's no title.
174 std::wstring tab_title(UTF16ToWideHack(tab_contents_->GetTitle())); 174 string16 tab_title = tab_contents_->GetTitle();
175 if (tab_title.empty()) { 175 if (tab_title.empty()) {
176 tab_title = UTF8ToWide(tab_contents_->GetURL().spec()); 176 tab_title = UTF8ToUTF16(tab_contents_->GetURL().spec());
177 // Force URL to be LTR. 177 // Force URL to be LTR.
178 tab_title = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( 178 tab_title = base::i18n::GetDisplayStringInLTRDirectionality(tab_title);
179 WideToUTF16(tab_title)));
180 } else { 179 } else {
181 // Since the tab_title will be concatenated with 180 // Since the tab_title will be concatenated with
182 // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to 181 // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to
183 // be LTR format if there is no strong RTL charater in it. Otherwise, if 182 // be LTR format if there is no strong RTL charater in it. Otherwise, if
184 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result 183 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result
185 // might be wrong. For example, http://mail.yahoo.com, whose title is 184 // might be wrong. For example, http://mail.yahoo.com, whose title is
186 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly 185 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly
187 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best 186 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best
188 // web-based Email :BAT", in which the capital letters "BAT" stands for 187 // web-based Email :BAT", in which the capital letters "BAT" stands for
189 // the Hebrew word for "tab". 188 // the Hebrew word for "tab".
190 base::i18n::AdjustStringForLocaleDirection(&tab_title); 189 base::i18n::AdjustStringForLocaleDirection(&tab_title);
191 } 190 }
192 191
193 ExtensionService* extensions_service = 192 ExtensionService* extensions_service =
194 tab_contents_->profile()->GetExtensionService(); 193 tab_contents_->profile()->GetExtensionService();
195 int message_id = GetMessagePrefixID( 194 int message_id = GetMessagePrefixID(
196 extensions_service->IsInstalledApp(tab_contents_->GetURL()), 195 extensions_service->IsInstalledApp(tab_contents_->GetURL()),
197 tab_contents_->HostsExtension(), 196 tab_contents_->HostsExtension(),
198 tab_contents_->profile()->IsOffTheRecord()); 197 tab_contents_->profile()->IsOffTheRecord());
199 return l10n_util::GetStringF(message_id, tab_title); 198 return UTF16ToWideHack(l10n_util::GetStringFUTF16(message_id, tab_title));
200 } 199 }
201 200
202 SkBitmap TaskManagerTabContentsResource::GetIcon() const { 201 SkBitmap TaskManagerTabContentsResource::GetIcon() const {
203 return tab_contents_->GetFavIcon(); 202 return tab_contents_->GetFavIcon();
204 } 203 }
205 204
206 TabContents* TaskManagerTabContentsResource::GetTabContents() const { 205 TabContents* TaskManagerTabContentsResource::GetTabContents() const {
207 return static_cast<TabContents*>(tab_contents_); 206 return static_cast<TabContents*>(tab_contents_);
208 } 207 }
209 208
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // Ensure that the string has the appropriate direction markers (see comment 407 // Ensure that the string has the appropriate direction markers (see comment
409 // in TaskManagerTabContentsResource::GetTitle()). 408 // in TaskManagerTabContentsResource::GetTitle()).
410 base::i18n::AdjustStringForLocaleDirection(&application_name_); 409 base::i18n::AdjustStringForLocaleDirection(&application_name_);
411 } 410 }
412 411
413 TaskManagerBackgroundContentsResource::~TaskManagerBackgroundContentsResource( 412 TaskManagerBackgroundContentsResource::~TaskManagerBackgroundContentsResource(
414 ) { 413 ) {
415 } 414 }
416 415
417 std::wstring TaskManagerBackgroundContentsResource::GetTitle() const { 416 std::wstring TaskManagerBackgroundContentsResource::GetTitle() const {
418 std::wstring title = application_name_; 417 string16 title = WideToUTF16Hack(application_name_);
419 418
420 if (title.empty()) { 419 if (title.empty()) {
421 // No title (can't locate the parent app for some reason) so just display 420 // No title (can't locate the parent app for some reason) so just display
422 // the URL (properly forced to be LTR). 421 // the URL (properly forced to be LTR).
423 title = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( 422 title = base::i18n::GetDisplayStringInLTRDirectionality(
424 UTF8ToUTF16(background_contents_->GetURL().spec()))); 423 UTF8ToUTF16(background_contents_->GetURL().spec()));
425 } 424 }
426 return l10n_util::GetStringF(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title); 425 return UTF16ToWideHack(
426 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title));
427 } 427 }
428 428
429 429
430 SkBitmap TaskManagerBackgroundContentsResource::GetIcon() const { 430 SkBitmap TaskManagerBackgroundContentsResource::GetIcon() const {
431 return *default_icon_; 431 return *default_icon_;
432 } 432 }
433 433
434 bool TaskManagerBackgroundContentsResource::IsBackground() const { 434 bool TaskManagerBackgroundContentsResource::IsBackground() const {
435 return true; 435 return true;
436 } 436 }
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 874
875 TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( 875 TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource(
876 ExtensionHost* extension_host) 876 ExtensionHost* extension_host)
877 : extension_host_(extension_host) { 877 : extension_host_(extension_host) {
878 if (!default_icon_) { 878 if (!default_icon_) {
879 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 879 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
880 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); 880 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN);
881 } 881 }
882 process_handle_ = extension_host_->render_process_host()->GetHandle(); 882 process_handle_ = extension_host_->render_process_host()->GetHandle();
883 pid_ = base::GetProcId(process_handle_); 883 pid_ = base::GetProcId(process_handle_);
884 std::wstring extension_name(UTF8ToWide(GetExtension()->name())); 884 string16 extension_name = UTF8ToUTF16(GetExtension()->name());
885 DCHECK(!extension_name.empty()); 885 DCHECK(!extension_name.empty());
886 886
887 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, 887 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true,
888 extension_host_->profile()->IsOffTheRecord()); 888 extension_host_->profile()->IsOffTheRecord());
889 title_ = l10n_util::GetStringF(message_id, extension_name); 889 title_ = UTF16ToWideHack(l10n_util::GetStringFUTF16(message_id,
890 extension_name));
890 } 891 }
891 892
892 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { 893 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() {
893 } 894 }
894 895
895 std::wstring TaskManagerExtensionProcessResource::GetTitle() const { 896 std::wstring TaskManagerExtensionProcessResource::GetTitle() const {
896 return title_; 897 return title_;
897 } 898 }
898 899
899 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const { 900 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 #endif // defined(OS_WIN) 1257 #endif // defined(OS_WIN)
1257 } 1258 }
1258 1259
1259 TaskManagerBrowserProcessResource::~TaskManagerBrowserProcessResource() { 1260 TaskManagerBrowserProcessResource::~TaskManagerBrowserProcessResource() {
1260 base::CloseProcessHandle(process_); 1261 base::CloseProcessHandle(process_);
1261 } 1262 }
1262 1263
1263 // TaskManagerResource methods: 1264 // TaskManagerResource methods:
1264 std::wstring TaskManagerBrowserProcessResource::GetTitle() const { 1265 std::wstring TaskManagerBrowserProcessResource::GetTitle() const {
1265 if (title_.empty()) { 1266 if (title_.empty()) {
1266 title_ = l10n_util::GetString(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT); 1267 title_ = UTF16ToWideHack(
1268 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT));
1267 } 1269 }
1268 return title_; 1270 return title_;
1269 } 1271 }
1270 1272
1271 SkBitmap TaskManagerBrowserProcessResource::GetIcon() const { 1273 SkBitmap TaskManagerBrowserProcessResource::GetIcon() const {
1272 return *default_icon_; 1274 return *default_icon_;
1273 } 1275 }
1274 1276
1275 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const { 1277 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const {
1276 return static_cast<size_t>(sqlite3_memory_used()); 1278 return static_cast<size_t>(sqlite3_memory_used());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 1322
1321 return &resource_; 1323 return &resource_;
1322 } 1324 }
1323 1325
1324 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { 1326 void TaskManagerBrowserProcessResourceProvider::StartUpdating() {
1325 task_manager_->AddResource(&resource_); 1327 task_manager_->AddResource(&resource_);
1326 } 1328 }
1327 1329
1328 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { 1330 void TaskManagerBrowserProcessResourceProvider::StopUpdating() {
1329 } 1331 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_browsertest.cc ('k') | chrome/browser/ui/app_modal_dialogs/message_box_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698