OLD | NEW |
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 Loading... |
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 string16 tab_title = tab_contents_->GetTitle(); | 174 std::wstring tab_title(UTF16ToWideHack(tab_contents_->GetTitle())); |
175 if (tab_title.empty()) { | 175 if (tab_title.empty()) { |
176 tab_title = UTF8ToUTF16(tab_contents_->GetURL().spec()); | 176 tab_title = UTF8ToWide(tab_contents_->GetURL().spec()); |
177 // Force URL to be LTR. | 177 // Force URL to be LTR. |
178 tab_title = base::i18n::GetDisplayStringInLTRDirectionality(tab_title); | 178 tab_title = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( |
| 179 WideToUTF16(tab_title))); |
179 } else { | 180 } else { |
180 // Since the tab_title will be concatenated with | 181 // Since the tab_title will be concatenated with |
181 // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to | 182 // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to |
182 // be LTR format if there is no strong RTL charater in it. Otherwise, if | 183 // be LTR format if there is no strong RTL charater in it. Otherwise, if |
183 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result | 184 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result |
184 // might be wrong. For example, http://mail.yahoo.com, whose title is | 185 // might be wrong. For example, http://mail.yahoo.com, whose title is |
185 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly | 186 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly |
186 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best | 187 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best |
187 // web-based Email :BAT", in which the capital letters "BAT" stands for | 188 // web-based Email :BAT", in which the capital letters "BAT" stands for |
188 // the Hebrew word for "tab". | 189 // the Hebrew word for "tab". |
189 base::i18n::AdjustStringForLocaleDirection(&tab_title); | 190 base::i18n::AdjustStringForLocaleDirection(&tab_title); |
190 } | 191 } |
191 | 192 |
192 ExtensionService* extensions_service = | 193 ExtensionService* extensions_service = |
193 tab_contents_->profile()->GetExtensionService(); | 194 tab_contents_->profile()->GetExtensionService(); |
194 int message_id = GetMessagePrefixID( | 195 int message_id = GetMessagePrefixID( |
195 extensions_service->IsInstalledApp(tab_contents_->GetURL()), | 196 extensions_service->IsInstalledApp(tab_contents_->GetURL()), |
196 tab_contents_->HostsExtension(), | 197 tab_contents_->HostsExtension(), |
197 tab_contents_->profile()->IsOffTheRecord()); | 198 tab_contents_->profile()->IsOffTheRecord()); |
198 return UTF16ToWideHack(l10n_util::GetStringFUTF16(message_id, tab_title)); | 199 return l10n_util::GetStringF(message_id, tab_title); |
199 } | 200 } |
200 | 201 |
201 SkBitmap TaskManagerTabContentsResource::GetIcon() const { | 202 SkBitmap TaskManagerTabContentsResource::GetIcon() const { |
202 return tab_contents_->GetFavIcon(); | 203 return tab_contents_->GetFavIcon(); |
203 } | 204 } |
204 | 205 |
205 TabContents* TaskManagerTabContentsResource::GetTabContents() const { | 206 TabContents* TaskManagerTabContentsResource::GetTabContents() const { |
206 return static_cast<TabContents*>(tab_contents_); | 207 return static_cast<TabContents*>(tab_contents_); |
207 } | 208 } |
208 | 209 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // Ensure that the string has the appropriate direction markers (see comment | 408 // Ensure that the string has the appropriate direction markers (see comment |
408 // in TaskManagerTabContentsResource::GetTitle()). | 409 // in TaskManagerTabContentsResource::GetTitle()). |
409 base::i18n::AdjustStringForLocaleDirection(&application_name_); | 410 base::i18n::AdjustStringForLocaleDirection(&application_name_); |
410 } | 411 } |
411 | 412 |
412 TaskManagerBackgroundContentsResource::~TaskManagerBackgroundContentsResource( | 413 TaskManagerBackgroundContentsResource::~TaskManagerBackgroundContentsResource( |
413 ) { | 414 ) { |
414 } | 415 } |
415 | 416 |
416 std::wstring TaskManagerBackgroundContentsResource::GetTitle() const { | 417 std::wstring TaskManagerBackgroundContentsResource::GetTitle() const { |
417 string16 title = WideToUTF16Hack(application_name_); | 418 std::wstring title = application_name_; |
418 | 419 |
419 if (title.empty()) { | 420 if (title.empty()) { |
420 // No title (can't locate the parent app for some reason) so just display | 421 // No title (can't locate the parent app for some reason) so just display |
421 // the URL (properly forced to be LTR). | 422 // the URL (properly forced to be LTR). |
422 title = base::i18n::GetDisplayStringInLTRDirectionality( | 423 title = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( |
423 UTF8ToUTF16(background_contents_->GetURL().spec())); | 424 UTF8ToUTF16(background_contents_->GetURL().spec()))); |
424 } | 425 } |
425 return UTF16ToWideHack( | 426 return l10n_util::GetStringF(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title); |
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 Loading... |
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 string16 extension_name = UTF8ToUTF16(GetExtension()->name()); | 884 std::wstring extension_name(UTF8ToWide(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_ = UTF16ToWideHack(l10n_util::GetStringFUTF16(message_id, | 889 title_ = l10n_util::GetStringF(message_id, extension_name); |
890 extension_name)); | |
891 } | 890 } |
892 | 891 |
893 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { | 892 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { |
894 } | 893 } |
895 | 894 |
896 std::wstring TaskManagerExtensionProcessResource::GetTitle() const { | 895 std::wstring TaskManagerExtensionProcessResource::GetTitle() const { |
897 return title_; | 896 return title_; |
898 } | 897 } |
899 | 898 |
900 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const { | 899 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const { |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 #endif // defined(OS_WIN) | 1256 #endif // defined(OS_WIN) |
1258 } | 1257 } |
1259 | 1258 |
1260 TaskManagerBrowserProcessResource::~TaskManagerBrowserProcessResource() { | 1259 TaskManagerBrowserProcessResource::~TaskManagerBrowserProcessResource() { |
1261 base::CloseProcessHandle(process_); | 1260 base::CloseProcessHandle(process_); |
1262 } | 1261 } |
1263 | 1262 |
1264 // TaskManagerResource methods: | 1263 // TaskManagerResource methods: |
1265 std::wstring TaskManagerBrowserProcessResource::GetTitle() const { | 1264 std::wstring TaskManagerBrowserProcessResource::GetTitle() const { |
1266 if (title_.empty()) { | 1265 if (title_.empty()) { |
1267 title_ = UTF16ToWideHack( | 1266 title_ = l10n_util::GetString(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT); |
1268 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT)); | |
1269 } | 1267 } |
1270 return title_; | 1268 return title_; |
1271 } | 1269 } |
1272 | 1270 |
1273 SkBitmap TaskManagerBrowserProcessResource::GetIcon() const { | 1271 SkBitmap TaskManagerBrowserProcessResource::GetIcon() const { |
1274 return *default_icon_; | 1272 return *default_icon_; |
1275 } | 1273 } |
1276 | 1274 |
1277 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const { | 1275 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const { |
1278 return static_cast<size_t>(sqlite3_memory_used()); | 1276 return static_cast<size_t>(sqlite3_memory_used()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 | 1320 |
1323 return &resource_; | 1321 return &resource_; |
1324 } | 1322 } |
1325 | 1323 |
1326 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1324 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
1327 task_manager_->AddResource(&resource_); | 1325 task_manager_->AddResource(&resource_); |
1328 } | 1326 } |
1329 | 1327 |
1330 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1328 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
1331 } | 1329 } |
OLD | NEW |