Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 // be LTR format if there is no strong RTL charater in it. Otherwise, if | 307 // be LTR format if there is no strong RTL charater in it. Otherwise, if |
| 308 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result | 308 // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result |
| 309 // might be wrong. For example, http://mail.yahoo.com, whose title is | 309 // might be wrong. For example, http://mail.yahoo.com, whose title is |
| 310 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly | 310 // "Yahoo! Mail: The best web-based Email!", without setting it explicitly |
| 311 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best | 311 // as LTR format, the concatenated result will be "!Yahoo! Mail: The best |
| 312 // web-based Email :BAT", in which the capital letters "BAT" stands for | 312 // web-based Email :BAT", in which the capital letters "BAT" stands for |
| 313 // the Hebrew word for "tab". | 313 // the Hebrew word for "tab". |
| 314 base::i18n::AdjustStringForLocaleDirection(&tab_title); | 314 base::i18n::AdjustStringForLocaleDirection(&tab_title); |
| 315 } | 315 } |
| 316 | 316 |
| 317 // Only classify as an app if the URL is an app and the tab is hosting an | |
| 318 // extension process. (It's possible to be showing the URL from before it | |
| 319 // was installed as an app.) | |
| 320 ExtensionService* extension_service = | |
| 321 tab_contents_->profile()->GetExtensionService(); | |
| 322 extensions::ProcessMap* process_map = extension_service->process_map(); | |
| 323 bool is_app = extension_service->IsInstalledApp(url) && | |
| 324 process_map->Contains(contents->GetRenderProcessHost()->GetID()); | |
| 325 | |
| 326 int message_id = GetMessagePrefixID( | 317 int message_id = GetMessagePrefixID( |
| 327 is_app, | 318 false, // (is_app) Apps do not have TabContents |
| 328 HostsExtension(), | 319 HostsExtension(), |
| 329 tab_contents_->profile()->IsOffTheRecord(), | 320 tab_contents_->profile()->IsOffTheRecord(), |
| 330 IsPrerendering(), | 321 IsPrerendering(), |
| 331 is_instant_preview_, | 322 is_instant_preview_, |
| 332 false); | 323 false); |
| 333 return l10n_util::GetStringFUTF16(message_id, tab_title); | 324 return l10n_util::GetStringFUTF16(message_id, tab_title); |
| 334 } | 325 } |
| 335 | 326 |
| 336 string16 TaskManagerTabContentsResource::GetProfileName() const { | 327 string16 TaskManagerTabContentsResource::GetProfileName() const { |
| 337 return GetProfileNameFromInfoCache(tab_contents_->profile()); | 328 return GetProfileNameFromInfoCache(tab_contents_->profile()); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 std::map<TabContents*, TaskManagerTabContentsResource*>::iterator | 486 std::map<TabContents*, TaskManagerTabContentsResource*>::iterator |
| 496 iter = resources_.find(tab_contents); | 487 iter = resources_.find(tab_contents); |
| 497 DCHECK(iter != resources_.end()); | 488 DCHECK(iter != resources_.end()); |
| 498 if (iter != resources_.end()) | 489 if (iter != resources_.end()) |
| 499 iter->second->InstantCommitted(); | 490 iter->second->InstantCommitted(); |
| 500 } | 491 } |
| 501 | 492 |
| 502 void TaskManagerTabContentsResourceProvider::Observe(int type, | 493 void TaskManagerTabContentsResourceProvider::Observe(int type, |
| 503 const content::NotificationSource& source, | 494 const content::NotificationSource& source, |
| 504 const content::NotificationDetails& details) { | 495 const content::NotificationDetails& details) { |
| 505 TabContents* tab_contents; | 496 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
| 506 tab_contents = TabContents::FromWebContents( | 497 TabContents* tab_contents = TabContents::FromWebContents(web_contents); |
| 507 content::Source<WebContents>(source).ptr()); | |
| 508 // A background page does not have a TabContents. | 498 // A background page does not have a TabContents. |
| 509 if (!tab_contents) | 499 if (!tab_contents) |
| 510 return; | 500 return; |
| 501 | |
| 502 // Only classify as an app if the URL is an app and the tab is hosting an | |
| 503 // extension process. (It's possible to be showing the URL from before it | |
| 504 // was installed as an app.) | |
| 505 ExtensionService* extension_service = | |
| 506 tab_contents->profile()->GetExtensionService(); | |
| 507 extensions::ProcessMap* process_map = extension_service->process_map(); | |
| 508 bool is_app = extension_service->IsInstalledApp(web_contents->GetURL()) && | |
| 509 process_map->Contains(web_contents->GetRenderProcessHost()->GetID()); | |
|
benwells
2012/10/17 05:59:49
I don't think this will work with old style packag
| |
| 510 if (is_app) | |
| 511 return; | |
| 512 | |
| 511 switch (type) { | 513 switch (type) { |
| 512 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: | 514 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: |
| 513 Add(tab_contents); | 515 Add(tab_contents); |
| 514 break; | 516 break; |
| 515 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: | 517 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: |
| 516 Remove(tab_contents); | 518 Remove(tab_contents); |
| 517 Add(tab_contents); | 519 Add(tab_contents); |
| 518 break; | 520 break; |
| 519 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: | 521 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: |
| 520 Remove(tab_contents); | 522 Remove(tab_contents); |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1683 | 1685 |
| 1684 return &resource_; | 1686 return &resource_; |
| 1685 } | 1687 } |
| 1686 | 1688 |
| 1687 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1689 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
| 1688 task_manager_->AddResource(&resource_); | 1690 task_manager_->AddResource(&resource_); |
| 1689 } | 1691 } |
| 1690 | 1692 |
| 1691 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1693 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
| 1692 } | 1694 } |
| OLD | NEW |