Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / task_management / providers / web_contents / prerender_task.cc
blob616edad1d750b0050b169a2993daae6cfdd8c16c
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 {
16 namespace {
18 gfx::ImageSkia* g_prerender_icon = nullptr;
20 // Returns the prerender icon or |nullptr| if the |ResourceBundle| is not ready
21 // yet.
22 gfx::ImageSkia* GetPrerenderIcon() {
23 if (g_prerender_icon)
24 return g_prerender_icon;
26 if (!ResourceBundle::HasSharedInstance())
27 return nullptr;
29 g_prerender_icon =
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);
38 } // namespace
40 PrerenderTask::PrerenderTask(content::WebContents* web_contents)
41 : RendererTask(
42 PrefixTitle(RendererTask::GetTitleFromWebContents(web_contents)),
43 GetPrerenderIcon(),
44 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
58 // this event.
61 } // namespace task_management