OLD | NEW |
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 "chrome/browser/task_manager/task_manager_resource_providers.h" | 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 prerender_manager->IsTabContentsPrerendering( | 190 prerender_manager->IsTabContentsPrerendering( |
191 tab_contents_->tab_contents()); | 191 tab_contents_->tab_contents()); |
192 } | 192 } |
193 | 193 |
194 TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const { | 194 TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const { |
195 return tab_contents_->tab_contents()->HostsExtension() ? EXTENSION : RENDERER; | 195 return tab_contents_->tab_contents()->HostsExtension() ? EXTENSION : RENDERER; |
196 } | 196 } |
197 | 197 |
198 string16 TaskManagerTabContentsResource::GetTitle() const { | 198 string16 TaskManagerTabContentsResource::GetTitle() const { |
199 // Fall back on the URL if there's no title. | 199 // Fall back on the URL if there's no title. |
200 string16 tab_title = tab_contents_->tab_contents()->GetTitle(); | 200 TabContents* contents = tab_contents_->tab_contents(); |
| 201 string16 tab_title = contents->GetTitle(); |
| 202 GURL url = contents->GetURL(); |
201 if (tab_title.empty()) { | 203 if (tab_title.empty()) { |
202 tab_title = UTF8ToUTF16(tab_contents_->tab_contents()->GetURL().spec()); | 204 tab_title = UTF8ToUTF16(url.spec()); |
203 // Force URL to be LTR. | 205 // Force URL to be LTR. |
204 tab_title = base::i18n::GetDisplayStringInLTRDirectionality(tab_title); | 206 tab_title = base::i18n::GetDisplayStringInLTRDirectionality(tab_title); |
205 } else { | 207 } else { |
206 // Since the tab_title will be concatenated with | 208 // Since the tab_title will be concatenated with |
207 // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to | 209 // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to |
208 // be LTR format if there is no strong RTL charater in it. Otherwise, if | 210 // be LTR format if there is no strong RTL charater in it. Otherwise, if |
209 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result | 211 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result |
210 // might be wrong. For example, http://mail.yahoo.com, whose title is | 212 // might be wrong. For example, http://mail.yahoo.com, whose title is |
211 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly | 213 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly |
212 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best | 214 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best |
213 // web-based Email :BAT", in which the capital letters "BAT" stands for | 215 // web-based Email :BAT", in which the capital letters "BAT" stands for |
214 // the Hebrew word for "tab". | 216 // the Hebrew word for "tab". |
215 base::i18n::AdjustStringForLocaleDirection(&tab_title); | 217 base::i18n::AdjustStringForLocaleDirection(&tab_title); |
216 } | 218 } |
217 | 219 |
| 220 // Only classify as an app if the URL is an app and the tab is hosting an |
| 221 // extension process. (It's possible to be showing the URL from before it |
| 222 // was installed as an app.) |
218 ExtensionService* extensions_service = | 223 ExtensionService* extensions_service = |
219 tab_contents_->profile()->GetExtensionService(); | 224 tab_contents_->profile()->GetExtensionService(); |
| 225 bool is_app = extensions_service->IsInstalledApp(url) && |
| 226 contents->GetRenderProcessHost()->is_extension_process(); |
220 | 227 |
221 int message_id = GetMessagePrefixID( | 228 int message_id = GetMessagePrefixID( |
222 extensions_service->IsInstalledApp( | 229 is_app, |
223 tab_contents_->tab_contents()->GetURL()), | 230 contents->HostsExtension(), |
224 tab_contents_->tab_contents()->HostsExtension(), | |
225 tab_contents_->profile()->IsOffTheRecord(), | 231 tab_contents_->profile()->IsOffTheRecord(), |
226 IsPrerendering()); | 232 IsPrerendering()); |
227 return l10n_util::GetStringFUTF16(message_id, tab_title); | 233 return l10n_util::GetStringFUTF16(message_id, tab_title); |
228 } | 234 } |
229 | 235 |
230 SkBitmap TaskManagerTabContentsResource::GetIcon() const { | 236 SkBitmap TaskManagerTabContentsResource::GetIcon() const { |
231 if (IsPrerendering()) | 237 if (IsPrerendering()) |
232 return *prerender_icon_; | 238 return *prerender_icon_; |
233 return tab_contents_->favicon_tab_helper()->GetFavicon(); | 239 return tab_contents_->favicon_tab_helper()->GetFavicon(); |
234 } | 240 } |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 | 1429 |
1424 return &resource_; | 1430 return &resource_; |
1425 } | 1431 } |
1426 | 1432 |
1427 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1433 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
1428 task_manager_->AddResource(&resource_); | 1434 task_manager_->AddResource(&resource_); |
1429 } | 1435 } |
1430 | 1436 |
1431 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1437 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
1432 } | 1438 } |
OLD | NEW |