OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "chrome/browser/task_management/providers/web_contents/extension_task.h " | |
6 | |
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" | |
15 | |
16 namespace task_management { | |
17 | |
18 namespace { | |
19 | |
20 gfx::ImageSkia* g_default_icon = nullptr; | |
21 | |
22 gfx::ImageSkia* GetDefaultIcon() { | |
23 if (!g_default_icon && ResourceBundle::HasSharedInstance()) { | |
Devlin
2015/08/04 16:05:07
When would HasSharedInstance() fail? And, if it *
afakhry
2015/08/04 18:31:08
This happened to me once in the past. I opened the
Devlin
2015/08/04 20:22:40
This doesn't really answer the question of "What i
afakhry
2015/08/05 17:20:07
This should never happen. If it does, that's an in
Devlin
2015/08/06 17:43:44
This is probably edge case of edge case, but I dis
afakhry
2015/08/06 18:01:27
I changed it to return nullptr whenever !ResourceB
| |
24 g_default_icon = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | |
25 IDR_PLUGINS_FAVICON); | |
Devlin
2015/08/04 16:05:07
Why use plugins, instead of extensions?
afakhry
2015/08/04 18:31:08
Indeed there's an IDR_EXTENSIONS_FAVICON not sure
ncarter (slow)
2015/08/04 18:55:19
We ought to switch to IDR_EXTENSIONS_FAVICON here.
afakhry
2015/08/05 17:20:07
Done.
| |
26 } | |
27 | |
28 return g_default_icon; | |
29 } | |
30 | |
31 } // namespace | |
32 | |
33 ExtensionTask::ExtensionTask(content::WebContents* web_contents, | |
34 const extensions::Extension* extension) | |
35 : RendererTask(GetExtensionTitle(web_contents, extension), | |
36 GetDefaultIcon(), | |
37 web_contents) { | |
38 } | |
39 | |
40 ExtensionTask::~ExtensionTask() { | |
41 } | |
42 | |
43 void ExtensionTask::OnTitleChanged(content::NavigationEntry* entry) { | |
44 // The title of the extension should not change as a result of title change | |
45 // in its WebContents, so we ignore this. | |
46 } | |
47 | |
48 void ExtensionTask::OnFaviconChanged() { | |
49 // We never change the favicon of the extension, we always use the default | |
Devlin
2015/08/04 16:05:07
Probably out of scope for this change, but why don
afakhry
2015/08/04 18:31:08
I agree. What do you think, Nick?
Devlin, Can we
Devlin
2015/08/04 20:22:40
Sure, indirectly (more like the browser context).
afakhry
2015/08/05 17:20:07
Let me see if I can do that in a follow-up patch.
| |
50 // one. | |
51 } | |
52 | |
53 Task::Type ExtensionTask::GetType() const { | |
54 return Task::EXTENSION; | |
55 } | |
56 | |
57 base::string16 ExtensionTask::GetExtensionTitle( | |
58 content::WebContents* web_contents, | |
59 const extensions::Extension* extension) const { | |
60 DCHECK(web_contents); | |
61 DCHECK(extension); | |
62 | |
63 base::string16 title = base::UTF8ToUTF16(extension->name()); | |
64 | |
65 DCHECK(!title.empty()); | |
66 | |
67 extensions::ViewType view_type = extensions::GetViewType(web_contents); | |
68 bool is_background = | |
69 (view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | |
Devlin
2015/08/04 16:05:07
nitty nit: Can we inline this a bit, to be
bool is
afakhry
2015/08/04 18:31:08
Done.
| |
70 | |
71 return RendererTask::PrefixRendererTitle( | |
72 title, | |
73 extension->is_app(), | |
74 true, // is_extension | |
75 web_contents->GetBrowserContext()->IsOffTheRecord(), | |
76 is_background); | |
77 } | |
78 | |
79 } // namespace task_management | |
OLD | NEW |