Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / task_management / providers / web_contents / extension_task.cc
bloba63781a20de87823ad8deef3d4ab707e2676cd8a
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/extension_task.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/web_contents.h"
10 #include "extensions/browser/view_type_utils.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/view_type.h"
13 #include "grit/theme_resources.h"
14 #include "ui/base/resource/resource_bundle.h"
16 namespace task_management {
18 namespace {
20 gfx::ImageSkia* g_default_icon = nullptr;
22 gfx::ImageSkia* GetDefaultIcon() {
23 if (!ResourceBundle::HasSharedInstance())
24 return nullptr;
26 if (!g_default_icon) {
27 g_default_icon = ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
28 IDR_EXTENSIONS_FAVICON);
31 return g_default_icon;
34 } // namespace
36 ExtensionTask::ExtensionTask(content::WebContents* web_contents,
37 const extensions::Extension* extension,
38 extensions::ViewType view_type)
39 : RendererTask(GetExtensionTitle(web_contents, extension, view_type),
40 GetDefaultIcon(),
41 web_contents,
42 web_contents->GetRenderProcessHost()) {
45 ExtensionTask::~ExtensionTask() {
48 void ExtensionTask::OnTitleChanged(content::NavigationEntry* entry) {
49 // The title of the extension should not change as a result of title change
50 // in its WebContents, so we ignore this.
53 void ExtensionTask::OnFaviconChanged() {
54 // For now we never change the favicon of the extension, we always use the
55 // default one.
56 // TODO(afakhry): In the future use the extensions' favicons.
59 Task::Type ExtensionTask::GetType() const {
60 return Task::EXTENSION;
63 base::string16 ExtensionTask::GetExtensionTitle(
64 content::WebContents* web_contents,
65 const extensions::Extension* extension,
66 extensions::ViewType view_type) const {
67 DCHECK(web_contents);
69 base::string16 title = extension ?
70 base::UTF8ToUTF16(extension->name()) :
71 RendererTask::GetTitleFromWebContents(web_contents);
73 bool is_background =
74 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE;
76 return RendererTask::PrefixRendererTitle(
77 title,
78 extension->is_app(),
79 true, // is_extension
80 web_contents->GetBrowserContext()->IsOffTheRecord(),
81 is_background);
84 } // namespace task_management