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
3 // found in the LICENSE file.
5 #include "chrome/browser/task_management/providers/web_contents/prerender_task.h"
7 #include "chrome/grit/generated_resources.h"
8 #include "content/public/browser/web_contents.h"
9 #include "grit/theme_resources.h"
10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/image/image_skia.h"
14 namespace task_management
{
18 gfx::ImageSkia
* g_prerender_icon
= nullptr;
20 // Returns the prerender icon or |nullptr| if the |ResourceBundle| is not ready
22 gfx::ImageSkia
* GetPrerenderIcon() {
24 return g_prerender_icon
;
26 if (!ResourceBundle::HasSharedInstance())
30 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_PRERENDER
);
31 return g_prerender_icon
;
34 base::string16
PrefixTitle(const base::string16
& title
) {
35 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX
, title
);
40 PrerenderTask::PrerenderTask(content::WebContents
* web_contents
)
42 PrefixTitle(RendererTask::GetTitleFromWebContents(web_contents
)),
45 web_contents
->GetRenderProcessHost()) {
48 PrerenderTask::~PrerenderTask() {
51 void PrerenderTask::OnTitleChanged(content::NavigationEntry
* entry
) {
52 // As long as this task lives we keep prefixing its title with "Prerender:".
53 set_title(PrefixTitle(RendererTask::GetTitleFromWebContents(web_contents())));
56 void PrerenderTask::OnFaviconChanged() {
57 // As long as this task lives we keep using the prerender icon, so we ignore
61 } // namespace task_management