OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_management/providers/web_contents/renderer_task.h" | 5 #include "chrome/browser/task_management/providers/web_contents/renderer_task.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 renderer_resources_sampler_( | 71 renderer_resources_sampler_( |
72 CreateRendererResourcesSampler(render_process_host_)), | 72 CreateRendererResourcesSampler(render_process_host_)), |
73 render_process_id_(render_process_host_->GetID()), | 73 render_process_id_(render_process_host_->GetID()), |
74 v8_memory_allocated_(0), | 74 v8_memory_allocated_(0), |
75 v8_memory_used_(0), | 75 v8_memory_used_(0), |
76 webcache_stats_(), | 76 webcache_stats_(), |
77 profile_name_(GetRendererProfileName(render_process_host_)) { | 77 profile_name_(GetRendererProfileName(render_process_host_)) { |
78 // All renderer tasks are capable of reporting network usage, so the default | 78 // All renderer tasks are capable of reporting network usage, so the default |
79 // invalid value of -1 doesn't apply here. | 79 // invalid value of -1 doesn't apply here. |
80 OnNetworkBytesRead(0); | 80 OnNetworkBytesRead(0); |
| 81 |
| 82 // Tag the web_contents with a |ContentFaviconDriver| (if needed) so that |
| 83 // we can use it to observe favicons changes. |
| 84 favicon::CreateContentFaviconDriverForWebContents(web_contents); |
| 85 favicon::ContentFaviconDriver::FromWebContents(web_contents)->AddObserver( |
| 86 this); |
81 } | 87 } |
82 | 88 |
83 RendererTask::~RendererTask() { | 89 RendererTask::~RendererTask() { |
| 90 favicon::ContentFaviconDriver::FromWebContents(web_contents())-> |
| 91 RemoveObserver(this); |
84 } | 92 } |
85 | 93 |
86 void RendererTask::Activate() { | 94 void RendererTask::Activate() { |
87 if (!web_contents_->GetDelegate()) | 95 if (!web_contents_->GetDelegate()) |
88 return; | 96 return; |
89 | 97 |
90 web_contents_->GetDelegate()->ActivateContents(web_contents_); | 98 web_contents_->GetDelegate()->ActivateContents(web_contents_); |
91 } | 99 } |
92 | 100 |
93 void RendererTask::Refresh(const base::TimeDelta& update_interval, | 101 void RendererTask::Refresh(const base::TimeDelta& update_interval, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 139 } |
132 | 140 |
133 bool RendererTask::ReportsWebCacheStats() const { | 141 bool RendererTask::ReportsWebCacheStats() const { |
134 return true; | 142 return true; |
135 } | 143 } |
136 | 144 |
137 blink::WebCache::ResourceTypeStats RendererTask::GetWebCacheStats() const { | 145 blink::WebCache::ResourceTypeStats RendererTask::GetWebCacheStats() const { |
138 return webcache_stats_; | 146 return webcache_stats_; |
139 } | 147 } |
140 | 148 |
| 149 void RendererTask::OnFaviconAvailable(const gfx::Image& image) { |
| 150 } |
| 151 |
| 152 void RendererTask::OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, |
| 153 bool icon_url_changed) { |
| 154 UpdateFavicon(); |
| 155 } |
| 156 |
141 // static | 157 // static |
142 base::string16 RendererTask::GetTitleFromWebContents( | 158 base::string16 RendererTask::GetTitleFromWebContents( |
143 content::WebContents* web_contents) { | 159 content::WebContents* web_contents) { |
144 DCHECK(web_contents); | 160 DCHECK(web_contents); |
145 base::string16 title = web_contents->GetTitle(); | 161 base::string16 title = web_contents->GetTitle(); |
146 if (title.empty()) { | 162 if (title.empty()) { |
147 GURL url = web_contents->GetURL(); | 163 GURL url = web_contents->GetURL(); |
148 title = base::UTF8ToUTF16(url.spec()); | 164 title = base::UTF8ToUTF16(url.spec()); |
149 // Force URL to be LTR. | 165 // Force URL to be LTR. |
150 title = base::i18n::GetDisplayStringInLTRDirectionality(title); | 166 title = base::i18n::GetDisplayStringInLTRDirectionality(title); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (is_incognito) | 218 if (is_incognito) |
203 message_id = IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; | 219 message_id = IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; |
204 else | 220 else |
205 message_id = IDS_TASK_MANAGER_EXTENSION_PREFIX; | 221 message_id = IDS_TASK_MANAGER_EXTENSION_PREFIX; |
206 } | 222 } |
207 | 223 |
208 return l10n_util::GetStringFUTF16(message_id, title); | 224 return l10n_util::GetStringFUTF16(message_id, title); |
209 } | 225 } |
210 | 226 |
211 } // namespace task_management | 227 } // namespace task_management |
OLD | NEW |