| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_resource_providers.h" | 5 #include "chrome/browser/task_manager_resource_providers.h" |
| 6 | 6 |
| 7 #include "base/file_version_info.h" | 7 #include "base/file_version_info.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 std::wstring TaskManagerWebContentsResource::GetTitle() const { | 43 std::wstring TaskManagerWebContentsResource::GetTitle() const { |
| 44 // GetTitle() and GetURL() can only be invoked when the WebContents has a | 44 // GetTitle() and GetURL() can only be invoked when the WebContents has a |
| 45 // controller. | 45 // controller. |
| 46 if (!web_contents_->controller()) | 46 if (!web_contents_->controller()) |
| 47 return std::wstring(); | 47 return std::wstring(); |
| 48 | 48 |
| 49 // Fall back on the URL if there's no title. | 49 // Fall back on the URL if there's no title. |
| 50 std::wstring tab_title(web_contents_->GetTitle()); | 50 std::wstring tab_title(web_contents_->GetTitle()); |
| 51 if (tab_title.empty()) | 51 if (tab_title.empty()) { |
| 52 tab_title = UTF8ToWide(web_contents_->GetURL().spec()); | 52 tab_title = UTF8ToWide(web_contents_->GetURL().spec()); |
| 53 // Force URL to be LTR. |
| 54 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) |
| 55 l10n_util::WrapStringWithLTRFormatting(&tab_title); |
| 56 } else { |
| 57 // Since the tab_title will be concatenated with |
| 58 // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to |
| 59 // be LTR format if there is no strong RTL charater in it. Otherwise, if |
| 60 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result |
| 61 // might be wrong. For example, http://mail.yahoo.com, whose title is |
| 62 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly |
| 63 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best |
| 64 // web-based Email :BAT", in which the capital letters "BAT" stands for |
| 65 // the Hebrew word for "tab". |
| 66 l10n_util::AdjustStringForLocaleDirection(tab_title, &tab_title); |
| 67 } |
| 53 | 68 |
| 54 return l10n_util::GetStringF(IDS_TASK_MANAGER_TAB_PREFIX, tab_title); | 69 return l10n_util::GetStringF(IDS_TASK_MANAGER_TAB_PREFIX, tab_title); |
| 55 } | 70 } |
| 56 | 71 |
| 57 SkBitmap TaskManagerWebContentsResource::GetIcon() const { | 72 SkBitmap TaskManagerWebContentsResource::GetIcon() const { |
| 58 return web_contents_->GetFavIcon(); | 73 return web_contents_->GetFavIcon(); |
| 59 } | 74 } |
| 60 | 75 |
| 61 HANDLE TaskManagerWebContentsResource::GetProcess() const { | 76 HANDLE TaskManagerWebContentsResource::GetProcess() const { |
| 62 return process_; | 77 return process_; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // TaskManagerResource methods: | 261 // TaskManagerResource methods: |
| 247 std::wstring TaskManagerPluginProcessResource::GetTitle() const { | 262 std::wstring TaskManagerPluginProcessResource::GetTitle() const { |
| 248 if (title_.empty()) { | 263 if (title_.empty()) { |
| 249 std::wstring plugin_name; | 264 std::wstring plugin_name; |
| 250 WebPluginInfo info; | 265 WebPluginInfo info; |
| 251 if (PluginService::GetInstance()-> | 266 if (PluginService::GetInstance()-> |
| 252 GetPluginInfoByPath(plugin_process_.plugin_path(), &info)) | 267 GetPluginInfoByPath(plugin_process_.plugin_path(), &info)) |
| 253 plugin_name = info.name; | 268 plugin_name = info.name; |
| 254 else | 269 else |
| 255 plugin_name = l10n_util::GetString(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME); | 270 plugin_name = l10n_util::GetString(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME); |
| 271 // Explicitly mark plugin_name as LTR if there is no strong RTL character, |
| 272 // to avoid the wrong concatenation result similar to "!Yahoo! Mail: the |
| 273 // best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew |
| 274 // or Arabic word for "plugin". |
| 275 l10n_util::AdjustStringForLocaleDirection(plugin_name, &plugin_name); |
| 256 title_ = l10n_util::GetStringF(IDS_TASK_MANAGER_PLUGIN_PREFIX, | 276 title_ = l10n_util::GetStringF(IDS_TASK_MANAGER_PLUGIN_PREFIX, |
| 257 plugin_name); | 277 plugin_name); |
| 258 } | 278 } |
| 259 return title_; | 279 return title_; |
| 260 } | 280 } |
| 261 | 281 |
| 262 SkBitmap TaskManagerPluginProcessResource::GetIcon() const { | 282 SkBitmap TaskManagerPluginProcessResource::GetIcon() const { |
| 263 return *default_icon_; | 283 return *default_icon_; |
| 264 } | 284 } |
| 265 | 285 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 } | 519 } |
| 500 | 520 |
| 501 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 521 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
| 502 task_manager_->AddResource(&resource_); | 522 task_manager_->AddResource(&resource_); |
| 503 } | 523 } |
| 504 | 524 |
| 505 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 525 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
| 506 } | 526 } |
| 507 | 527 |
| 508 | 528 |
| OLD | NEW |